babylon.module.d.ts 5.3 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505
  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. * Gets the list of observers
  4360. */
  4361. readonly observers: Array<Observer<T>>;
  4362. /**
  4363. * Creates a new observable
  4364. * @param onObserverAdded defines a callback to call when a new observer is added
  4365. */
  4366. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4367. /**
  4368. * Create a new Observer with the specified callback
  4369. * @param callback the callback that will be executed for that Observer
  4370. * @param mask the mask used to filter observers
  4371. * @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.
  4372. * @param scope optional scope for the callback to be called from
  4373. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4374. * @returns the new observer created for the callback
  4375. */
  4376. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4377. /**
  4378. * Create a new Observer with the specified callback and unregisters after the next notification
  4379. * @param callback the callback that will be executed for that Observer
  4380. * @returns the new observer created for the callback
  4381. */
  4382. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4383. /**
  4384. * Remove an Observer from the Observable object
  4385. * @param observer the instance of the Observer to remove
  4386. * @returns false if it doesn't belong to this Observable
  4387. */
  4388. remove(observer: Nullable<Observer<T>>): boolean;
  4389. /**
  4390. * Remove a callback from the Observable object
  4391. * @param callback the callback to remove
  4392. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4393. * @returns false if it doesn't belong to this Observable
  4394. */
  4395. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4396. private _deferUnregister;
  4397. private _remove;
  4398. /**
  4399. * Moves the observable to the top of the observer list making it get called first when notified
  4400. * @param observer the observer to move
  4401. */
  4402. makeObserverTopPriority(observer: Observer<T>): void;
  4403. /**
  4404. * Moves the observable to the bottom of the observer list making it get called last when notified
  4405. * @param observer the observer to move
  4406. */
  4407. makeObserverBottomPriority(observer: Observer<T>): void;
  4408. /**
  4409. * Notify all Observers by calling their respective callback with the given data
  4410. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4411. * @param eventData defines the data to send to all observers
  4412. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4413. * @param target defines the original target of the state
  4414. * @param currentTarget defines the current target of the state
  4415. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4416. */
  4417. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4418. /**
  4419. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4420. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4421. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4422. * and it is crucial that all callbacks will be executed.
  4423. * The order of the callbacks is kept, callbacks are not executed parallel.
  4424. *
  4425. * @param eventData The data to be sent to each callback
  4426. * @param mask is used to filter observers defaults to -1
  4427. * @param target defines the callback target (see EventState)
  4428. * @param currentTarget defines he current object in the bubbling phase
  4429. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4430. */
  4431. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4432. /**
  4433. * Notify a specific observer
  4434. * @param observer defines the observer to notify
  4435. * @param eventData defines the data to be sent to each callback
  4436. * @param mask is used to filter observers defaults to -1
  4437. */
  4438. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4439. /**
  4440. * Gets a boolean indicating if the observable has at least one observer
  4441. * @returns true is the Observable has at least one Observer registered
  4442. */
  4443. hasObservers(): boolean;
  4444. /**
  4445. * Clear the list of observers
  4446. */
  4447. clear(): void;
  4448. /**
  4449. * Clone the current observable
  4450. * @returns a new observable
  4451. */
  4452. clone(): Observable<T>;
  4453. /**
  4454. * Does this observable handles observer registered with a given mask
  4455. * @param mask defines the mask to be tested
  4456. * @return whether or not one observer registered with the given mask is handeled
  4457. **/
  4458. hasSpecificMask(mask?: number): boolean;
  4459. }
  4460. }
  4461. declare module "babylonjs/Misc/filesInputStore" {
  4462. /**
  4463. * Class used to help managing file picking and drag'n'drop
  4464. * File Storage
  4465. */
  4466. export class FilesInputStore {
  4467. /**
  4468. * List of files ready to be loaded
  4469. */
  4470. static FilesToLoad: {
  4471. [key: string]: File;
  4472. };
  4473. }
  4474. }
  4475. declare module "babylonjs/Engines/constants" {
  4476. /** Defines the cross module used constants to avoid circular dependncies */
  4477. export class Constants {
  4478. /** Defines that alpha blending is disabled */
  4479. static readonly ALPHA_DISABLE: number;
  4480. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4481. static readonly ALPHA_ADD: number;
  4482. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4483. static readonly ALPHA_COMBINE: number;
  4484. /** Defines that alpha blending to DEST - SRC * DEST */
  4485. static readonly ALPHA_SUBTRACT: number;
  4486. /** Defines that alpha blending to SRC * DEST */
  4487. static readonly ALPHA_MULTIPLY: number;
  4488. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4489. static readonly ALPHA_MAXIMIZED: number;
  4490. /** Defines that alpha blending to SRC + DEST */
  4491. static readonly ALPHA_ONEONE: number;
  4492. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4493. static readonly ALPHA_PREMULTIPLIED: number;
  4494. /**
  4495. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4496. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4497. */
  4498. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4499. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4500. static readonly ALPHA_INTERPOLATE: number;
  4501. /**
  4502. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4503. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4504. */
  4505. static readonly ALPHA_SCREENMODE: number;
  4506. /** Defines that the ressource is not delayed*/
  4507. static readonly DELAYLOADSTATE_NONE: number;
  4508. /** Defines that the ressource was successfully delay loaded */
  4509. static readonly DELAYLOADSTATE_LOADED: number;
  4510. /** Defines that the ressource is currently delay loading */
  4511. static readonly DELAYLOADSTATE_LOADING: number;
  4512. /** Defines that the ressource is delayed and has not started loading */
  4513. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4514. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4515. static readonly NEVER: number;
  4516. /** 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 */
  4517. static readonly ALWAYS: number;
  4518. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4519. static readonly LESS: number;
  4520. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4521. static readonly EQUAL: number;
  4522. /** 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 */
  4523. static readonly LEQUAL: number;
  4524. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4525. static readonly GREATER: number;
  4526. /** 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 */
  4527. static readonly GEQUAL: number;
  4528. /** 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 */
  4529. static readonly NOTEQUAL: number;
  4530. /** Passed to stencilOperation to specify that stencil value must be kept */
  4531. static readonly KEEP: number;
  4532. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4533. static readonly REPLACE: number;
  4534. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4535. static readonly INCR: number;
  4536. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4537. static readonly DECR: number;
  4538. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4539. static readonly INVERT: number;
  4540. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4541. static readonly INCR_WRAP: number;
  4542. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4543. static readonly DECR_WRAP: number;
  4544. /** Texture is not repeating outside of 0..1 UVs */
  4545. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4546. /** Texture is repeating outside of 0..1 UVs */
  4547. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4548. /** Texture is repeating and mirrored */
  4549. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4550. /** ALPHA */
  4551. static readonly TEXTUREFORMAT_ALPHA: number;
  4552. /** LUMINANCE */
  4553. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4554. /** LUMINANCE_ALPHA */
  4555. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4556. /** RGB */
  4557. static readonly TEXTUREFORMAT_RGB: number;
  4558. /** RGBA */
  4559. static readonly TEXTUREFORMAT_RGBA: number;
  4560. /** RED */
  4561. static readonly TEXTUREFORMAT_RED: number;
  4562. /** RED (2nd reference) */
  4563. static readonly TEXTUREFORMAT_R: number;
  4564. /** RG */
  4565. static readonly TEXTUREFORMAT_RG: number;
  4566. /** RED_INTEGER */
  4567. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4568. /** RED_INTEGER (2nd reference) */
  4569. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4570. /** RG_INTEGER */
  4571. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4572. /** RGB_INTEGER */
  4573. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4574. /** RGBA_INTEGER */
  4575. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4576. /** UNSIGNED_BYTE */
  4577. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4578. /** UNSIGNED_BYTE (2nd reference) */
  4579. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4580. /** FLOAT */
  4581. static readonly TEXTURETYPE_FLOAT: number;
  4582. /** HALF_FLOAT */
  4583. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4584. /** BYTE */
  4585. static readonly TEXTURETYPE_BYTE: number;
  4586. /** SHORT */
  4587. static readonly TEXTURETYPE_SHORT: number;
  4588. /** UNSIGNED_SHORT */
  4589. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4590. /** INT */
  4591. static readonly TEXTURETYPE_INT: number;
  4592. /** UNSIGNED_INT */
  4593. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4594. /** UNSIGNED_SHORT_4_4_4_4 */
  4595. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4596. /** UNSIGNED_SHORT_5_5_5_1 */
  4597. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4598. /** UNSIGNED_SHORT_5_6_5 */
  4599. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4600. /** UNSIGNED_INT_2_10_10_10_REV */
  4601. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4602. /** UNSIGNED_INT_24_8 */
  4603. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4604. /** UNSIGNED_INT_10F_11F_11F_REV */
  4605. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4606. /** UNSIGNED_INT_5_9_9_9_REV */
  4607. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4608. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4609. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4610. /** nearest is mag = nearest and min = nearest and mip = linear */
  4611. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4612. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4613. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4614. /** Trilinear is mag = linear and min = linear and mip = linear */
  4615. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4616. /** nearest is mag = nearest and min = nearest and mip = linear */
  4617. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4618. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4619. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4620. /** Trilinear is mag = linear and min = linear and mip = linear */
  4621. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4622. /** mag = nearest and min = nearest and mip = nearest */
  4623. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4624. /** mag = nearest and min = linear and mip = nearest */
  4625. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4626. /** mag = nearest and min = linear and mip = linear */
  4627. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4628. /** mag = nearest and min = linear and mip = none */
  4629. static readonly TEXTURE_NEAREST_LINEAR: number;
  4630. /** mag = nearest and min = nearest and mip = none */
  4631. static readonly TEXTURE_NEAREST_NEAREST: number;
  4632. /** mag = linear and min = nearest and mip = nearest */
  4633. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4634. /** mag = linear and min = nearest and mip = linear */
  4635. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4636. /** mag = linear and min = linear and mip = none */
  4637. static readonly TEXTURE_LINEAR_LINEAR: number;
  4638. /** mag = linear and min = nearest and mip = none */
  4639. static readonly TEXTURE_LINEAR_NEAREST: number;
  4640. /** Explicit coordinates mode */
  4641. static readonly TEXTURE_EXPLICIT_MODE: number;
  4642. /** Spherical coordinates mode */
  4643. static readonly TEXTURE_SPHERICAL_MODE: number;
  4644. /** Planar coordinates mode */
  4645. static readonly TEXTURE_PLANAR_MODE: number;
  4646. /** Cubic coordinates mode */
  4647. static readonly TEXTURE_CUBIC_MODE: number;
  4648. /** Projection coordinates mode */
  4649. static readonly TEXTURE_PROJECTION_MODE: number;
  4650. /** Skybox coordinates mode */
  4651. static readonly TEXTURE_SKYBOX_MODE: number;
  4652. /** Inverse Cubic coordinates mode */
  4653. static readonly TEXTURE_INVCUBIC_MODE: number;
  4654. /** Equirectangular coordinates mode */
  4655. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4656. /** Equirectangular Fixed coordinates mode */
  4657. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4658. /** Equirectangular Fixed Mirrored coordinates mode */
  4659. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4660. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4661. static readonly SCALEMODE_FLOOR: number;
  4662. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4663. static readonly SCALEMODE_NEAREST: number;
  4664. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4665. static readonly SCALEMODE_CEILING: number;
  4666. /**
  4667. * The dirty texture flag value
  4668. */
  4669. static readonly MATERIAL_TextureDirtyFlag: number;
  4670. /**
  4671. * The dirty light flag value
  4672. */
  4673. static readonly MATERIAL_LightDirtyFlag: number;
  4674. /**
  4675. * The dirty fresnel flag value
  4676. */
  4677. static readonly MATERIAL_FresnelDirtyFlag: number;
  4678. /**
  4679. * The dirty attribute flag value
  4680. */
  4681. static readonly MATERIAL_AttributesDirtyFlag: number;
  4682. /**
  4683. * The dirty misc flag value
  4684. */
  4685. static readonly MATERIAL_MiscDirtyFlag: number;
  4686. /**
  4687. * The all dirty flag value
  4688. */
  4689. static readonly MATERIAL_AllDirtyFlag: number;
  4690. /**
  4691. * Returns the triangle fill mode
  4692. */
  4693. static readonly MATERIAL_TriangleFillMode: number;
  4694. /**
  4695. * Returns the wireframe mode
  4696. */
  4697. static readonly MATERIAL_WireFrameFillMode: number;
  4698. /**
  4699. * Returns the point fill mode
  4700. */
  4701. static readonly MATERIAL_PointFillMode: number;
  4702. /**
  4703. * Returns the point list draw mode
  4704. */
  4705. static readonly MATERIAL_PointListDrawMode: number;
  4706. /**
  4707. * Returns the line list draw mode
  4708. */
  4709. static readonly MATERIAL_LineListDrawMode: number;
  4710. /**
  4711. * Returns the line loop draw mode
  4712. */
  4713. static readonly MATERIAL_LineLoopDrawMode: number;
  4714. /**
  4715. * Returns the line strip draw mode
  4716. */
  4717. static readonly MATERIAL_LineStripDrawMode: number;
  4718. /**
  4719. * Returns the triangle strip draw mode
  4720. */
  4721. static readonly MATERIAL_TriangleStripDrawMode: number;
  4722. /**
  4723. * Returns the triangle fan draw mode
  4724. */
  4725. static readonly MATERIAL_TriangleFanDrawMode: number;
  4726. /**
  4727. * Stores the clock-wise side orientation
  4728. */
  4729. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4730. /**
  4731. * Stores the counter clock-wise side orientation
  4732. */
  4733. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4734. /**
  4735. * Nothing
  4736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4737. */
  4738. static readonly ACTION_NothingTrigger: number;
  4739. /**
  4740. * On pick
  4741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4742. */
  4743. static readonly ACTION_OnPickTrigger: number;
  4744. /**
  4745. * On left pick
  4746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4747. */
  4748. static readonly ACTION_OnLeftPickTrigger: number;
  4749. /**
  4750. * On right pick
  4751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4752. */
  4753. static readonly ACTION_OnRightPickTrigger: number;
  4754. /**
  4755. * On center pick
  4756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4757. */
  4758. static readonly ACTION_OnCenterPickTrigger: number;
  4759. /**
  4760. * On pick down
  4761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4762. */
  4763. static readonly ACTION_OnPickDownTrigger: number;
  4764. /**
  4765. * On double pick
  4766. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4767. */
  4768. static readonly ACTION_OnDoublePickTrigger: number;
  4769. /**
  4770. * On pick up
  4771. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4772. */
  4773. static readonly ACTION_OnPickUpTrigger: number;
  4774. /**
  4775. * On pick out.
  4776. * This trigger will only be raised if you also declared a OnPickDown
  4777. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4778. */
  4779. static readonly ACTION_OnPickOutTrigger: number;
  4780. /**
  4781. * On long press
  4782. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4783. */
  4784. static readonly ACTION_OnLongPressTrigger: number;
  4785. /**
  4786. * On pointer over
  4787. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4788. */
  4789. static readonly ACTION_OnPointerOverTrigger: number;
  4790. /**
  4791. * On pointer out
  4792. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4793. */
  4794. static readonly ACTION_OnPointerOutTrigger: number;
  4795. /**
  4796. * On every frame
  4797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4798. */
  4799. static readonly ACTION_OnEveryFrameTrigger: number;
  4800. /**
  4801. * On intersection enter
  4802. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4803. */
  4804. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4805. /**
  4806. * On intersection exit
  4807. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4808. */
  4809. static readonly ACTION_OnIntersectionExitTrigger: number;
  4810. /**
  4811. * On key down
  4812. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4813. */
  4814. static readonly ACTION_OnKeyDownTrigger: number;
  4815. /**
  4816. * On key up
  4817. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4818. */
  4819. static readonly ACTION_OnKeyUpTrigger: number;
  4820. /**
  4821. * Billboard mode will only apply to Y axis
  4822. */
  4823. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4824. /**
  4825. * Billboard mode will apply to all axes
  4826. */
  4827. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4828. /**
  4829. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4830. */
  4831. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4832. /**
  4833. * Gets or sets base Assets URL
  4834. */
  4835. static PARTICLES_BaseAssetsUrl: string;
  4836. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4837. * Test order :
  4838. * Is the bounding sphere outside the frustum ?
  4839. * If not, are the bounding box vertices outside the frustum ?
  4840. * It not, then the cullable object is in the frustum.
  4841. */
  4842. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4843. /** Culling strategy : Bounding Sphere Only.
  4844. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4845. * It's also less accurate than the standard because some not visible objects can still be selected.
  4846. * Test : is the bounding sphere outside the frustum ?
  4847. * If not, then the cullable object is in the frustum.
  4848. */
  4849. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4850. /** Culling strategy : Optimistic Inclusion.
  4851. * This in an inclusion test first, then the standard exclusion test.
  4852. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4853. * 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.
  4854. * Anyway, it's as accurate as the standard strategy.
  4855. * Test :
  4856. * Is the cullable object bounding sphere center in the frustum ?
  4857. * If not, apply the default culling strategy.
  4858. */
  4859. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4860. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4861. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4862. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4863. * 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.
  4864. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4865. * Test :
  4866. * Is the cullable object bounding sphere center in the frustum ?
  4867. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4868. */
  4869. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4870. /**
  4871. * No logging while loading
  4872. */
  4873. static readonly SCENELOADER_NO_LOGGING: number;
  4874. /**
  4875. * Minimal logging while loading
  4876. */
  4877. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4878. /**
  4879. * Summary logging while loading
  4880. */
  4881. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4882. /**
  4883. * Detailled logging while loading
  4884. */
  4885. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4886. }
  4887. }
  4888. declare module "babylonjs/Misc/domManagement" {
  4889. /**
  4890. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4891. * Babylon.js
  4892. */
  4893. export class DomManagement {
  4894. /**
  4895. * Checks if the window object exists
  4896. * @returns true if the window object exists
  4897. */
  4898. static IsWindowObjectExist(): boolean;
  4899. /**
  4900. * Extracts text content from a DOM element hierarchy
  4901. * @param element defines the root element
  4902. * @returns a string
  4903. */
  4904. static GetDOMTextContent(element: HTMLElement): string;
  4905. }
  4906. }
  4907. declare module "babylonjs/Misc/logger" {
  4908. /**
  4909. * Logger used througouht the application to allow configuration of
  4910. * the log level required for the messages.
  4911. */
  4912. export class Logger {
  4913. /**
  4914. * No log
  4915. */
  4916. static readonly NoneLogLevel: number;
  4917. /**
  4918. * Only message logs
  4919. */
  4920. static readonly MessageLogLevel: number;
  4921. /**
  4922. * Only warning logs
  4923. */
  4924. static readonly WarningLogLevel: number;
  4925. /**
  4926. * Only error logs
  4927. */
  4928. static readonly ErrorLogLevel: number;
  4929. /**
  4930. * All logs
  4931. */
  4932. static readonly AllLogLevel: number;
  4933. private static _LogCache;
  4934. /**
  4935. * Gets a value indicating the number of loading errors
  4936. * @ignorenaming
  4937. */
  4938. static errorsCount: number;
  4939. /**
  4940. * Callback called when a new log is added
  4941. */
  4942. static OnNewCacheEntry: (entry: string) => void;
  4943. private static _AddLogEntry;
  4944. private static _FormatMessage;
  4945. private static _LogDisabled;
  4946. private static _LogEnabled;
  4947. private static _WarnDisabled;
  4948. private static _WarnEnabled;
  4949. private static _ErrorDisabled;
  4950. private static _ErrorEnabled;
  4951. /**
  4952. * Log a message to the console
  4953. */
  4954. static Log: (message: string) => void;
  4955. /**
  4956. * Write a warning message to the console
  4957. */
  4958. static Warn: (message: string) => void;
  4959. /**
  4960. * Write an error message to the console
  4961. */
  4962. static Error: (message: string) => void;
  4963. /**
  4964. * Gets current log cache (list of logs)
  4965. */
  4966. static readonly LogCache: string;
  4967. /**
  4968. * Clears the log cache
  4969. */
  4970. static ClearLogCache(): void;
  4971. /**
  4972. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4973. */
  4974. static LogLevels: number;
  4975. }
  4976. }
  4977. declare module "babylonjs/Misc/typeStore" {
  4978. /** @hidden */
  4979. export class _TypeStore {
  4980. /** @hidden */
  4981. static RegisteredTypes: {
  4982. [key: string]: Object;
  4983. };
  4984. /** @hidden */
  4985. static GetClass(fqdn: string): any;
  4986. }
  4987. }
  4988. declare module "babylonjs/Misc/deepCopier" {
  4989. /**
  4990. * Class containing a set of static utilities functions for deep copy.
  4991. */
  4992. export class DeepCopier {
  4993. /**
  4994. * Tries to copy an object by duplicating every property
  4995. * @param source defines the source object
  4996. * @param destination defines the target object
  4997. * @param doNotCopyList defines a list of properties to avoid
  4998. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4999. */
  5000. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  5001. }
  5002. }
  5003. declare module "babylonjs/Misc/precisionDate" {
  5004. /**
  5005. * Class containing a set of static utilities functions for precision date
  5006. */
  5007. export class PrecisionDate {
  5008. /**
  5009. * Gets either window.performance.now() if supported or Date.now() else
  5010. */
  5011. static readonly Now: number;
  5012. }
  5013. }
  5014. declare module "babylonjs/Misc/devTools" {
  5015. /** @hidden */
  5016. export class _DevTools {
  5017. static WarnImport(name: string): string;
  5018. }
  5019. }
  5020. declare module "babylonjs/Misc/webRequest" {
  5021. /**
  5022. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  5023. */
  5024. export class WebRequest {
  5025. private _xhr;
  5026. /**
  5027. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5028. * i.e. when loading files, where the server/service expects an Authorization header
  5029. */
  5030. static CustomRequestHeaders: {
  5031. [key: string]: string;
  5032. };
  5033. /**
  5034. * Add callback functions in this array to update all the requests before they get sent to the network
  5035. */
  5036. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  5037. private _injectCustomRequestHeaders;
  5038. /**
  5039. * Gets or sets a function to be called when loading progress changes
  5040. */
  5041. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5042. /**
  5043. * Returns client's state
  5044. */
  5045. readonly readyState: number;
  5046. /**
  5047. * Returns client's status
  5048. */
  5049. readonly status: number;
  5050. /**
  5051. * Returns client's status as a text
  5052. */
  5053. readonly statusText: string;
  5054. /**
  5055. * Returns client's response
  5056. */
  5057. readonly response: any;
  5058. /**
  5059. * Returns client's response url
  5060. */
  5061. readonly responseURL: string;
  5062. /**
  5063. * Returns client's response as text
  5064. */
  5065. readonly responseText: string;
  5066. /**
  5067. * Gets or sets the expected response type
  5068. */
  5069. responseType: XMLHttpRequestResponseType;
  5070. /** @hidden */
  5071. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5072. /** @hidden */
  5073. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5074. /**
  5075. * Cancels any network activity
  5076. */
  5077. abort(): void;
  5078. /**
  5079. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5080. * @param body defines an optional request body
  5081. */
  5082. send(body?: Document | BodyInit | null): void;
  5083. /**
  5084. * Sets the request method, request URL
  5085. * @param method defines the method to use (GET, POST, etc..)
  5086. * @param url defines the url to connect with
  5087. */
  5088. open(method: string, url: string): void;
  5089. }
  5090. }
  5091. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5092. /**
  5093. * Class used to evalaute queries containing `and` and `or` operators
  5094. */
  5095. export class AndOrNotEvaluator {
  5096. /**
  5097. * Evaluate a query
  5098. * @param query defines the query to evaluate
  5099. * @param evaluateCallback defines the callback used to filter result
  5100. * @returns true if the query matches
  5101. */
  5102. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5103. private static _HandleParenthesisContent;
  5104. private static _SimplifyNegation;
  5105. }
  5106. }
  5107. declare module "babylonjs/Misc/tags" {
  5108. /**
  5109. * Class used to store custom tags
  5110. */
  5111. export class Tags {
  5112. /**
  5113. * Adds support for tags on the given object
  5114. * @param obj defines the object to use
  5115. */
  5116. static EnableFor(obj: any): void;
  5117. /**
  5118. * Removes tags support
  5119. * @param obj defines the object to use
  5120. */
  5121. static DisableFor(obj: any): void;
  5122. /**
  5123. * Gets a boolean indicating if the given object has tags
  5124. * @param obj defines the object to use
  5125. * @returns a boolean
  5126. */
  5127. static HasTags(obj: any): boolean;
  5128. /**
  5129. * Gets the tags available on a given object
  5130. * @param obj defines the object to use
  5131. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5132. * @returns the tags
  5133. */
  5134. static GetTags(obj: any, asString?: boolean): any;
  5135. /**
  5136. * Adds tags to an object
  5137. * @param obj defines the object to use
  5138. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5139. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5140. */
  5141. static AddTagsTo(obj: any, tagsString: string): void;
  5142. /**
  5143. * @hidden
  5144. */
  5145. static _AddTagTo(obj: any, tag: string): void;
  5146. /**
  5147. * Removes specific tags from a specific object
  5148. * @param obj defines the object to use
  5149. * @param tagsString defines the tags to remove
  5150. */
  5151. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5152. /**
  5153. * @hidden
  5154. */
  5155. static _RemoveTagFrom(obj: any, tag: string): void;
  5156. /**
  5157. * Defines if tags hosted on an object match a given query
  5158. * @param obj defines the object to use
  5159. * @param tagsQuery defines the tag query
  5160. * @returns a boolean
  5161. */
  5162. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5163. }
  5164. }
  5165. declare module "babylonjs/Materials/materialDefines" {
  5166. /**
  5167. * Manages the defines for the Material
  5168. */
  5169. export class MaterialDefines {
  5170. /** @hidden */
  5171. protected _keys: string[];
  5172. private _isDirty;
  5173. /** @hidden */
  5174. _renderId: number;
  5175. /** @hidden */
  5176. _areLightsDirty: boolean;
  5177. /** @hidden */
  5178. _areAttributesDirty: boolean;
  5179. /** @hidden */
  5180. _areTexturesDirty: boolean;
  5181. /** @hidden */
  5182. _areFresnelDirty: boolean;
  5183. /** @hidden */
  5184. _areMiscDirty: boolean;
  5185. /** @hidden */
  5186. _areImageProcessingDirty: boolean;
  5187. /** @hidden */
  5188. _normals: boolean;
  5189. /** @hidden */
  5190. _uvs: boolean;
  5191. /** @hidden */
  5192. _needNormals: boolean;
  5193. /** @hidden */
  5194. _needUVs: boolean;
  5195. [id: string]: any;
  5196. /**
  5197. * Specifies if the material needs to be re-calculated
  5198. */
  5199. readonly isDirty: boolean;
  5200. /**
  5201. * Marks the material to indicate that it has been re-calculated
  5202. */
  5203. markAsProcessed(): void;
  5204. /**
  5205. * Marks the material to indicate that it needs to be re-calculated
  5206. */
  5207. markAsUnprocessed(): void;
  5208. /**
  5209. * Marks the material to indicate all of its defines need to be re-calculated
  5210. */
  5211. markAllAsDirty(): void;
  5212. /**
  5213. * Marks the material to indicate that image processing needs to be re-calculated
  5214. */
  5215. markAsImageProcessingDirty(): void;
  5216. /**
  5217. * Marks the material to indicate the lights need to be re-calculated
  5218. */
  5219. markAsLightDirty(): void;
  5220. /**
  5221. * Marks the attribute state as changed
  5222. */
  5223. markAsAttributesDirty(): void;
  5224. /**
  5225. * Marks the texture state as changed
  5226. */
  5227. markAsTexturesDirty(): void;
  5228. /**
  5229. * Marks the fresnel state as changed
  5230. */
  5231. markAsFresnelDirty(): void;
  5232. /**
  5233. * Marks the misc state as changed
  5234. */
  5235. markAsMiscDirty(): void;
  5236. /**
  5237. * Rebuilds the material defines
  5238. */
  5239. rebuild(): void;
  5240. /**
  5241. * Specifies if two material defines are equal
  5242. * @param other - A material define instance to compare to
  5243. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5244. */
  5245. isEqual(other: MaterialDefines): boolean;
  5246. /**
  5247. * Clones this instance's defines to another instance
  5248. * @param other - material defines to clone values to
  5249. */
  5250. cloneTo(other: MaterialDefines): void;
  5251. /**
  5252. * Resets the material define values
  5253. */
  5254. reset(): void;
  5255. /**
  5256. * Converts the material define values to a string
  5257. * @returns - String of material define information
  5258. */
  5259. toString(): string;
  5260. }
  5261. }
  5262. declare module "babylonjs/Engines/IPipelineContext" {
  5263. /**
  5264. * Class used to store and describe the pipeline context associated with an effect
  5265. */
  5266. export interface IPipelineContext {
  5267. /**
  5268. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5269. */
  5270. isAsync: boolean;
  5271. /**
  5272. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5273. */
  5274. isReady: boolean;
  5275. /** @hidden */
  5276. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5277. }
  5278. }
  5279. declare module "babylonjs/Meshes/dataBuffer" {
  5280. /**
  5281. * Class used to store gfx data (like WebGLBuffer)
  5282. */
  5283. export class DataBuffer {
  5284. /**
  5285. * Gets or sets the number of objects referencing this buffer
  5286. */
  5287. references: number;
  5288. /** Gets or sets the size of the underlying buffer */
  5289. capacity: number;
  5290. /**
  5291. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5292. */
  5293. is32Bits: boolean;
  5294. /**
  5295. * Gets the underlying buffer
  5296. */
  5297. readonly underlyingResource: any;
  5298. }
  5299. }
  5300. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  5301. /** @hidden */
  5302. export interface IShaderProcessor {
  5303. attributeProcessor?: (attribute: string) => string;
  5304. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  5305. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  5306. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  5307. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  5308. lineProcessor?: (line: string, isFragment: boolean) => string;
  5309. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5310. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  5311. }
  5312. }
  5313. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  5314. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  5315. /** @hidden */
  5316. export interface ProcessingOptions {
  5317. defines: string[];
  5318. indexParameters: any;
  5319. isFragment: boolean;
  5320. shouldUseHighPrecisionShader: boolean;
  5321. supportsUniformBuffers: boolean;
  5322. shadersRepository: string;
  5323. includesShadersStore: {
  5324. [key: string]: string;
  5325. };
  5326. processor?: IShaderProcessor;
  5327. version: string;
  5328. platformName: string;
  5329. lookForClosingBracketForUniformBuffer?: boolean;
  5330. }
  5331. }
  5332. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  5333. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5334. /** @hidden */
  5335. export class ShaderCodeNode {
  5336. line: string;
  5337. children: ShaderCodeNode[];
  5338. additionalDefineKey?: string;
  5339. additionalDefineValue?: string;
  5340. isValid(preprocessors: {
  5341. [key: string]: string;
  5342. }): boolean;
  5343. process(preprocessors: {
  5344. [key: string]: string;
  5345. }, options: ProcessingOptions): string;
  5346. }
  5347. }
  5348. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  5349. /** @hidden */
  5350. export class ShaderCodeCursor {
  5351. private _lines;
  5352. lineIndex: number;
  5353. readonly currentLine: string;
  5354. readonly canRead: boolean;
  5355. lines: string[];
  5356. }
  5357. }
  5358. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  5359. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  5360. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5361. /** @hidden */
  5362. export class ShaderCodeConditionNode extends ShaderCodeNode {
  5363. process(preprocessors: {
  5364. [key: string]: string;
  5365. }, options: ProcessingOptions): string;
  5366. }
  5367. }
  5368. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  5369. /** @hidden */
  5370. export class ShaderDefineExpression {
  5371. isTrue(preprocessors: {
  5372. [key: string]: string;
  5373. }): boolean;
  5374. }
  5375. }
  5376. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  5377. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  5378. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5379. /** @hidden */
  5380. export class ShaderCodeTestNode extends ShaderCodeNode {
  5381. testExpression: ShaderDefineExpression;
  5382. isValid(preprocessors: {
  5383. [key: string]: string;
  5384. }): boolean;
  5385. }
  5386. }
  5387. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  5388. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5389. /** @hidden */
  5390. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  5391. define: string;
  5392. not: boolean;
  5393. constructor(define: string, not?: boolean);
  5394. isTrue(preprocessors: {
  5395. [key: string]: string;
  5396. }): boolean;
  5397. }
  5398. }
  5399. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  5400. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5401. /** @hidden */
  5402. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  5403. leftOperand: ShaderDefineExpression;
  5404. rightOperand: ShaderDefineExpression;
  5405. isTrue(preprocessors: {
  5406. [key: string]: string;
  5407. }): boolean;
  5408. }
  5409. }
  5410. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  5411. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5412. /** @hidden */
  5413. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  5414. leftOperand: ShaderDefineExpression;
  5415. rightOperand: ShaderDefineExpression;
  5416. isTrue(preprocessors: {
  5417. [key: string]: string;
  5418. }): boolean;
  5419. }
  5420. }
  5421. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  5422. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5423. /** @hidden */
  5424. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  5425. define: string;
  5426. operand: string;
  5427. testValue: string;
  5428. constructor(define: string, operand: string, testValue: string);
  5429. isTrue(preprocessors: {
  5430. [key: string]: string;
  5431. }): boolean;
  5432. }
  5433. }
  5434. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  5435. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5436. /** @hidden */
  5437. export class ShaderProcessor {
  5438. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5439. private static _ProcessPrecision;
  5440. private static _ExtractOperation;
  5441. private static _BuildSubExpression;
  5442. private static _BuildExpression;
  5443. private static _MoveCursorWithinIf;
  5444. private static _MoveCursor;
  5445. private static _EvaluatePreProcessors;
  5446. private static _PreparePreProcessors;
  5447. private static _ProcessShaderConversion;
  5448. private static _ProcessIncludes;
  5449. }
  5450. }
  5451. declare module "babylonjs/Misc/performanceMonitor" {
  5452. /**
  5453. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5454. */
  5455. export class PerformanceMonitor {
  5456. private _enabled;
  5457. private _rollingFrameTime;
  5458. private _lastFrameTimeMs;
  5459. /**
  5460. * constructor
  5461. * @param frameSampleSize The number of samples required to saturate the sliding window
  5462. */
  5463. constructor(frameSampleSize?: number);
  5464. /**
  5465. * Samples current frame
  5466. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5467. */
  5468. sampleFrame(timeMs?: number): void;
  5469. /**
  5470. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5471. */
  5472. readonly averageFrameTime: number;
  5473. /**
  5474. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5475. */
  5476. readonly averageFrameTimeVariance: number;
  5477. /**
  5478. * Returns the frame time of the most recent frame
  5479. */
  5480. readonly instantaneousFrameTime: number;
  5481. /**
  5482. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5483. */
  5484. readonly averageFPS: number;
  5485. /**
  5486. * Returns the average framerate in frames per second using the most recent frame time
  5487. */
  5488. readonly instantaneousFPS: number;
  5489. /**
  5490. * Returns true if enough samples have been taken to completely fill the sliding window
  5491. */
  5492. readonly isSaturated: boolean;
  5493. /**
  5494. * Enables contributions to the sliding window sample set
  5495. */
  5496. enable(): void;
  5497. /**
  5498. * Disables contributions to the sliding window sample set
  5499. * Samples will not be interpolated over the disabled period
  5500. */
  5501. disable(): void;
  5502. /**
  5503. * Returns true if sampling is enabled
  5504. */
  5505. readonly isEnabled: boolean;
  5506. /**
  5507. * Resets performance monitor
  5508. */
  5509. reset(): void;
  5510. }
  5511. /**
  5512. * RollingAverage
  5513. *
  5514. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5515. */
  5516. export class RollingAverage {
  5517. /**
  5518. * Current average
  5519. */
  5520. average: number;
  5521. /**
  5522. * Current variance
  5523. */
  5524. variance: number;
  5525. protected _samples: Array<number>;
  5526. protected _sampleCount: number;
  5527. protected _pos: number;
  5528. protected _m2: number;
  5529. /**
  5530. * constructor
  5531. * @param length The number of samples required to saturate the sliding window
  5532. */
  5533. constructor(length: number);
  5534. /**
  5535. * Adds a sample to the sample set
  5536. * @param v The sample value
  5537. */
  5538. add(v: number): void;
  5539. /**
  5540. * Returns previously added values or null if outside of history or outside the sliding window domain
  5541. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5542. * @return Value previously recorded with add() or null if outside of range
  5543. */
  5544. history(i: number): number;
  5545. /**
  5546. * Returns true if enough samples have been taken to completely fill the sliding window
  5547. * @return true if sample-set saturated
  5548. */
  5549. isSaturated(): boolean;
  5550. /**
  5551. * Resets the rolling average (equivalent to 0 samples taken so far)
  5552. */
  5553. reset(): void;
  5554. /**
  5555. * Wraps a value around the sample range boundaries
  5556. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5557. * @return Wrapped position in sample range
  5558. */
  5559. protected _wrapPosition(i: number): number;
  5560. }
  5561. }
  5562. declare module "babylonjs/Misc/stringDictionary" {
  5563. import { Nullable } from "babylonjs/types";
  5564. /**
  5565. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5566. * The underlying implementation relies on an associative array to ensure the best performances.
  5567. * The value can be anything including 'null' but except 'undefined'
  5568. */
  5569. export class StringDictionary<T> {
  5570. /**
  5571. * This will clear this dictionary and copy the content from the 'source' one.
  5572. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5573. * @param source the dictionary to take the content from and copy to this dictionary
  5574. */
  5575. copyFrom(source: StringDictionary<T>): void;
  5576. /**
  5577. * Get a value based from its key
  5578. * @param key the given key to get the matching value from
  5579. * @return the value if found, otherwise undefined is returned
  5580. */
  5581. get(key: string): T | undefined;
  5582. /**
  5583. * Get a value from its key or add it if it doesn't exist.
  5584. * This method will ensure you that a given key/data will be present in the dictionary.
  5585. * @param key the given key to get the matching value from
  5586. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5587. * The factory will only be invoked if there's no data for the given key.
  5588. * @return the value corresponding to the key.
  5589. */
  5590. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5591. /**
  5592. * Get a value from its key if present in the dictionary otherwise add it
  5593. * @param key the key to get the value from
  5594. * @param val if there's no such key/value pair in the dictionary add it with this value
  5595. * @return the value corresponding to the key
  5596. */
  5597. getOrAdd(key: string, val: T): T;
  5598. /**
  5599. * Check if there's a given key in the dictionary
  5600. * @param key the key to check for
  5601. * @return true if the key is present, false otherwise
  5602. */
  5603. contains(key: string): boolean;
  5604. /**
  5605. * Add a new key and its corresponding value
  5606. * @param key the key to add
  5607. * @param value the value corresponding to the key
  5608. * @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
  5609. */
  5610. add(key: string, value: T): boolean;
  5611. /**
  5612. * Update a specific value associated to a key
  5613. * @param key defines the key to use
  5614. * @param value defines the value to store
  5615. * @returns true if the value was updated (or false if the key was not found)
  5616. */
  5617. set(key: string, value: T): boolean;
  5618. /**
  5619. * Get the element of the given key and remove it from the dictionary
  5620. * @param key defines the key to search
  5621. * @returns the value associated with the key or null if not found
  5622. */
  5623. getAndRemove(key: string): Nullable<T>;
  5624. /**
  5625. * Remove a key/value from the dictionary.
  5626. * @param key the key to remove
  5627. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5628. */
  5629. remove(key: string): boolean;
  5630. /**
  5631. * Clear the whole content of the dictionary
  5632. */
  5633. clear(): void;
  5634. /**
  5635. * Gets the current count
  5636. */
  5637. readonly count: number;
  5638. /**
  5639. * Execute a callback on each key/val of the dictionary.
  5640. * Note that you can remove any element in this dictionary in the callback implementation
  5641. * @param callback the callback to execute on a given key/value pair
  5642. */
  5643. forEach(callback: (key: string, val: T) => void): void;
  5644. /**
  5645. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5646. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5647. * Note that you can remove any element in this dictionary in the callback implementation
  5648. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5649. * @returns the first item
  5650. */
  5651. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5652. private _count;
  5653. private _data;
  5654. }
  5655. }
  5656. declare module "babylonjs/Misc/promise" {
  5657. /**
  5658. * Helper class that provides a small promise polyfill
  5659. */
  5660. export class PromisePolyfill {
  5661. /**
  5662. * Static function used to check if the polyfill is required
  5663. * If this is the case then the function will inject the polyfill to window.Promise
  5664. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5665. */
  5666. static Apply(force?: boolean): void;
  5667. }
  5668. }
  5669. declare module "babylonjs/Meshes/buffer" {
  5670. import { Nullable, DataArray } from "babylonjs/types";
  5671. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  5672. /**
  5673. * Class used to store data that will be store in GPU memory
  5674. */
  5675. export class Buffer {
  5676. private _engine;
  5677. private _buffer;
  5678. /** @hidden */
  5679. _data: Nullable<DataArray>;
  5680. private _updatable;
  5681. private _instanced;
  5682. /**
  5683. * Gets the byte stride.
  5684. */
  5685. readonly byteStride: number;
  5686. /**
  5687. * Constructor
  5688. * @param engine the engine
  5689. * @param data the data to use for this buffer
  5690. * @param updatable whether the data is updatable
  5691. * @param stride the stride (optional)
  5692. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5693. * @param instanced whether the buffer is instanced (optional)
  5694. * @param useBytes set to true if the stride in in bytes (optional)
  5695. */
  5696. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5697. /**
  5698. * Create a new VertexBuffer based on the current buffer
  5699. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5700. * @param offset defines offset in the buffer (0 by default)
  5701. * @param size defines the size in floats of attributes (position is 3 for instance)
  5702. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5703. * @param instanced defines if the vertex buffer contains indexed data
  5704. * @param useBytes defines if the offset and stride are in bytes
  5705. * @returns the new vertex buffer
  5706. */
  5707. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5708. /**
  5709. * Gets a boolean indicating if the Buffer is updatable?
  5710. * @returns true if the buffer is updatable
  5711. */
  5712. isUpdatable(): boolean;
  5713. /**
  5714. * Gets current buffer's data
  5715. * @returns a DataArray or null
  5716. */
  5717. getData(): Nullable<DataArray>;
  5718. /**
  5719. * Gets underlying native buffer
  5720. * @returns underlying native buffer
  5721. */
  5722. getBuffer(): Nullable<DataBuffer>;
  5723. /**
  5724. * Gets the stride in float32 units (i.e. byte stride / 4).
  5725. * May not be an integer if the byte stride is not divisible by 4.
  5726. * DEPRECATED. Use byteStride instead.
  5727. * @returns the stride in float32 units
  5728. */
  5729. getStrideSize(): number;
  5730. /**
  5731. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5732. * @param data defines the data to store
  5733. */
  5734. create(data?: Nullable<DataArray>): void;
  5735. /** @hidden */
  5736. _rebuild(): void;
  5737. /**
  5738. * Update current buffer data
  5739. * @param data defines the data to store
  5740. */
  5741. update(data: DataArray): void;
  5742. /**
  5743. * Updates the data directly.
  5744. * @param data the new data
  5745. * @param offset the new offset
  5746. * @param vertexCount the vertex count (optional)
  5747. * @param useBytes set to true if the offset is in bytes
  5748. */
  5749. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5750. /**
  5751. * Release all resources
  5752. */
  5753. dispose(): void;
  5754. }
  5755. /**
  5756. * Specialized buffer used to store vertex data
  5757. */
  5758. export class VertexBuffer {
  5759. /** @hidden */
  5760. _buffer: Buffer;
  5761. private _kind;
  5762. private _size;
  5763. private _ownsBuffer;
  5764. private _instanced;
  5765. private _instanceDivisor;
  5766. /**
  5767. * The byte type.
  5768. */
  5769. static readonly BYTE: number;
  5770. /**
  5771. * The unsigned byte type.
  5772. */
  5773. static readonly UNSIGNED_BYTE: number;
  5774. /**
  5775. * The short type.
  5776. */
  5777. static readonly SHORT: number;
  5778. /**
  5779. * The unsigned short type.
  5780. */
  5781. static readonly UNSIGNED_SHORT: number;
  5782. /**
  5783. * The integer type.
  5784. */
  5785. static readonly INT: number;
  5786. /**
  5787. * The unsigned integer type.
  5788. */
  5789. static readonly UNSIGNED_INT: number;
  5790. /**
  5791. * The float type.
  5792. */
  5793. static readonly FLOAT: number;
  5794. /**
  5795. * Gets or sets the instance divisor when in instanced mode
  5796. */
  5797. instanceDivisor: number;
  5798. /**
  5799. * Gets the byte stride.
  5800. */
  5801. readonly byteStride: number;
  5802. /**
  5803. * Gets the byte offset.
  5804. */
  5805. readonly byteOffset: number;
  5806. /**
  5807. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5808. */
  5809. readonly normalized: boolean;
  5810. /**
  5811. * Gets the data type of each component in the array.
  5812. */
  5813. readonly type: number;
  5814. /**
  5815. * Constructor
  5816. * @param engine the engine
  5817. * @param data the data to use for this vertex buffer
  5818. * @param kind the vertex buffer kind
  5819. * @param updatable whether the data is updatable
  5820. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5821. * @param stride the stride (optional)
  5822. * @param instanced whether the buffer is instanced (optional)
  5823. * @param offset the offset of the data (optional)
  5824. * @param size the number of components (optional)
  5825. * @param type the type of the component (optional)
  5826. * @param normalized whether the data contains normalized data (optional)
  5827. * @param useBytes set to true if stride and offset are in bytes (optional)
  5828. */
  5829. 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);
  5830. /** @hidden */
  5831. _rebuild(): void;
  5832. /**
  5833. * Returns the kind of the VertexBuffer (string)
  5834. * @returns a string
  5835. */
  5836. getKind(): string;
  5837. /**
  5838. * Gets a boolean indicating if the VertexBuffer is updatable?
  5839. * @returns true if the buffer is updatable
  5840. */
  5841. isUpdatable(): boolean;
  5842. /**
  5843. * Gets current buffer's data
  5844. * @returns a DataArray or null
  5845. */
  5846. getData(): Nullable<DataArray>;
  5847. /**
  5848. * Gets underlying native buffer
  5849. * @returns underlying native buffer
  5850. */
  5851. getBuffer(): Nullable<DataBuffer>;
  5852. /**
  5853. * Gets the stride in float32 units (i.e. byte stride / 4).
  5854. * May not be an integer if the byte stride is not divisible by 4.
  5855. * DEPRECATED. Use byteStride instead.
  5856. * @returns the stride in float32 units
  5857. */
  5858. getStrideSize(): number;
  5859. /**
  5860. * Returns the offset as a multiple of the type byte length.
  5861. * DEPRECATED. Use byteOffset instead.
  5862. * @returns the offset in bytes
  5863. */
  5864. getOffset(): number;
  5865. /**
  5866. * Returns the number of components per vertex attribute (integer)
  5867. * @returns the size in float
  5868. */
  5869. getSize(): number;
  5870. /**
  5871. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5872. * @returns true if this buffer is instanced
  5873. */
  5874. getIsInstanced(): boolean;
  5875. /**
  5876. * Returns the instancing divisor, zero for non-instanced (integer).
  5877. * @returns a number
  5878. */
  5879. getInstanceDivisor(): number;
  5880. /**
  5881. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5882. * @param data defines the data to store
  5883. */
  5884. create(data?: DataArray): void;
  5885. /**
  5886. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5887. * This function will create a new buffer if the current one is not updatable
  5888. * @param data defines the data to store
  5889. */
  5890. update(data: DataArray): void;
  5891. /**
  5892. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5893. * Returns the directly updated WebGLBuffer.
  5894. * @param data the new data
  5895. * @param offset the new offset
  5896. * @param useBytes set to true if the offset is in bytes
  5897. */
  5898. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5899. /**
  5900. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5901. */
  5902. dispose(): void;
  5903. /**
  5904. * Enumerates each value of this vertex buffer as numbers.
  5905. * @param count the number of values to enumerate
  5906. * @param callback the callback function called for each value
  5907. */
  5908. forEach(count: number, callback: (value: number, index: number) => void): void;
  5909. /**
  5910. * Positions
  5911. */
  5912. static readonly PositionKind: string;
  5913. /**
  5914. * Normals
  5915. */
  5916. static readonly NormalKind: string;
  5917. /**
  5918. * Tangents
  5919. */
  5920. static readonly TangentKind: string;
  5921. /**
  5922. * Texture coordinates
  5923. */
  5924. static readonly UVKind: string;
  5925. /**
  5926. * Texture coordinates 2
  5927. */
  5928. static readonly UV2Kind: string;
  5929. /**
  5930. * Texture coordinates 3
  5931. */
  5932. static readonly UV3Kind: string;
  5933. /**
  5934. * Texture coordinates 4
  5935. */
  5936. static readonly UV4Kind: string;
  5937. /**
  5938. * Texture coordinates 5
  5939. */
  5940. static readonly UV5Kind: string;
  5941. /**
  5942. * Texture coordinates 6
  5943. */
  5944. static readonly UV6Kind: string;
  5945. /**
  5946. * Colors
  5947. */
  5948. static readonly ColorKind: string;
  5949. /**
  5950. * Matrix indices (for bones)
  5951. */
  5952. static readonly MatricesIndicesKind: string;
  5953. /**
  5954. * Matrix weights (for bones)
  5955. */
  5956. static readonly MatricesWeightsKind: string;
  5957. /**
  5958. * Additional matrix indices (for bones)
  5959. */
  5960. static readonly MatricesIndicesExtraKind: string;
  5961. /**
  5962. * Additional matrix weights (for bones)
  5963. */
  5964. static readonly MatricesWeightsExtraKind: string;
  5965. /**
  5966. * Deduces the stride given a kind.
  5967. * @param kind The kind string to deduce
  5968. * @returns The deduced stride
  5969. */
  5970. static DeduceStride(kind: string): number;
  5971. /**
  5972. * Gets the byte length of the given type.
  5973. * @param type the type
  5974. * @returns the number of bytes
  5975. */
  5976. static GetTypeByteLength(type: number): number;
  5977. /**
  5978. * Enumerates each value of the given parameters as numbers.
  5979. * @param data the data to enumerate
  5980. * @param byteOffset the byte offset of the data
  5981. * @param byteStride the byte stride of the data
  5982. * @param componentCount the number of components per element
  5983. * @param componentType the type of the component
  5984. * @param count the number of values to enumerate
  5985. * @param normalized whether the data is normalized
  5986. * @param callback the callback function called for each value
  5987. */
  5988. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5989. private static _GetFloatValue;
  5990. }
  5991. }
  5992. declare module "babylonjs/Maths/sphericalPolynomial" {
  5993. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5994. /**
  5995. * Class representing spherical harmonics coefficients to the 3rd degree
  5996. */
  5997. export class SphericalHarmonics {
  5998. /**
  5999. * Defines whether or not the harmonics have been prescaled for rendering.
  6000. */
  6001. preScaled: boolean;
  6002. /**
  6003. * The l0,0 coefficients of the spherical harmonics
  6004. */
  6005. l00: Vector3;
  6006. /**
  6007. * The l1,-1 coefficients of the spherical harmonics
  6008. */
  6009. l1_1: Vector3;
  6010. /**
  6011. * The l1,0 coefficients of the spherical harmonics
  6012. */
  6013. l10: Vector3;
  6014. /**
  6015. * The l1,1 coefficients of the spherical harmonics
  6016. */
  6017. l11: Vector3;
  6018. /**
  6019. * The l2,-2 coefficients of the spherical harmonics
  6020. */
  6021. l2_2: Vector3;
  6022. /**
  6023. * The l2,-1 coefficients of the spherical harmonics
  6024. */
  6025. l2_1: Vector3;
  6026. /**
  6027. * The l2,0 coefficients of the spherical harmonics
  6028. */
  6029. l20: Vector3;
  6030. /**
  6031. * The l2,1 coefficients of the spherical harmonics
  6032. */
  6033. l21: Vector3;
  6034. /**
  6035. * The l2,2 coefficients of the spherical harmonics
  6036. */
  6037. l22: Vector3;
  6038. /**
  6039. * Adds a light to the spherical harmonics
  6040. * @param direction the direction of the light
  6041. * @param color the color of the light
  6042. * @param deltaSolidAngle the delta solid angle of the light
  6043. */
  6044. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  6045. /**
  6046. * Scales the spherical harmonics by the given amount
  6047. * @param scale the amount to scale
  6048. */
  6049. scaleInPlace(scale: number): void;
  6050. /**
  6051. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  6052. *
  6053. * ```
  6054. * E_lm = A_l * L_lm
  6055. * ```
  6056. *
  6057. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  6058. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  6059. * the scaling factors are given in equation 9.
  6060. */
  6061. convertIncidentRadianceToIrradiance(): void;
  6062. /**
  6063. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  6064. *
  6065. * ```
  6066. * L = (1/pi) * E * rho
  6067. * ```
  6068. *
  6069. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  6070. */
  6071. convertIrradianceToLambertianRadiance(): void;
  6072. /**
  6073. * Integrates the reconstruction coefficients directly in to the SH preventing further
  6074. * required operations at run time.
  6075. *
  6076. * This is simply done by scaling back the SH with Ylm constants parameter.
  6077. * The trigonometric part being applied by the shader at run time.
  6078. */
  6079. preScaleForRendering(): void;
  6080. /**
  6081. * Constructs a spherical harmonics from an array.
  6082. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  6083. * @returns the spherical harmonics
  6084. */
  6085. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  6086. /**
  6087. * Gets the spherical harmonics from polynomial
  6088. * @param polynomial the spherical polynomial
  6089. * @returns the spherical harmonics
  6090. */
  6091. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  6092. }
  6093. /**
  6094. * Class representing spherical polynomial coefficients to the 3rd degree
  6095. */
  6096. export class SphericalPolynomial {
  6097. private _harmonics;
  6098. /**
  6099. * The spherical harmonics used to create the polynomials.
  6100. */
  6101. readonly preScaledHarmonics: SphericalHarmonics;
  6102. /**
  6103. * The x coefficients of the spherical polynomial
  6104. */
  6105. x: Vector3;
  6106. /**
  6107. * The y coefficients of the spherical polynomial
  6108. */
  6109. y: Vector3;
  6110. /**
  6111. * The z coefficients of the spherical polynomial
  6112. */
  6113. z: Vector3;
  6114. /**
  6115. * The xx coefficients of the spherical polynomial
  6116. */
  6117. xx: Vector3;
  6118. /**
  6119. * The yy coefficients of the spherical polynomial
  6120. */
  6121. yy: Vector3;
  6122. /**
  6123. * The zz coefficients of the spherical polynomial
  6124. */
  6125. zz: Vector3;
  6126. /**
  6127. * The xy coefficients of the spherical polynomial
  6128. */
  6129. xy: Vector3;
  6130. /**
  6131. * The yz coefficients of the spherical polynomial
  6132. */
  6133. yz: Vector3;
  6134. /**
  6135. * The zx coefficients of the spherical polynomial
  6136. */
  6137. zx: Vector3;
  6138. /**
  6139. * Adds an ambient color to the spherical polynomial
  6140. * @param color the color to add
  6141. */
  6142. addAmbient(color: Color3): void;
  6143. /**
  6144. * Scales the spherical polynomial by the given amount
  6145. * @param scale the amount to scale
  6146. */
  6147. scaleInPlace(scale: number): void;
  6148. /**
  6149. * Gets the spherical polynomial from harmonics
  6150. * @param harmonics the spherical harmonics
  6151. * @returns the spherical polynomial
  6152. */
  6153. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  6154. /**
  6155. * Constructs a spherical polynomial from an array.
  6156. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  6157. * @returns the spherical polynomial
  6158. */
  6159. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  6160. }
  6161. }
  6162. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  6163. import { Nullable } from "babylonjs/types";
  6164. /**
  6165. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  6166. */
  6167. export interface CubeMapInfo {
  6168. /**
  6169. * The pixel array for the front face.
  6170. * This is stored in format, left to right, up to down format.
  6171. */
  6172. front: Nullable<ArrayBufferView>;
  6173. /**
  6174. * The pixel array for the back face.
  6175. * This is stored in format, left to right, up to down format.
  6176. */
  6177. back: Nullable<ArrayBufferView>;
  6178. /**
  6179. * The pixel array for the left face.
  6180. * This is stored in format, left to right, up to down format.
  6181. */
  6182. left: Nullable<ArrayBufferView>;
  6183. /**
  6184. * The pixel array for the right face.
  6185. * This is stored in format, left to right, up to down format.
  6186. */
  6187. right: Nullable<ArrayBufferView>;
  6188. /**
  6189. * The pixel array for the up face.
  6190. * This is stored in format, left to right, up to down format.
  6191. */
  6192. up: Nullable<ArrayBufferView>;
  6193. /**
  6194. * The pixel array for the down face.
  6195. * This is stored in format, left to right, up to down format.
  6196. */
  6197. down: Nullable<ArrayBufferView>;
  6198. /**
  6199. * The size of the cubemap stored.
  6200. *
  6201. * Each faces will be size * size pixels.
  6202. */
  6203. size: number;
  6204. /**
  6205. * The format of the texture.
  6206. *
  6207. * RGBA, RGB.
  6208. */
  6209. format: number;
  6210. /**
  6211. * The type of the texture data.
  6212. *
  6213. * UNSIGNED_INT, FLOAT.
  6214. */
  6215. type: number;
  6216. /**
  6217. * Specifies whether the texture is in gamma space.
  6218. */
  6219. gammaSpace: boolean;
  6220. }
  6221. /**
  6222. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6223. */
  6224. export class PanoramaToCubeMapTools {
  6225. private static FACE_FRONT;
  6226. private static FACE_BACK;
  6227. private static FACE_RIGHT;
  6228. private static FACE_LEFT;
  6229. private static FACE_DOWN;
  6230. private static FACE_UP;
  6231. /**
  6232. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6233. *
  6234. * @param float32Array The source data.
  6235. * @param inputWidth The width of the input panorama.
  6236. * @param inputHeight The height of the input panorama.
  6237. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6238. * @return The cubemap data
  6239. */
  6240. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6241. private static CreateCubemapTexture;
  6242. private static CalcProjectionSpherical;
  6243. }
  6244. }
  6245. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  6246. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6247. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6248. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  6249. /**
  6250. * Helper class dealing with the extraction of spherical polynomial dataArray
  6251. * from a cube map.
  6252. */
  6253. export class CubeMapToSphericalPolynomialTools {
  6254. private static FileFaces;
  6255. /**
  6256. * Converts a texture to the according Spherical Polynomial data.
  6257. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6258. *
  6259. * @param texture The texture to extract the information from.
  6260. * @return The Spherical Polynomial data.
  6261. */
  6262. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6263. /**
  6264. * Converts a cubemap to the according Spherical Polynomial data.
  6265. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6266. *
  6267. * @param cubeInfo The Cube map to extract the information from.
  6268. * @return The Spherical Polynomial data.
  6269. */
  6270. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6271. }
  6272. }
  6273. declare module "babylonjs/Engines/engineStore" {
  6274. import { Nullable } from "babylonjs/types";
  6275. import { Engine } from "babylonjs/Engines/engine";
  6276. import { Scene } from "babylonjs/scene";
  6277. /**
  6278. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6279. * during the life time of the application.
  6280. */
  6281. export class EngineStore {
  6282. /** Gets the list of created engines */
  6283. static Instances: import("babylonjs/Engines/engine").Engine[];
  6284. /** @hidden */
  6285. static _LastCreatedScene: Nullable<Scene>;
  6286. /**
  6287. * Gets the latest created engine
  6288. */
  6289. static readonly LastCreatedEngine: Nullable<Engine>;
  6290. /**
  6291. * Gets the latest created scene
  6292. */
  6293. static readonly LastCreatedScene: Nullable<Scene>;
  6294. }
  6295. }
  6296. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6297. /**
  6298. * Define options used to create a render target texture
  6299. */
  6300. export class RenderTargetCreationOptions {
  6301. /**
  6302. * Specifies is mipmaps must be generated
  6303. */
  6304. generateMipMaps?: boolean;
  6305. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6306. generateDepthBuffer?: boolean;
  6307. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6308. generateStencilBuffer?: boolean;
  6309. /** Defines texture type (int by default) */
  6310. type?: number;
  6311. /** Defines sampling mode (trilinear by default) */
  6312. samplingMode?: number;
  6313. /** Defines format (RGBA by default) */
  6314. format?: number;
  6315. }
  6316. }
  6317. declare module "babylonjs/States/alphaCullingState" {
  6318. /**
  6319. * @hidden
  6320. **/
  6321. export class _AlphaState {
  6322. private _isAlphaBlendDirty;
  6323. private _isBlendFunctionParametersDirty;
  6324. private _isBlendEquationParametersDirty;
  6325. private _isBlendConstantsDirty;
  6326. private _alphaBlend;
  6327. private _blendFunctionParameters;
  6328. private _blendEquationParameters;
  6329. private _blendConstants;
  6330. /**
  6331. * Initializes the state.
  6332. */
  6333. constructor();
  6334. readonly isDirty: boolean;
  6335. alphaBlend: boolean;
  6336. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6337. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6338. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6339. reset(): void;
  6340. apply(gl: WebGLRenderingContext): void;
  6341. }
  6342. }
  6343. declare module "babylonjs/States/depthCullingState" {
  6344. import { Nullable } from "babylonjs/types";
  6345. /**
  6346. * @hidden
  6347. **/
  6348. export class _DepthCullingState {
  6349. private _isDepthTestDirty;
  6350. private _isDepthMaskDirty;
  6351. private _isDepthFuncDirty;
  6352. private _isCullFaceDirty;
  6353. private _isCullDirty;
  6354. private _isZOffsetDirty;
  6355. private _isFrontFaceDirty;
  6356. private _depthTest;
  6357. private _depthMask;
  6358. private _depthFunc;
  6359. private _cull;
  6360. private _cullFace;
  6361. private _zOffset;
  6362. private _frontFace;
  6363. /**
  6364. * Initializes the state.
  6365. */
  6366. constructor();
  6367. readonly isDirty: boolean;
  6368. zOffset: number;
  6369. cullFace: Nullable<number>;
  6370. cull: Nullable<boolean>;
  6371. depthFunc: Nullable<number>;
  6372. depthMask: boolean;
  6373. depthTest: boolean;
  6374. frontFace: Nullable<number>;
  6375. reset(): void;
  6376. apply(gl: WebGLRenderingContext): void;
  6377. }
  6378. }
  6379. declare module "babylonjs/States/stencilState" {
  6380. /**
  6381. * @hidden
  6382. **/
  6383. export class _StencilState {
  6384. /** 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 */
  6385. static readonly ALWAYS: number;
  6386. /** Passed to stencilOperation to specify that stencil value must be kept */
  6387. static readonly KEEP: number;
  6388. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6389. static readonly REPLACE: number;
  6390. private _isStencilTestDirty;
  6391. private _isStencilMaskDirty;
  6392. private _isStencilFuncDirty;
  6393. private _isStencilOpDirty;
  6394. private _stencilTest;
  6395. private _stencilMask;
  6396. private _stencilFunc;
  6397. private _stencilFuncRef;
  6398. private _stencilFuncMask;
  6399. private _stencilOpStencilFail;
  6400. private _stencilOpDepthFail;
  6401. private _stencilOpStencilDepthPass;
  6402. readonly isDirty: boolean;
  6403. stencilFunc: number;
  6404. stencilFuncRef: number;
  6405. stencilFuncMask: number;
  6406. stencilOpStencilFail: number;
  6407. stencilOpDepthFail: number;
  6408. stencilOpStencilDepthPass: number;
  6409. stencilMask: number;
  6410. stencilTest: boolean;
  6411. constructor();
  6412. reset(): void;
  6413. apply(gl: WebGLRenderingContext): void;
  6414. }
  6415. }
  6416. declare module "babylonjs/States/index" {
  6417. export * from "babylonjs/States/alphaCullingState";
  6418. export * from "babylonjs/States/depthCullingState";
  6419. export * from "babylonjs/States/stencilState";
  6420. }
  6421. declare module "babylonjs/Instrumentation/timeToken" {
  6422. import { Nullable } from "babylonjs/types";
  6423. /**
  6424. * @hidden
  6425. **/
  6426. export class _TimeToken {
  6427. _startTimeQuery: Nullable<WebGLQuery>;
  6428. _endTimeQuery: Nullable<WebGLQuery>;
  6429. _timeElapsedQuery: Nullable<WebGLQuery>;
  6430. _timeElapsedQueryEnded: boolean;
  6431. }
  6432. }
  6433. declare module "babylonjs/Materials/Textures/internalTexture" {
  6434. import { Observable } from "babylonjs/Misc/observable";
  6435. import { Nullable, int } from "babylonjs/types";
  6436. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6437. import { Engine } from "babylonjs/Engines/engine";
  6438. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6439. /**
  6440. * Class used to store data associated with WebGL texture data for the engine
  6441. * This class should not be used directly
  6442. */
  6443. export class InternalTexture {
  6444. /** @hidden */
  6445. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6446. /**
  6447. * The source of the texture data is unknown
  6448. */
  6449. static DATASOURCE_UNKNOWN: number;
  6450. /**
  6451. * Texture data comes from an URL
  6452. */
  6453. static DATASOURCE_URL: number;
  6454. /**
  6455. * Texture data is only used for temporary storage
  6456. */
  6457. static DATASOURCE_TEMP: number;
  6458. /**
  6459. * Texture data comes from raw data (ArrayBuffer)
  6460. */
  6461. static DATASOURCE_RAW: number;
  6462. /**
  6463. * Texture content is dynamic (video or dynamic texture)
  6464. */
  6465. static DATASOURCE_DYNAMIC: number;
  6466. /**
  6467. * Texture content is generated by rendering to it
  6468. */
  6469. static DATASOURCE_RENDERTARGET: number;
  6470. /**
  6471. * Texture content is part of a multi render target process
  6472. */
  6473. static DATASOURCE_MULTIRENDERTARGET: number;
  6474. /**
  6475. * Texture data comes from a cube data file
  6476. */
  6477. static DATASOURCE_CUBE: number;
  6478. /**
  6479. * Texture data comes from a raw cube data
  6480. */
  6481. static DATASOURCE_CUBERAW: number;
  6482. /**
  6483. * Texture data come from a prefiltered cube data file
  6484. */
  6485. static DATASOURCE_CUBEPREFILTERED: number;
  6486. /**
  6487. * Texture content is raw 3D data
  6488. */
  6489. static DATASOURCE_RAW3D: number;
  6490. /**
  6491. * Texture content is a depth texture
  6492. */
  6493. static DATASOURCE_DEPTHTEXTURE: number;
  6494. /**
  6495. * Texture data comes from a raw cube data encoded with RGBD
  6496. */
  6497. static DATASOURCE_CUBERAW_RGBD: number;
  6498. /**
  6499. * Defines if the texture is ready
  6500. */
  6501. isReady: boolean;
  6502. /**
  6503. * Defines if the texture is a cube texture
  6504. */
  6505. isCube: boolean;
  6506. /**
  6507. * Defines if the texture contains 3D data
  6508. */
  6509. is3D: boolean;
  6510. /**
  6511. * Defines if the texture contains multiview data
  6512. */
  6513. isMultiview: boolean;
  6514. /**
  6515. * Gets the URL used to load this texture
  6516. */
  6517. url: string;
  6518. /**
  6519. * Gets the sampling mode of the texture
  6520. */
  6521. samplingMode: number;
  6522. /**
  6523. * Gets a boolean indicating if the texture needs mipmaps generation
  6524. */
  6525. generateMipMaps: boolean;
  6526. /**
  6527. * Gets the number of samples used by the texture (WebGL2+ only)
  6528. */
  6529. samples: number;
  6530. /**
  6531. * Gets the type of the texture (int, float...)
  6532. */
  6533. type: number;
  6534. /**
  6535. * Gets the format of the texture (RGB, RGBA...)
  6536. */
  6537. format: number;
  6538. /**
  6539. * Observable called when the texture is loaded
  6540. */
  6541. onLoadedObservable: Observable<InternalTexture>;
  6542. /**
  6543. * Gets the width of the texture
  6544. */
  6545. width: number;
  6546. /**
  6547. * Gets the height of the texture
  6548. */
  6549. height: number;
  6550. /**
  6551. * Gets the depth of the texture
  6552. */
  6553. depth: number;
  6554. /**
  6555. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6556. */
  6557. baseWidth: number;
  6558. /**
  6559. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6560. */
  6561. baseHeight: number;
  6562. /**
  6563. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6564. */
  6565. baseDepth: number;
  6566. /**
  6567. * Gets a boolean indicating if the texture is inverted on Y axis
  6568. */
  6569. invertY: boolean;
  6570. /** @hidden */
  6571. _invertVScale: boolean;
  6572. /** @hidden */
  6573. _associatedChannel: number;
  6574. /** @hidden */
  6575. _dataSource: number;
  6576. /** @hidden */
  6577. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6578. /** @hidden */
  6579. _bufferView: Nullable<ArrayBufferView>;
  6580. /** @hidden */
  6581. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6582. /** @hidden */
  6583. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6584. /** @hidden */
  6585. _size: number;
  6586. /** @hidden */
  6587. _extension: string;
  6588. /** @hidden */
  6589. _files: Nullable<string[]>;
  6590. /** @hidden */
  6591. _workingCanvas: Nullable<HTMLCanvasElement>;
  6592. /** @hidden */
  6593. _workingContext: Nullable<CanvasRenderingContext2D>;
  6594. /** @hidden */
  6595. _framebuffer: Nullable<WebGLFramebuffer>;
  6596. /** @hidden */
  6597. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6598. /** @hidden */
  6599. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6600. /** @hidden */
  6601. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6602. /** @hidden */
  6603. _attachments: Nullable<number[]>;
  6604. /** @hidden */
  6605. _cachedCoordinatesMode: Nullable<number>;
  6606. /** @hidden */
  6607. _cachedWrapU: Nullable<number>;
  6608. /** @hidden */
  6609. _cachedWrapV: Nullable<number>;
  6610. /** @hidden */
  6611. _cachedWrapR: Nullable<number>;
  6612. /** @hidden */
  6613. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6614. /** @hidden */
  6615. _isDisabled: boolean;
  6616. /** @hidden */
  6617. _compression: Nullable<string>;
  6618. /** @hidden */
  6619. _generateStencilBuffer: boolean;
  6620. /** @hidden */
  6621. _generateDepthBuffer: boolean;
  6622. /** @hidden */
  6623. _comparisonFunction: number;
  6624. /** @hidden */
  6625. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6626. /** @hidden */
  6627. _lodGenerationScale: number;
  6628. /** @hidden */
  6629. _lodGenerationOffset: number;
  6630. /** @hidden */
  6631. _colorTextureArray: Nullable<WebGLTexture>;
  6632. /** @hidden */
  6633. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6634. /** @hidden */
  6635. _lodTextureHigh: Nullable<BaseTexture>;
  6636. /** @hidden */
  6637. _lodTextureMid: Nullable<BaseTexture>;
  6638. /** @hidden */
  6639. _lodTextureLow: Nullable<BaseTexture>;
  6640. /** @hidden */
  6641. _isRGBD: boolean;
  6642. /** @hidden */
  6643. _linearSpecularLOD: boolean;
  6644. /** @hidden */
  6645. _irradianceTexture: Nullable<BaseTexture>;
  6646. /** @hidden */
  6647. _webGLTexture: Nullable<WebGLTexture>;
  6648. /** @hidden */
  6649. _references: number;
  6650. private _engine;
  6651. /**
  6652. * Gets the Engine the texture belongs to.
  6653. * @returns The babylon engine
  6654. */
  6655. getEngine(): Engine;
  6656. /**
  6657. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6658. */
  6659. readonly dataSource: number;
  6660. /**
  6661. * Creates a new InternalTexture
  6662. * @param engine defines the engine to use
  6663. * @param dataSource defines the type of data that will be used
  6664. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6665. */
  6666. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6667. /**
  6668. * Increments the number of references (ie. the number of Texture that point to it)
  6669. */
  6670. incrementReferences(): void;
  6671. /**
  6672. * Change the size of the texture (not the size of the content)
  6673. * @param width defines the new width
  6674. * @param height defines the new height
  6675. * @param depth defines the new depth (1 by default)
  6676. */
  6677. updateSize(width: int, height: int, depth?: int): void;
  6678. /** @hidden */
  6679. _rebuild(): void;
  6680. /** @hidden */
  6681. _swapAndDie(target: InternalTexture): void;
  6682. /**
  6683. * Dispose the current allocated resources
  6684. */
  6685. dispose(): void;
  6686. }
  6687. }
  6688. declare module "babylonjs/Animations/easing" {
  6689. /**
  6690. * This represents the main contract an easing function should follow.
  6691. * Easing functions are used throughout the animation system.
  6692. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6693. */
  6694. export interface IEasingFunction {
  6695. /**
  6696. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6697. * of the easing function.
  6698. * The link below provides some of the most common examples of easing functions.
  6699. * @see https://easings.net/
  6700. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6701. * @returns the corresponding value on the curve defined by the easing function
  6702. */
  6703. ease(gradient: number): number;
  6704. }
  6705. /**
  6706. * Base class used for every default easing function.
  6707. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6708. */
  6709. export class EasingFunction implements IEasingFunction {
  6710. /**
  6711. * Interpolation follows the mathematical formula associated with the easing function.
  6712. */
  6713. static readonly EASINGMODE_EASEIN: number;
  6714. /**
  6715. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6716. */
  6717. static readonly EASINGMODE_EASEOUT: number;
  6718. /**
  6719. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6720. */
  6721. static readonly EASINGMODE_EASEINOUT: number;
  6722. private _easingMode;
  6723. /**
  6724. * Sets the easing mode of the current function.
  6725. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6726. */
  6727. setEasingMode(easingMode: number): void;
  6728. /**
  6729. * Gets the current easing mode.
  6730. * @returns the easing mode
  6731. */
  6732. getEasingMode(): number;
  6733. /**
  6734. * @hidden
  6735. */
  6736. easeInCore(gradient: number): number;
  6737. /**
  6738. * Given an input gradient between 0 and 1, this returns the corresponding value
  6739. * of the easing function.
  6740. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6741. * @returns the corresponding value on the curve defined by the easing function
  6742. */
  6743. ease(gradient: number): number;
  6744. }
  6745. /**
  6746. * Easing function with a circle shape (see link below).
  6747. * @see https://easings.net/#easeInCirc
  6748. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6749. */
  6750. export class CircleEase extends EasingFunction implements IEasingFunction {
  6751. /** @hidden */
  6752. easeInCore(gradient: number): number;
  6753. }
  6754. /**
  6755. * Easing function with a ease back shape (see link below).
  6756. * @see https://easings.net/#easeInBack
  6757. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6758. */
  6759. export class BackEase extends EasingFunction implements IEasingFunction {
  6760. /** Defines the amplitude of the function */
  6761. amplitude: number;
  6762. /**
  6763. * Instantiates a back ease easing
  6764. * @see https://easings.net/#easeInBack
  6765. * @param amplitude Defines the amplitude of the function
  6766. */
  6767. constructor(
  6768. /** Defines the amplitude of the function */
  6769. amplitude?: number);
  6770. /** @hidden */
  6771. easeInCore(gradient: number): number;
  6772. }
  6773. /**
  6774. * Easing function with a bouncing shape (see link below).
  6775. * @see https://easings.net/#easeInBounce
  6776. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6777. */
  6778. export class BounceEase extends EasingFunction implements IEasingFunction {
  6779. /** Defines the number of bounces */
  6780. bounces: number;
  6781. /** Defines the amplitude of the bounce */
  6782. bounciness: number;
  6783. /**
  6784. * Instantiates a bounce easing
  6785. * @see https://easings.net/#easeInBounce
  6786. * @param bounces Defines the number of bounces
  6787. * @param bounciness Defines the amplitude of the bounce
  6788. */
  6789. constructor(
  6790. /** Defines the number of bounces */
  6791. bounces?: number,
  6792. /** Defines the amplitude of the bounce */
  6793. bounciness?: number);
  6794. /** @hidden */
  6795. easeInCore(gradient: number): number;
  6796. }
  6797. /**
  6798. * Easing function with a power of 3 shape (see link below).
  6799. * @see https://easings.net/#easeInCubic
  6800. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6801. */
  6802. export class CubicEase extends EasingFunction implements IEasingFunction {
  6803. /** @hidden */
  6804. easeInCore(gradient: number): number;
  6805. }
  6806. /**
  6807. * Easing function with an elastic shape (see link below).
  6808. * @see https://easings.net/#easeInElastic
  6809. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6810. */
  6811. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6812. /** Defines the number of oscillations*/
  6813. oscillations: number;
  6814. /** Defines the amplitude of the oscillations*/
  6815. springiness: number;
  6816. /**
  6817. * Instantiates an elastic easing function
  6818. * @see https://easings.net/#easeInElastic
  6819. * @param oscillations Defines the number of oscillations
  6820. * @param springiness Defines the amplitude of the oscillations
  6821. */
  6822. constructor(
  6823. /** Defines the number of oscillations*/
  6824. oscillations?: number,
  6825. /** Defines the amplitude of the oscillations*/
  6826. springiness?: number);
  6827. /** @hidden */
  6828. easeInCore(gradient: number): number;
  6829. }
  6830. /**
  6831. * Easing function with an exponential shape (see link below).
  6832. * @see https://easings.net/#easeInExpo
  6833. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6834. */
  6835. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6836. /** Defines the exponent of the function */
  6837. exponent: number;
  6838. /**
  6839. * Instantiates an exponential easing function
  6840. * @see https://easings.net/#easeInExpo
  6841. * @param exponent Defines the exponent of the function
  6842. */
  6843. constructor(
  6844. /** Defines the exponent of the function */
  6845. exponent?: number);
  6846. /** @hidden */
  6847. easeInCore(gradient: number): number;
  6848. }
  6849. /**
  6850. * Easing function with a power shape (see link below).
  6851. * @see https://easings.net/#easeInQuad
  6852. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6853. */
  6854. export class PowerEase extends EasingFunction implements IEasingFunction {
  6855. /** Defines the power of the function */
  6856. power: number;
  6857. /**
  6858. * Instantiates an power base easing function
  6859. * @see https://easings.net/#easeInQuad
  6860. * @param power Defines the power of the function
  6861. */
  6862. constructor(
  6863. /** Defines the power of the function */
  6864. power?: number);
  6865. /** @hidden */
  6866. easeInCore(gradient: number): number;
  6867. }
  6868. /**
  6869. * Easing function with a power of 2 shape (see link below).
  6870. * @see https://easings.net/#easeInQuad
  6871. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6872. */
  6873. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6874. /** @hidden */
  6875. easeInCore(gradient: number): number;
  6876. }
  6877. /**
  6878. * Easing function with a power of 4 shape (see link below).
  6879. * @see https://easings.net/#easeInQuart
  6880. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6881. */
  6882. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6883. /** @hidden */
  6884. easeInCore(gradient: number): number;
  6885. }
  6886. /**
  6887. * Easing function with a power of 5 shape (see link below).
  6888. * @see https://easings.net/#easeInQuint
  6889. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6890. */
  6891. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6892. /** @hidden */
  6893. easeInCore(gradient: number): number;
  6894. }
  6895. /**
  6896. * Easing function with a sin shape (see link below).
  6897. * @see https://easings.net/#easeInSine
  6898. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6899. */
  6900. export class SineEase extends EasingFunction implements IEasingFunction {
  6901. /** @hidden */
  6902. easeInCore(gradient: number): number;
  6903. }
  6904. /**
  6905. * Easing function with a bezier shape (see link below).
  6906. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6907. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6908. */
  6909. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6910. /** Defines the x component of the start tangent in the bezier curve */
  6911. x1: number;
  6912. /** Defines the y component of the start tangent in the bezier curve */
  6913. y1: number;
  6914. /** Defines the x component of the end tangent in the bezier curve */
  6915. x2: number;
  6916. /** Defines the y component of the end tangent in the bezier curve */
  6917. y2: number;
  6918. /**
  6919. * Instantiates a bezier function
  6920. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6921. * @param x1 Defines the x component of the start tangent in the bezier curve
  6922. * @param y1 Defines the y component of the start tangent in the bezier curve
  6923. * @param x2 Defines the x component of the end tangent in the bezier curve
  6924. * @param y2 Defines the y component of the end tangent in the bezier curve
  6925. */
  6926. constructor(
  6927. /** Defines the x component of the start tangent in the bezier curve */
  6928. x1?: number,
  6929. /** Defines the y component of the start tangent in the bezier curve */
  6930. y1?: number,
  6931. /** Defines the x component of the end tangent in the bezier curve */
  6932. x2?: number,
  6933. /** Defines the y component of the end tangent in the bezier curve */
  6934. y2?: number);
  6935. /** @hidden */
  6936. easeInCore(gradient: number): number;
  6937. }
  6938. }
  6939. declare module "babylonjs/Animations/animationKey" {
  6940. /**
  6941. * Defines an interface which represents an animation key frame
  6942. */
  6943. export interface IAnimationKey {
  6944. /**
  6945. * Frame of the key frame
  6946. */
  6947. frame: number;
  6948. /**
  6949. * Value at the specifies key frame
  6950. */
  6951. value: any;
  6952. /**
  6953. * The input tangent for the cubic hermite spline
  6954. */
  6955. inTangent?: any;
  6956. /**
  6957. * The output tangent for the cubic hermite spline
  6958. */
  6959. outTangent?: any;
  6960. /**
  6961. * The animation interpolation type
  6962. */
  6963. interpolation?: AnimationKeyInterpolation;
  6964. }
  6965. /**
  6966. * Enum for the animation key frame interpolation type
  6967. */
  6968. export enum AnimationKeyInterpolation {
  6969. /**
  6970. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6971. */
  6972. STEP = 1
  6973. }
  6974. }
  6975. declare module "babylonjs/Animations/animationRange" {
  6976. /**
  6977. * Represents the range of an animation
  6978. */
  6979. export class AnimationRange {
  6980. /**The name of the animation range**/
  6981. name: string;
  6982. /**The starting frame of the animation */
  6983. from: number;
  6984. /**The ending frame of the animation*/
  6985. to: number;
  6986. /**
  6987. * Initializes the range of an animation
  6988. * @param name The name of the animation range
  6989. * @param from The starting frame of the animation
  6990. * @param to The ending frame of the animation
  6991. */
  6992. constructor(
  6993. /**The name of the animation range**/
  6994. name: string,
  6995. /**The starting frame of the animation */
  6996. from: number,
  6997. /**The ending frame of the animation*/
  6998. to: number);
  6999. /**
  7000. * Makes a copy of the animation range
  7001. * @returns A copy of the animation range
  7002. */
  7003. clone(): AnimationRange;
  7004. }
  7005. }
  7006. declare module "babylonjs/Animations/animationEvent" {
  7007. /**
  7008. * Composed of a frame, and an action function
  7009. */
  7010. export class AnimationEvent {
  7011. /** The frame for which the event is triggered **/
  7012. frame: number;
  7013. /** The event to perform when triggered **/
  7014. action: (currentFrame: number) => void;
  7015. /** Specifies if the event should be triggered only once**/
  7016. onlyOnce?: boolean | undefined;
  7017. /**
  7018. * Specifies if the animation event is done
  7019. */
  7020. isDone: boolean;
  7021. /**
  7022. * Initializes the animation event
  7023. * @param frame The frame for which the event is triggered
  7024. * @param action The event to perform when triggered
  7025. * @param onlyOnce Specifies if the event should be triggered only once
  7026. */
  7027. constructor(
  7028. /** The frame for which the event is triggered **/
  7029. frame: number,
  7030. /** The event to perform when triggered **/
  7031. action: (currentFrame: number) => void,
  7032. /** Specifies if the event should be triggered only once**/
  7033. onlyOnce?: boolean | undefined);
  7034. /** @hidden */
  7035. _clone(): AnimationEvent;
  7036. }
  7037. }
  7038. declare module "babylonjs/Behaviors/behavior" {
  7039. import { Nullable } from "babylonjs/types";
  7040. /**
  7041. * Interface used to define a behavior
  7042. */
  7043. export interface Behavior<T> {
  7044. /** gets or sets behavior's name */
  7045. name: string;
  7046. /**
  7047. * Function called when the behavior needs to be initialized (after attaching it to a target)
  7048. */
  7049. init(): void;
  7050. /**
  7051. * Called when the behavior is attached to a target
  7052. * @param target defines the target where the behavior is attached to
  7053. */
  7054. attach(target: T): void;
  7055. /**
  7056. * Called when the behavior is detached from its target
  7057. */
  7058. detach(): void;
  7059. }
  7060. /**
  7061. * Interface implemented by classes supporting behaviors
  7062. */
  7063. export interface IBehaviorAware<T> {
  7064. /**
  7065. * Attach a behavior
  7066. * @param behavior defines the behavior to attach
  7067. * @returns the current host
  7068. */
  7069. addBehavior(behavior: Behavior<T>): T;
  7070. /**
  7071. * Remove a behavior from the current object
  7072. * @param behavior defines the behavior to detach
  7073. * @returns the current host
  7074. */
  7075. removeBehavior(behavior: Behavior<T>): T;
  7076. /**
  7077. * Gets a behavior using its name to search
  7078. * @param name defines the name to search
  7079. * @returns the behavior or null if not found
  7080. */
  7081. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  7082. }
  7083. }
  7084. declare module "babylonjs/Collisions/intersectionInfo" {
  7085. import { Nullable } from "babylonjs/types";
  7086. /**
  7087. * @hidden
  7088. */
  7089. export class IntersectionInfo {
  7090. bu: Nullable<number>;
  7091. bv: Nullable<number>;
  7092. distance: number;
  7093. faceId: number;
  7094. subMeshId: number;
  7095. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7096. }
  7097. }
  7098. declare module "babylonjs/Culling/boundingSphere" {
  7099. import { DeepImmutable } from "babylonjs/types";
  7100. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7101. /**
  7102. * Class used to store bounding sphere information
  7103. */
  7104. export class BoundingSphere {
  7105. /**
  7106. * Gets the center of the bounding sphere in local space
  7107. */
  7108. readonly center: Vector3;
  7109. /**
  7110. * Radius of the bounding sphere in local space
  7111. */
  7112. radius: number;
  7113. /**
  7114. * Gets the center of the bounding sphere in world space
  7115. */
  7116. readonly centerWorld: Vector3;
  7117. /**
  7118. * Radius of the bounding sphere in world space
  7119. */
  7120. radiusWorld: number;
  7121. /**
  7122. * Gets the minimum vector in local space
  7123. */
  7124. readonly minimum: Vector3;
  7125. /**
  7126. * Gets the maximum vector in local space
  7127. */
  7128. readonly maximum: Vector3;
  7129. private _worldMatrix;
  7130. private static readonly TmpVector3;
  7131. /**
  7132. * Creates a new bounding sphere
  7133. * @param min defines the minimum vector (in local space)
  7134. * @param max defines the maximum vector (in local space)
  7135. * @param worldMatrix defines the new world matrix
  7136. */
  7137. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7138. /**
  7139. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7140. * @param min defines the new minimum vector (in local space)
  7141. * @param max defines the new maximum vector (in local space)
  7142. * @param worldMatrix defines the new world matrix
  7143. */
  7144. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7145. /**
  7146. * Scale the current bounding sphere by applying a scale factor
  7147. * @param factor defines the scale factor to apply
  7148. * @returns the current bounding box
  7149. */
  7150. scale(factor: number): BoundingSphere;
  7151. /**
  7152. * Gets the world matrix of the bounding box
  7153. * @returns a matrix
  7154. */
  7155. getWorldMatrix(): DeepImmutable<Matrix>;
  7156. /** @hidden */
  7157. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7158. /**
  7159. * Tests if the bounding sphere is intersecting the frustum planes
  7160. * @param frustumPlanes defines the frustum planes to test
  7161. * @returns true if there is an intersection
  7162. */
  7163. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7164. /**
  7165. * Tests if the bounding sphere center is in between the frustum planes.
  7166. * Used for optimistic fast inclusion.
  7167. * @param frustumPlanes defines the frustum planes to test
  7168. * @returns true if the sphere center is in between the frustum planes
  7169. */
  7170. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7171. /**
  7172. * Tests if a point is inside the bounding sphere
  7173. * @param point defines the point to test
  7174. * @returns true if the point is inside the bounding sphere
  7175. */
  7176. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7177. /**
  7178. * Checks if two sphere intersct
  7179. * @param sphere0 sphere 0
  7180. * @param sphere1 sphere 1
  7181. * @returns true if the speres intersect
  7182. */
  7183. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7184. }
  7185. }
  7186. declare module "babylonjs/Culling/boundingBox" {
  7187. import { DeepImmutable } from "babylonjs/types";
  7188. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7189. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7190. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7191. /**
  7192. * Class used to store bounding box information
  7193. */
  7194. export class BoundingBox implements ICullable {
  7195. /**
  7196. * Gets the 8 vectors representing the bounding box in local space
  7197. */
  7198. readonly vectors: Vector3[];
  7199. /**
  7200. * Gets the center of the bounding box in local space
  7201. */
  7202. readonly center: Vector3;
  7203. /**
  7204. * Gets the center of the bounding box in world space
  7205. */
  7206. readonly centerWorld: Vector3;
  7207. /**
  7208. * Gets the extend size in local space
  7209. */
  7210. readonly extendSize: Vector3;
  7211. /**
  7212. * Gets the extend size in world space
  7213. */
  7214. readonly extendSizeWorld: Vector3;
  7215. /**
  7216. * Gets the OBB (object bounding box) directions
  7217. */
  7218. readonly directions: Vector3[];
  7219. /**
  7220. * Gets the 8 vectors representing the bounding box in world space
  7221. */
  7222. readonly vectorsWorld: Vector3[];
  7223. /**
  7224. * Gets the minimum vector in world space
  7225. */
  7226. readonly minimumWorld: Vector3;
  7227. /**
  7228. * Gets the maximum vector in world space
  7229. */
  7230. readonly maximumWorld: Vector3;
  7231. /**
  7232. * Gets the minimum vector in local space
  7233. */
  7234. readonly minimum: Vector3;
  7235. /**
  7236. * Gets the maximum vector in local space
  7237. */
  7238. readonly maximum: Vector3;
  7239. private _worldMatrix;
  7240. private static readonly TmpVector3;
  7241. /**
  7242. * @hidden
  7243. */
  7244. _tag: number;
  7245. /**
  7246. * Creates a new bounding box
  7247. * @param min defines the minimum vector (in local space)
  7248. * @param max defines the maximum vector (in local space)
  7249. * @param worldMatrix defines the new world matrix
  7250. */
  7251. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7252. /**
  7253. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7254. * @param min defines the new minimum vector (in local space)
  7255. * @param max defines the new maximum vector (in local space)
  7256. * @param worldMatrix defines the new world matrix
  7257. */
  7258. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7259. /**
  7260. * Scale the current bounding box by applying a scale factor
  7261. * @param factor defines the scale factor to apply
  7262. * @returns the current bounding box
  7263. */
  7264. scale(factor: number): BoundingBox;
  7265. /**
  7266. * Gets the world matrix of the bounding box
  7267. * @returns a matrix
  7268. */
  7269. getWorldMatrix(): DeepImmutable<Matrix>;
  7270. /** @hidden */
  7271. _update(world: DeepImmutable<Matrix>): void;
  7272. /**
  7273. * Tests if the bounding box is intersecting the frustum planes
  7274. * @param frustumPlanes defines the frustum planes to test
  7275. * @returns true if there is an intersection
  7276. */
  7277. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7278. /**
  7279. * Tests if the bounding box is entirely inside the frustum planes
  7280. * @param frustumPlanes defines the frustum planes to test
  7281. * @returns true if there is an inclusion
  7282. */
  7283. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7284. /**
  7285. * Tests if a point is inside the bounding box
  7286. * @param point defines the point to test
  7287. * @returns true if the point is inside the bounding box
  7288. */
  7289. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7290. /**
  7291. * Tests if the bounding box intersects with a bounding sphere
  7292. * @param sphere defines the sphere to test
  7293. * @returns true if there is an intersection
  7294. */
  7295. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7296. /**
  7297. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7298. * @param min defines the min vector to use
  7299. * @param max defines the max vector to use
  7300. * @returns true if there is an intersection
  7301. */
  7302. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7303. /**
  7304. * Tests if two bounding boxes are intersections
  7305. * @param box0 defines the first box to test
  7306. * @param box1 defines the second box to test
  7307. * @returns true if there is an intersection
  7308. */
  7309. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7310. /**
  7311. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7312. * @param minPoint defines the minimum vector of the bounding box
  7313. * @param maxPoint defines the maximum vector of the bounding box
  7314. * @param sphereCenter defines the sphere center
  7315. * @param sphereRadius defines the sphere radius
  7316. * @returns true if there is an intersection
  7317. */
  7318. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7319. /**
  7320. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7321. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7322. * @param frustumPlanes defines the frustum planes to test
  7323. * @return true if there is an inclusion
  7324. */
  7325. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7326. /**
  7327. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7328. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7329. * @param frustumPlanes defines the frustum planes to test
  7330. * @return true if there is an intersection
  7331. */
  7332. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7333. }
  7334. }
  7335. declare module "babylonjs/Collisions/collider" {
  7336. import { Nullable, IndicesArray } from "babylonjs/types";
  7337. import { Vector3, Plane } from "babylonjs/Maths/math";
  7338. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7339. /** @hidden */
  7340. export class Collider {
  7341. /** Define if a collision was found */
  7342. collisionFound: boolean;
  7343. /**
  7344. * Define last intersection point in local space
  7345. */
  7346. intersectionPoint: Vector3;
  7347. /**
  7348. * Define last collided mesh
  7349. */
  7350. collidedMesh: Nullable<AbstractMesh>;
  7351. private _collisionPoint;
  7352. private _planeIntersectionPoint;
  7353. private _tempVector;
  7354. private _tempVector2;
  7355. private _tempVector3;
  7356. private _tempVector4;
  7357. private _edge;
  7358. private _baseToVertex;
  7359. private _destinationPoint;
  7360. private _slidePlaneNormal;
  7361. private _displacementVector;
  7362. /** @hidden */
  7363. _radius: Vector3;
  7364. /** @hidden */
  7365. _retry: number;
  7366. private _velocity;
  7367. private _basePoint;
  7368. private _epsilon;
  7369. /** @hidden */
  7370. _velocityWorldLength: number;
  7371. /** @hidden */
  7372. _basePointWorld: Vector3;
  7373. private _velocityWorld;
  7374. private _normalizedVelocity;
  7375. /** @hidden */
  7376. _initialVelocity: Vector3;
  7377. /** @hidden */
  7378. _initialPosition: Vector3;
  7379. private _nearestDistance;
  7380. private _collisionMask;
  7381. collisionMask: number;
  7382. /**
  7383. * Gets the plane normal used to compute the sliding response (in local space)
  7384. */
  7385. readonly slidePlaneNormal: Vector3;
  7386. /** @hidden */
  7387. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7388. /** @hidden */
  7389. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7390. /** @hidden */
  7391. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7392. /** @hidden */
  7393. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7394. /** @hidden */
  7395. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7396. /** @hidden */
  7397. _getResponse(pos: Vector3, vel: Vector3): void;
  7398. }
  7399. }
  7400. declare module "babylonjs/Culling/boundingInfo" {
  7401. import { DeepImmutable } from "babylonjs/types";
  7402. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7403. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7404. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7405. import { Collider } from "babylonjs/Collisions/collider";
  7406. /**
  7407. * Interface for cullable objects
  7408. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7409. */
  7410. export interface ICullable {
  7411. /**
  7412. * Checks if the object or part of the object is in the frustum
  7413. * @param frustumPlanes Camera near/planes
  7414. * @returns true if the object is in frustum otherwise false
  7415. */
  7416. isInFrustum(frustumPlanes: Plane[]): boolean;
  7417. /**
  7418. * Checks if a cullable object (mesh...) is in the camera frustum
  7419. * Unlike isInFrustum this cheks the full bounding box
  7420. * @param frustumPlanes Camera near/planes
  7421. * @returns true if the object is in frustum otherwise false
  7422. */
  7423. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7424. }
  7425. /**
  7426. * Info for a bounding data of a mesh
  7427. */
  7428. export class BoundingInfo implements ICullable {
  7429. /**
  7430. * Bounding box for the mesh
  7431. */
  7432. readonly boundingBox: BoundingBox;
  7433. /**
  7434. * Bounding sphere for the mesh
  7435. */
  7436. readonly boundingSphere: BoundingSphere;
  7437. private _isLocked;
  7438. private static readonly TmpVector3;
  7439. /**
  7440. * Constructs bounding info
  7441. * @param minimum min vector of the bounding box/sphere
  7442. * @param maximum max vector of the bounding box/sphere
  7443. * @param worldMatrix defines the new world matrix
  7444. */
  7445. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7446. /**
  7447. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7448. * @param min defines the new minimum vector (in local space)
  7449. * @param max defines the new maximum vector (in local space)
  7450. * @param worldMatrix defines the new world matrix
  7451. */
  7452. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7453. /**
  7454. * min vector of the bounding box/sphere
  7455. */
  7456. readonly minimum: Vector3;
  7457. /**
  7458. * max vector of the bounding box/sphere
  7459. */
  7460. readonly maximum: Vector3;
  7461. /**
  7462. * If the info is locked and won't be updated to avoid perf overhead
  7463. */
  7464. isLocked: boolean;
  7465. /**
  7466. * Updates the bounding sphere and box
  7467. * @param world world matrix to be used to update
  7468. */
  7469. update(world: DeepImmutable<Matrix>): void;
  7470. /**
  7471. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7472. * @param center New center of the bounding info
  7473. * @param extend New extend of the bounding info
  7474. * @returns the current bounding info
  7475. */
  7476. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7477. /**
  7478. * Scale the current bounding info by applying a scale factor
  7479. * @param factor defines the scale factor to apply
  7480. * @returns the current bounding info
  7481. */
  7482. scale(factor: number): BoundingInfo;
  7483. /**
  7484. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7485. * @param frustumPlanes defines the frustum to test
  7486. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7487. * @returns true if the bounding info is in the frustum planes
  7488. */
  7489. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7490. /**
  7491. * Gets the world distance between the min and max points of the bounding box
  7492. */
  7493. readonly diagonalLength: number;
  7494. /**
  7495. * Checks if a cullable object (mesh...) is in the camera frustum
  7496. * Unlike isInFrustum this cheks the full bounding box
  7497. * @param frustumPlanes Camera near/planes
  7498. * @returns true if the object is in frustum otherwise false
  7499. */
  7500. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7501. /** @hidden */
  7502. _checkCollision(collider: Collider): boolean;
  7503. /**
  7504. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7505. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7506. * @param point the point to check intersection with
  7507. * @returns if the point intersects
  7508. */
  7509. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7510. /**
  7511. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7512. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7513. * @param boundingInfo the bounding info to check intersection with
  7514. * @param precise if the intersection should be done using OBB
  7515. * @returns if the bounding info intersects
  7516. */
  7517. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7518. }
  7519. }
  7520. declare module "babylonjs/Misc/smartArray" {
  7521. /**
  7522. * Defines an array and its length.
  7523. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7524. */
  7525. export interface ISmartArrayLike<T> {
  7526. /**
  7527. * The data of the array.
  7528. */
  7529. data: Array<T>;
  7530. /**
  7531. * The active length of the array.
  7532. */
  7533. length: number;
  7534. }
  7535. /**
  7536. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7537. */
  7538. export class SmartArray<T> implements ISmartArrayLike<T> {
  7539. /**
  7540. * The full set of data from the array.
  7541. */
  7542. data: Array<T>;
  7543. /**
  7544. * The active length of the array.
  7545. */
  7546. length: number;
  7547. protected _id: number;
  7548. /**
  7549. * Instantiates a Smart Array.
  7550. * @param capacity defines the default capacity of the array.
  7551. */
  7552. constructor(capacity: number);
  7553. /**
  7554. * Pushes a value at the end of the active data.
  7555. * @param value defines the object to push in the array.
  7556. */
  7557. push(value: T): void;
  7558. /**
  7559. * Iterates over the active data and apply the lambda to them.
  7560. * @param func defines the action to apply on each value.
  7561. */
  7562. forEach(func: (content: T) => void): void;
  7563. /**
  7564. * Sorts the full sets of data.
  7565. * @param compareFn defines the comparison function to apply.
  7566. */
  7567. sort(compareFn: (a: T, b: T) => number): void;
  7568. /**
  7569. * Resets the active data to an empty array.
  7570. */
  7571. reset(): void;
  7572. /**
  7573. * Releases all the data from the array as well as the array.
  7574. */
  7575. dispose(): void;
  7576. /**
  7577. * Concats the active data with a given array.
  7578. * @param array defines the data to concatenate with.
  7579. */
  7580. concat(array: any): void;
  7581. /**
  7582. * Returns the position of a value in the active data.
  7583. * @param value defines the value to find the index for
  7584. * @returns the index if found in the active data otherwise -1
  7585. */
  7586. indexOf(value: T): number;
  7587. /**
  7588. * Returns whether an element is part of the active data.
  7589. * @param value defines the value to look for
  7590. * @returns true if found in the active data otherwise false
  7591. */
  7592. contains(value: T): boolean;
  7593. private static _GlobalId;
  7594. }
  7595. /**
  7596. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7597. * The data in this array can only be present once
  7598. */
  7599. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7600. private _duplicateId;
  7601. /**
  7602. * Pushes a value at the end of the active data.
  7603. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7604. * @param value defines the object to push in the array.
  7605. */
  7606. push(value: T): void;
  7607. /**
  7608. * Pushes a value at the end of the active data.
  7609. * If the data is already present, it won t be added again
  7610. * @param value defines the object to push in the array.
  7611. * @returns true if added false if it was already present
  7612. */
  7613. pushNoDuplicate(value: T): boolean;
  7614. /**
  7615. * Resets the active data to an empty array.
  7616. */
  7617. reset(): void;
  7618. /**
  7619. * Concats the active data with a given array.
  7620. * This ensures no dupplicate will be present in the result.
  7621. * @param array defines the data to concatenate with.
  7622. */
  7623. concatWithNoDuplicate(array: any): void;
  7624. }
  7625. }
  7626. declare module "babylonjs/Misc/iInspectable" {
  7627. /**
  7628. * Enum that determines the text-wrapping mode to use.
  7629. */
  7630. export enum InspectableType {
  7631. /**
  7632. * Checkbox for booleans
  7633. */
  7634. Checkbox = 0,
  7635. /**
  7636. * Sliders for numbers
  7637. */
  7638. Slider = 1,
  7639. /**
  7640. * Vector3
  7641. */
  7642. Vector3 = 2,
  7643. /**
  7644. * Quaternions
  7645. */
  7646. Quaternion = 3,
  7647. /**
  7648. * Color3
  7649. */
  7650. Color3 = 4
  7651. }
  7652. /**
  7653. * Interface used to define custom inspectable properties.
  7654. * This interface is used by the inspector to display custom property grids
  7655. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7656. */
  7657. export interface IInspectable {
  7658. /**
  7659. * Gets the label to display
  7660. */
  7661. label: string;
  7662. /**
  7663. * Gets the name of the property to edit
  7664. */
  7665. propertyName: string;
  7666. /**
  7667. * Gets the type of the editor to use
  7668. */
  7669. type: InspectableType;
  7670. /**
  7671. * Gets the minimum value of the property when using in "slider" mode
  7672. */
  7673. min?: number;
  7674. /**
  7675. * Gets the maximum value of the property when using in "slider" mode
  7676. */
  7677. max?: number;
  7678. /**
  7679. * Gets the setp to use when using in "slider" mode
  7680. */
  7681. step?: number;
  7682. }
  7683. }
  7684. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  7685. import { Nullable } from "babylonjs/types";
  7686. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7687. /**
  7688. * This represents the required contract to create a new type of texture loader.
  7689. */
  7690. export interface IInternalTextureLoader {
  7691. /**
  7692. * Defines wether the loader supports cascade loading the different faces.
  7693. */
  7694. supportCascades: boolean;
  7695. /**
  7696. * This returns if the loader support the current file information.
  7697. * @param extension defines the file extension of the file being loaded
  7698. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7699. * @param fallback defines the fallback internal texture if any
  7700. * @param isBase64 defines whether the texture is encoded as a base64
  7701. * @param isBuffer defines whether the texture data are stored as a buffer
  7702. * @returns true if the loader can load the specified file
  7703. */
  7704. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7705. /**
  7706. * Transform the url before loading if required.
  7707. * @param rootUrl the url of the texture
  7708. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7709. * @returns the transformed texture
  7710. */
  7711. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7712. /**
  7713. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7714. * @param rootUrl the url of the texture
  7715. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7716. * @returns the fallback texture
  7717. */
  7718. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7719. /**
  7720. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7721. * @param data contains the texture data
  7722. * @param texture defines the BabylonJS internal texture
  7723. * @param createPolynomials will be true if polynomials have been requested
  7724. * @param onLoad defines the callback to trigger once the texture is ready
  7725. * @param onError defines the callback to trigger in case of error
  7726. */
  7727. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7728. /**
  7729. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7730. * @param data contains the texture data
  7731. * @param texture defines the BabylonJS internal texture
  7732. * @param callback defines the method to call once ready to upload
  7733. */
  7734. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7735. }
  7736. }
  7737. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7738. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7739. import { Nullable } from "babylonjs/types";
  7740. import { Scene } from "babylonjs/scene";
  7741. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7742. module "babylonjs/Engines/engine" {
  7743. interface Engine {
  7744. /**
  7745. * Creates a depth stencil cube texture.
  7746. * This is only available in WebGL 2.
  7747. * @param size The size of face edge in the cube texture.
  7748. * @param options The options defining the cube texture.
  7749. * @returns The cube texture
  7750. */
  7751. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7752. /**
  7753. * Creates a cube texture
  7754. * @param rootUrl defines the url where the files to load is located
  7755. * @param scene defines the current scene
  7756. * @param files defines the list of files to load (1 per face)
  7757. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7758. * @param onLoad defines an optional callback raised when the texture is loaded
  7759. * @param onError defines an optional callback raised if there is an issue to load the texture
  7760. * @param format defines the format of the data
  7761. * @param forcedExtension defines the extension to use to pick the right loader
  7762. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7763. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7764. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7765. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7766. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7767. * @returns the cube texture as an InternalTexture
  7768. */
  7769. 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;
  7770. /**
  7771. * Creates a cube texture
  7772. * @param rootUrl defines the url where the files to load is located
  7773. * @param scene defines the current scene
  7774. * @param files defines the list of files to load (1 per face)
  7775. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7776. * @param onLoad defines an optional callback raised when the texture is loaded
  7777. * @param onError defines an optional callback raised if there is an issue to load the texture
  7778. * @param format defines the format of the data
  7779. * @param forcedExtension defines the extension to use to pick the right loader
  7780. * @returns the cube texture as an InternalTexture
  7781. */
  7782. 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;
  7783. /**
  7784. * Creates a cube texture
  7785. * @param rootUrl defines the url where the files to load is located
  7786. * @param scene defines the current scene
  7787. * @param files defines the list of files to load (1 per face)
  7788. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7789. * @param onLoad defines an optional callback raised when the texture is loaded
  7790. * @param onError defines an optional callback raised if there is an issue to load the texture
  7791. * @param format defines the format of the data
  7792. * @param forcedExtension defines the extension to use to pick the right loader
  7793. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7794. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7795. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7796. * @returns the cube texture as an InternalTexture
  7797. */
  7798. 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;
  7799. /** @hidden */
  7800. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7801. /** @hidden */
  7802. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7803. /** @hidden */
  7804. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7805. /** @hidden */
  7806. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7807. }
  7808. }
  7809. }
  7810. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7811. import { Nullable } from "babylonjs/types";
  7812. import { Scene } from "babylonjs/scene";
  7813. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  7814. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7815. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7816. /**
  7817. * Class for creating a cube texture
  7818. */
  7819. export class CubeTexture extends BaseTexture {
  7820. private _delayedOnLoad;
  7821. /**
  7822. * The url of the texture
  7823. */
  7824. url: string;
  7825. /**
  7826. * Gets or sets the center of the bounding box associated with the cube texture.
  7827. * It must define where the camera used to render the texture was set
  7828. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7829. */
  7830. boundingBoxPosition: Vector3;
  7831. private _boundingBoxSize;
  7832. /**
  7833. * Gets or sets the size of the bounding box associated with the cube texture
  7834. * When defined, the cubemap will switch to local mode
  7835. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7836. * @example https://www.babylonjs-playground.com/#RNASML
  7837. */
  7838. /**
  7839. * Returns the bounding box size
  7840. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7841. */
  7842. boundingBoxSize: Vector3;
  7843. protected _rotationY: number;
  7844. /**
  7845. * Sets texture matrix rotation angle around Y axis in radians.
  7846. */
  7847. /**
  7848. * Gets texture matrix rotation angle around Y axis radians.
  7849. */
  7850. rotationY: number;
  7851. /**
  7852. * Are mip maps generated for this texture or not.
  7853. */
  7854. readonly noMipmap: boolean;
  7855. private _noMipmap;
  7856. private _files;
  7857. private _extensions;
  7858. private _textureMatrix;
  7859. private _format;
  7860. private _createPolynomials;
  7861. /** @hidden */
  7862. _prefiltered: boolean;
  7863. /**
  7864. * Creates a cube texture from an array of image urls
  7865. * @param files defines an array of image urls
  7866. * @param scene defines the hosting scene
  7867. * @param noMipmap specifies if mip maps are not used
  7868. * @returns a cube texture
  7869. */
  7870. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7871. /**
  7872. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7873. * @param url defines the url of the prefiltered texture
  7874. * @param scene defines the scene the texture is attached to
  7875. * @param forcedExtension defines the extension of the file if different from the url
  7876. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7877. * @return the prefiltered texture
  7878. */
  7879. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7880. /**
  7881. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7882. * as prefiltered data.
  7883. * @param rootUrl defines the url of the texture or the root name of the six images
  7884. * @param scene defines the scene the texture is attached to
  7885. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7886. * @param noMipmap defines if mipmaps should be created or not
  7887. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7888. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7889. * @param onError defines a callback triggered in case of error during load
  7890. * @param format defines the internal format to use for the texture once loaded
  7891. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7892. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7893. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7894. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7895. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7896. * @return the cube texture
  7897. */
  7898. 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);
  7899. /**
  7900. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7901. */
  7902. readonly isPrefiltered: boolean;
  7903. /**
  7904. * Get the current class name of the texture useful for serialization or dynamic coding.
  7905. * @returns "CubeTexture"
  7906. */
  7907. getClassName(): string;
  7908. /**
  7909. * Update the url (and optional buffer) of this texture if url was null during construction.
  7910. * @param url the url of the texture
  7911. * @param forcedExtension defines the extension to use
  7912. * @param onLoad callback called when the texture is loaded (defaults to null)
  7913. */
  7914. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7915. /**
  7916. * Delays loading of the cube texture
  7917. * @param forcedExtension defines the extension to use
  7918. */
  7919. delayLoad(forcedExtension?: string): void;
  7920. /**
  7921. * Returns the reflection texture matrix
  7922. * @returns the reflection texture matrix
  7923. */
  7924. getReflectionTextureMatrix(): Matrix;
  7925. /**
  7926. * Sets the reflection texture matrix
  7927. * @param value Reflection texture matrix
  7928. */
  7929. setReflectionTextureMatrix(value: Matrix): void;
  7930. /**
  7931. * Parses text to create a cube texture
  7932. * @param parsedTexture define the serialized text to read from
  7933. * @param scene defines the hosting scene
  7934. * @param rootUrl defines the root url of the cube texture
  7935. * @returns a cube texture
  7936. */
  7937. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7938. /**
  7939. * Makes a clone, or deep copy, of the cube texture
  7940. * @returns a new cube texture
  7941. */
  7942. clone(): CubeTexture;
  7943. }
  7944. }
  7945. declare module "babylonjs/Shaders/postprocess.vertex" {
  7946. /** @hidden */
  7947. export var postprocessVertexShader: {
  7948. name: string;
  7949. shader: string;
  7950. };
  7951. }
  7952. declare module "babylonjs/Cameras/targetCamera" {
  7953. import { Nullable } from "babylonjs/types";
  7954. import { Camera } from "babylonjs/Cameras/camera";
  7955. import { Scene } from "babylonjs/scene";
  7956. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  7957. /**
  7958. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  7959. * This is the base of the follow, arc rotate cameras and Free camera
  7960. * @see http://doc.babylonjs.com/features/cameras
  7961. */
  7962. export class TargetCamera extends Camera {
  7963. private static _RigCamTransformMatrix;
  7964. private static _TargetTransformMatrix;
  7965. private static _TargetFocalPoint;
  7966. /**
  7967. * Define the current direction the camera is moving to
  7968. */
  7969. cameraDirection: Vector3;
  7970. /**
  7971. * Define the current rotation the camera is rotating to
  7972. */
  7973. cameraRotation: Vector2;
  7974. /**
  7975. * When set, the up vector of the camera will be updated by the rotation of the camera
  7976. */
  7977. updateUpVectorFromRotation: boolean;
  7978. private _tmpQuaternion;
  7979. /**
  7980. * Define the current rotation of the camera
  7981. */
  7982. rotation: Vector3;
  7983. /**
  7984. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  7985. */
  7986. rotationQuaternion: Quaternion;
  7987. /**
  7988. * Define the current speed of the camera
  7989. */
  7990. speed: number;
  7991. /**
  7992. * Add cconstraint to the camera to prevent it to move freely in all directions and
  7993. * around all axis.
  7994. */
  7995. noRotationConstraint: boolean;
  7996. /**
  7997. * Define the current target of the camera as an object or a position.
  7998. */
  7999. lockedTarget: any;
  8000. /** @hidden */
  8001. _currentTarget: Vector3;
  8002. /** @hidden */
  8003. _initialFocalDistance: number;
  8004. /** @hidden */
  8005. _viewMatrix: Matrix;
  8006. /** @hidden */
  8007. _camMatrix: Matrix;
  8008. /** @hidden */
  8009. _cameraTransformMatrix: Matrix;
  8010. /** @hidden */
  8011. _cameraRotationMatrix: Matrix;
  8012. /** @hidden */
  8013. _referencePoint: Vector3;
  8014. /** @hidden */
  8015. _transformedReferencePoint: Vector3;
  8016. protected _globalCurrentTarget: Vector3;
  8017. protected _globalCurrentUpVector: Vector3;
  8018. /** @hidden */
  8019. _reset: () => void;
  8020. private _defaultUp;
  8021. /**
  8022. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8023. * This is the base of the follow, arc rotate cameras and Free camera
  8024. * @see http://doc.babylonjs.com/features/cameras
  8025. * @param name Defines the name of the camera in the scene
  8026. * @param position Defines the start position of the camera in the scene
  8027. * @param scene Defines the scene the camera belongs to
  8028. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8029. */
  8030. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8031. /**
  8032. * Gets the position in front of the camera at a given distance.
  8033. * @param distance The distance from the camera we want the position to be
  8034. * @returns the position
  8035. */
  8036. getFrontPosition(distance: number): Vector3;
  8037. /** @hidden */
  8038. _getLockedTargetPosition(): Nullable<Vector3>;
  8039. private _storedPosition;
  8040. private _storedRotation;
  8041. private _storedRotationQuaternion;
  8042. /**
  8043. * Store current camera state of the camera (fov, position, rotation, etc..)
  8044. * @returns the camera
  8045. */
  8046. storeState(): Camera;
  8047. /**
  8048. * Restored camera state. You must call storeState() first
  8049. * @returns whether it was successful or not
  8050. * @hidden
  8051. */
  8052. _restoreStateValues(): boolean;
  8053. /** @hidden */
  8054. _initCache(): void;
  8055. /** @hidden */
  8056. _updateCache(ignoreParentClass?: boolean): void;
  8057. /** @hidden */
  8058. _isSynchronizedViewMatrix(): boolean;
  8059. /** @hidden */
  8060. _computeLocalCameraSpeed(): number;
  8061. /**
  8062. * Defines the target the camera should look at.
  8063. * @param target Defines the new target as a Vector or a mesh
  8064. */
  8065. setTarget(target: Vector3): void;
  8066. /**
  8067. * Return the current target position of the camera. This value is expressed in local space.
  8068. * @returns the target position
  8069. */
  8070. getTarget(): Vector3;
  8071. /** @hidden */
  8072. _decideIfNeedsToMove(): boolean;
  8073. /** @hidden */
  8074. _updatePosition(): void;
  8075. /** @hidden */
  8076. _checkInputs(): void;
  8077. protected _updateCameraRotationMatrix(): void;
  8078. /**
  8079. * 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)
  8080. * @returns the current camera
  8081. */
  8082. private _rotateUpVectorWithCameraRotationMatrix;
  8083. private _cachedRotationZ;
  8084. private _cachedQuaternionRotationZ;
  8085. /** @hidden */
  8086. _getViewMatrix(): Matrix;
  8087. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8088. /**
  8089. * @hidden
  8090. */
  8091. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8092. /**
  8093. * @hidden
  8094. */
  8095. _updateRigCameras(): void;
  8096. private _getRigCamPositionAndTarget;
  8097. /**
  8098. * Gets the current object class name.
  8099. * @return the class name
  8100. */
  8101. getClassName(): string;
  8102. }
  8103. }
  8104. declare module "babylonjs/Cameras/cameraInputsManager" {
  8105. import { Nullable } from "babylonjs/types";
  8106. import { Camera } from "babylonjs/Cameras/camera";
  8107. /**
  8108. * @ignore
  8109. * This is a list of all the different input types that are available in the application.
  8110. * Fo instance: ArcRotateCameraGamepadInput...
  8111. */
  8112. export var CameraInputTypes: {};
  8113. /**
  8114. * This is the contract to implement in order to create a new input class.
  8115. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8116. */
  8117. export interface ICameraInput<TCamera extends Camera> {
  8118. /**
  8119. * Defines the camera the input is attached to.
  8120. */
  8121. camera: Nullable<TCamera>;
  8122. /**
  8123. * Gets the class name of the current intput.
  8124. * @returns the class name
  8125. */
  8126. getClassName(): string;
  8127. /**
  8128. * Get the friendly name associated with the input class.
  8129. * @returns the input friendly name
  8130. */
  8131. getSimpleName(): string;
  8132. /**
  8133. * Attach the input controls to a specific dom element to get the input from.
  8134. * @param element Defines the element the controls should be listened from
  8135. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8136. */
  8137. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8138. /**
  8139. * Detach the current controls from the specified dom element.
  8140. * @param element Defines the element to stop listening the inputs from
  8141. */
  8142. detachControl(element: Nullable<HTMLElement>): void;
  8143. /**
  8144. * Update the current camera state depending on the inputs that have been used this frame.
  8145. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8146. */
  8147. checkInputs?: () => void;
  8148. }
  8149. /**
  8150. * Represents a map of input types to input instance or input index to input instance.
  8151. */
  8152. export interface CameraInputsMap<TCamera extends Camera> {
  8153. /**
  8154. * Accessor to the input by input type.
  8155. */
  8156. [name: string]: ICameraInput<TCamera>;
  8157. /**
  8158. * Accessor to the input by input index.
  8159. */
  8160. [idx: number]: ICameraInput<TCamera>;
  8161. }
  8162. /**
  8163. * This represents the input manager used within a camera.
  8164. * It helps dealing with all the different kind of input attached to a camera.
  8165. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8166. */
  8167. export class CameraInputsManager<TCamera extends Camera> {
  8168. /**
  8169. * Defines the list of inputs attahed to the camera.
  8170. */
  8171. attached: CameraInputsMap<TCamera>;
  8172. /**
  8173. * Defines the dom element the camera is collecting inputs from.
  8174. * This is null if the controls have not been attached.
  8175. */
  8176. attachedElement: Nullable<HTMLElement>;
  8177. /**
  8178. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8179. */
  8180. noPreventDefault: boolean;
  8181. /**
  8182. * Defined the camera the input manager belongs to.
  8183. */
  8184. camera: TCamera;
  8185. /**
  8186. * Update the current camera state depending on the inputs that have been used this frame.
  8187. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8188. */
  8189. checkInputs: () => void;
  8190. /**
  8191. * Instantiate a new Camera Input Manager.
  8192. * @param camera Defines the camera the input manager blongs to
  8193. */
  8194. constructor(camera: TCamera);
  8195. /**
  8196. * Add an input method to a camera
  8197. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8198. * @param input camera input method
  8199. */
  8200. add(input: ICameraInput<TCamera>): void;
  8201. /**
  8202. * Remove a specific input method from a camera
  8203. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8204. * @param inputToRemove camera input method
  8205. */
  8206. remove(inputToRemove: ICameraInput<TCamera>): void;
  8207. /**
  8208. * Remove a specific input type from a camera
  8209. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8210. * @param inputType the type of the input to remove
  8211. */
  8212. removeByType(inputType: string): void;
  8213. private _addCheckInputs;
  8214. /**
  8215. * Attach the input controls to the currently attached dom element to listen the events from.
  8216. * @param input Defines the input to attach
  8217. */
  8218. attachInput(input: ICameraInput<TCamera>): void;
  8219. /**
  8220. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8221. * @param element Defines the dom element to collect the events from
  8222. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8223. */
  8224. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8225. /**
  8226. * Detach the current manager inputs controls from a specific dom element.
  8227. * @param element Defines the dom element to collect the events from
  8228. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8229. */
  8230. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8231. /**
  8232. * Rebuild the dynamic inputCheck function from the current list of
  8233. * defined inputs in the manager.
  8234. */
  8235. rebuildInputCheck(): void;
  8236. /**
  8237. * Remove all attached input methods from a camera
  8238. */
  8239. clear(): void;
  8240. /**
  8241. * Serialize the current input manager attached to a camera.
  8242. * This ensures than once parsed,
  8243. * the input associated to the camera will be identical to the current ones
  8244. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8245. */
  8246. serialize(serializedCamera: any): void;
  8247. /**
  8248. * Parses an input manager serialized JSON to restore the previous list of inputs
  8249. * and states associated to a camera.
  8250. * @param parsedCamera Defines the JSON to parse
  8251. */
  8252. parse(parsedCamera: any): void;
  8253. }
  8254. }
  8255. declare module "babylonjs/Events/keyboardEvents" {
  8256. /**
  8257. * Gather the list of keyboard event types as constants.
  8258. */
  8259. export class KeyboardEventTypes {
  8260. /**
  8261. * The keydown event is fired when a key becomes active (pressed).
  8262. */
  8263. static readonly KEYDOWN: number;
  8264. /**
  8265. * The keyup event is fired when a key has been released.
  8266. */
  8267. static readonly KEYUP: number;
  8268. }
  8269. /**
  8270. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8271. */
  8272. export class KeyboardInfo {
  8273. /**
  8274. * Defines the type of event (KeyboardEventTypes)
  8275. */
  8276. type: number;
  8277. /**
  8278. * Defines the related dom event
  8279. */
  8280. event: KeyboardEvent;
  8281. /**
  8282. * Instantiates a new keyboard info.
  8283. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8284. * @param type Defines the type of event (KeyboardEventTypes)
  8285. * @param event Defines the related dom event
  8286. */
  8287. constructor(
  8288. /**
  8289. * Defines the type of event (KeyboardEventTypes)
  8290. */
  8291. type: number,
  8292. /**
  8293. * Defines the related dom event
  8294. */
  8295. event: KeyboardEvent);
  8296. }
  8297. /**
  8298. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8299. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8300. */
  8301. export class KeyboardInfoPre extends KeyboardInfo {
  8302. /**
  8303. * Defines the type of event (KeyboardEventTypes)
  8304. */
  8305. type: number;
  8306. /**
  8307. * Defines the related dom event
  8308. */
  8309. event: KeyboardEvent;
  8310. /**
  8311. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8312. */
  8313. skipOnPointerObservable: boolean;
  8314. /**
  8315. * Instantiates a new keyboard pre info.
  8316. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8317. * @param type Defines the type of event (KeyboardEventTypes)
  8318. * @param event Defines the related dom event
  8319. */
  8320. constructor(
  8321. /**
  8322. * Defines the type of event (KeyboardEventTypes)
  8323. */
  8324. type: number,
  8325. /**
  8326. * Defines the related dom event
  8327. */
  8328. event: KeyboardEvent);
  8329. }
  8330. }
  8331. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8332. import { Nullable } from "babylonjs/types";
  8333. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8334. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8335. /**
  8336. * Manage the keyboard inputs to control the movement of a free camera.
  8337. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8338. */
  8339. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8340. /**
  8341. * Defines the camera the input is attached to.
  8342. */
  8343. camera: FreeCamera;
  8344. /**
  8345. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8346. */
  8347. keysUp: number[];
  8348. /**
  8349. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8350. */
  8351. keysDown: number[];
  8352. /**
  8353. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8354. */
  8355. keysLeft: number[];
  8356. /**
  8357. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8358. */
  8359. keysRight: number[];
  8360. private _keys;
  8361. private _onCanvasBlurObserver;
  8362. private _onKeyboardObserver;
  8363. private _engine;
  8364. private _scene;
  8365. /**
  8366. * Attach the input controls to a specific dom element to get the input from.
  8367. * @param element Defines the element the controls should be listened from
  8368. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8369. */
  8370. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8371. /**
  8372. * Detach the current controls from the specified dom element.
  8373. * @param element Defines the element to stop listening the inputs from
  8374. */
  8375. detachControl(element: Nullable<HTMLElement>): void;
  8376. /**
  8377. * Update the current camera state depending on the inputs that have been used this frame.
  8378. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8379. */
  8380. checkInputs(): void;
  8381. /**
  8382. * Gets the class name of the current intput.
  8383. * @returns the class name
  8384. */
  8385. getClassName(): string;
  8386. /** @hidden */
  8387. _onLostFocus(): void;
  8388. /**
  8389. * Get the friendly name associated with the input class.
  8390. * @returns the input friendly name
  8391. */
  8392. getSimpleName(): string;
  8393. }
  8394. }
  8395. declare module "babylonjs/Materials/multiMaterial" {
  8396. import { Nullable } from "babylonjs/types";
  8397. import { Scene } from "babylonjs/scene";
  8398. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8399. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  8400. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8401. import { Material } from "babylonjs/Materials/material";
  8402. /**
  8403. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8404. * separate meshes. This can be use to improve performances.
  8405. * @see http://doc.babylonjs.com/how_to/multi_materials
  8406. */
  8407. export class MultiMaterial extends Material {
  8408. private _subMaterials;
  8409. /**
  8410. * Gets or Sets the list of Materials used within the multi material.
  8411. * They need to be ordered according to the submeshes order in the associated mesh
  8412. */
  8413. subMaterials: Nullable<Material>[];
  8414. /**
  8415. * Function used to align with Node.getChildren()
  8416. * @returns the list of Materials used within the multi material
  8417. */
  8418. getChildren(): Nullable<Material>[];
  8419. /**
  8420. * Instantiates a new Multi Material
  8421. * A multi-material is used to apply different materials to different parts of the same object without the need of
  8422. * separate meshes. This can be use to improve performances.
  8423. * @see http://doc.babylonjs.com/how_to/multi_materials
  8424. * @param name Define the name in the scene
  8425. * @param scene Define the scene the material belongs to
  8426. */
  8427. constructor(name: string, scene: Scene);
  8428. private _hookArray;
  8429. /**
  8430. * Get one of the submaterial by its index in the submaterials array
  8431. * @param index The index to look the sub material at
  8432. * @returns The Material if the index has been defined
  8433. */
  8434. getSubMaterial(index: number): Nullable<Material>;
  8435. /**
  8436. * Get the list of active textures for the whole sub materials list.
  8437. * @returns All the textures that will be used during the rendering
  8438. */
  8439. getActiveTextures(): BaseTexture[];
  8440. /**
  8441. * Gets the current class name of the material e.g. "MultiMaterial"
  8442. * Mainly use in serialization.
  8443. * @returns the class name
  8444. */
  8445. getClassName(): string;
  8446. /**
  8447. * Checks if the material is ready to render the requested sub mesh
  8448. * @param mesh Define the mesh the submesh belongs to
  8449. * @param subMesh Define the sub mesh to look readyness for
  8450. * @param useInstances Define whether or not the material is used with instances
  8451. * @returns true if ready, otherwise false
  8452. */
  8453. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  8454. /**
  8455. * Clones the current material and its related sub materials
  8456. * @param name Define the name of the newly cloned material
  8457. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  8458. * @returns the cloned material
  8459. */
  8460. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  8461. /**
  8462. * Serializes the materials into a JSON representation.
  8463. * @returns the JSON representation
  8464. */
  8465. serialize(): any;
  8466. /**
  8467. * Dispose the material and release its associated resources
  8468. * @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)
  8469. * @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)
  8470. * @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)
  8471. */
  8472. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  8473. /**
  8474. * Creates a MultiMaterial from parsed MultiMaterial data.
  8475. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  8476. * @param scene defines the hosting scene
  8477. * @returns a new MultiMaterial
  8478. */
  8479. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  8480. }
  8481. }
  8482. declare module "babylonjs/Loading/sceneLoaderFlags" {
  8483. /**
  8484. * Class used to represent data loading progression
  8485. */
  8486. export class SceneLoaderFlags {
  8487. private static _ForceFullSceneLoadingForIncremental;
  8488. private static _ShowLoadingScreen;
  8489. private static _CleanBoneMatrixWeights;
  8490. private static _loggingLevel;
  8491. /**
  8492. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  8493. */
  8494. static ForceFullSceneLoadingForIncremental: boolean;
  8495. /**
  8496. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  8497. */
  8498. static ShowLoadingScreen: boolean;
  8499. /**
  8500. * Defines the current logging level (while loading the scene)
  8501. * @ignorenaming
  8502. */
  8503. static loggingLevel: number;
  8504. /**
  8505. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  8506. */
  8507. static CleanBoneMatrixWeights: boolean;
  8508. }
  8509. }
  8510. declare module "babylonjs/Meshes/transformNode" {
  8511. import { DeepImmutable } from "babylonjs/types";
  8512. import { Observable } from "babylonjs/Misc/observable";
  8513. import { Nullable } from "babylonjs/types";
  8514. import { Camera } from "babylonjs/Cameras/camera";
  8515. import { Scene } from "babylonjs/scene";
  8516. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  8517. import { Node } from "babylonjs/node";
  8518. import { Bone } from "babylonjs/Bones/bone";
  8519. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8520. /**
  8521. * 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.
  8522. * @see https://doc.babylonjs.com/how_to/transformnode
  8523. */
  8524. export class TransformNode extends Node {
  8525. /**
  8526. * Object will not rotate to face the camera
  8527. */
  8528. static BILLBOARDMODE_NONE: number;
  8529. /**
  8530. * Object will rotate to face the camera but only on the x axis
  8531. */
  8532. static BILLBOARDMODE_X: number;
  8533. /**
  8534. * Object will rotate to face the camera but only on the y axis
  8535. */
  8536. static BILLBOARDMODE_Y: number;
  8537. /**
  8538. * Object will rotate to face the camera but only on the z axis
  8539. */
  8540. static BILLBOARDMODE_Z: number;
  8541. /**
  8542. * Object will rotate to face the camera
  8543. */
  8544. static BILLBOARDMODE_ALL: number;
  8545. private _forward;
  8546. private _forwardInverted;
  8547. private _up;
  8548. private _right;
  8549. private _rightInverted;
  8550. private _position;
  8551. private _rotation;
  8552. private _rotationQuaternion;
  8553. protected _scaling: Vector3;
  8554. protected _isDirty: boolean;
  8555. private _transformToBoneReferal;
  8556. private _billboardMode;
  8557. /**
  8558. * Gets or sets the billboard mode. Default is 0.
  8559. *
  8560. * | Value | Type | Description |
  8561. * | --- | --- | --- |
  8562. * | 0 | BILLBOARDMODE_NONE | |
  8563. * | 1 | BILLBOARDMODE_X | |
  8564. * | 2 | BILLBOARDMODE_Y | |
  8565. * | 4 | BILLBOARDMODE_Z | |
  8566. * | 7 | BILLBOARDMODE_ALL | |
  8567. *
  8568. */
  8569. billboardMode: number;
  8570. private _preserveParentRotationForBillboard;
  8571. /**
  8572. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  8573. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  8574. */
  8575. preserveParentRotationForBillboard: boolean;
  8576. /**
  8577. * 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
  8578. */
  8579. scalingDeterminant: number;
  8580. private _infiniteDistance;
  8581. /**
  8582. * Gets or sets the distance of the object to max, often used by skybox
  8583. */
  8584. infiniteDistance: boolean;
  8585. /**
  8586. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  8587. * By default the system will update normals to compensate
  8588. */
  8589. ignoreNonUniformScaling: boolean;
  8590. /**
  8591. * 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
  8592. */
  8593. reIntegrateRotationIntoRotationQuaternion: boolean;
  8594. /** @hidden */
  8595. _poseMatrix: Nullable<Matrix>;
  8596. /** @hidden */
  8597. _localMatrix: Matrix;
  8598. private _usePivotMatrix;
  8599. private _absolutePosition;
  8600. private _pivotMatrix;
  8601. private _pivotMatrixInverse;
  8602. protected _postMultiplyPivotMatrix: boolean;
  8603. protected _isWorldMatrixFrozen: boolean;
  8604. /** @hidden */
  8605. _indexInSceneTransformNodesArray: number;
  8606. /**
  8607. * An event triggered after the world matrix is updated
  8608. */
  8609. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  8610. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  8611. /**
  8612. * Gets a string identifying the name of the class
  8613. * @returns "TransformNode" string
  8614. */
  8615. getClassName(): string;
  8616. /**
  8617. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  8618. */
  8619. position: Vector3;
  8620. /**
  8621. * 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)).
  8622. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  8623. */
  8624. rotation: Vector3;
  8625. /**
  8626. * 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)).
  8627. */
  8628. scaling: Vector3;
  8629. /**
  8630. * 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).
  8631. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  8632. */
  8633. rotationQuaternion: Nullable<Quaternion>;
  8634. /**
  8635. * The forward direction of that transform in world space.
  8636. */
  8637. readonly forward: Vector3;
  8638. /**
  8639. * The up direction of that transform in world space.
  8640. */
  8641. readonly up: Vector3;
  8642. /**
  8643. * The right direction of that transform in world space.
  8644. */
  8645. readonly right: Vector3;
  8646. /**
  8647. * Copies the parameter passed Matrix into the mesh Pose matrix.
  8648. * @param matrix the matrix to copy the pose from
  8649. * @returns this TransformNode.
  8650. */
  8651. updatePoseMatrix(matrix: Matrix): TransformNode;
  8652. /**
  8653. * Returns the mesh Pose matrix.
  8654. * @returns the pose matrix
  8655. */
  8656. getPoseMatrix(): Matrix;
  8657. /** @hidden */
  8658. _isSynchronized(): boolean;
  8659. /** @hidden */
  8660. _initCache(): void;
  8661. /**
  8662. * Flag the transform node as dirty (Forcing it to update everything)
  8663. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  8664. * @returns this transform node
  8665. */
  8666. markAsDirty(property: string): TransformNode;
  8667. /**
  8668. * Returns the current mesh absolute position.
  8669. * Returns a Vector3.
  8670. */
  8671. readonly absolutePosition: Vector3;
  8672. /**
  8673. * Sets a new matrix to apply before all other transformation
  8674. * @param matrix defines the transform matrix
  8675. * @returns the current TransformNode
  8676. */
  8677. setPreTransformMatrix(matrix: Matrix): TransformNode;
  8678. /**
  8679. * Sets a new pivot matrix to the current node
  8680. * @param matrix defines the new pivot matrix to use
  8681. * @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
  8682. * @returns the current TransformNode
  8683. */
  8684. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  8685. /**
  8686. * Returns the mesh pivot matrix.
  8687. * Default : Identity.
  8688. * @returns the matrix
  8689. */
  8690. getPivotMatrix(): Matrix;
  8691. /**
  8692. * Prevents the World matrix to be computed any longer.
  8693. * @returns the TransformNode.
  8694. */
  8695. freezeWorldMatrix(): TransformNode;
  8696. /**
  8697. * Allows back the World matrix computation.
  8698. * @returns the TransformNode.
  8699. */
  8700. unfreezeWorldMatrix(): this;
  8701. /**
  8702. * True if the World matrix has been frozen.
  8703. */
  8704. readonly isWorldMatrixFrozen: boolean;
  8705. /**
  8706. * Retuns the mesh absolute position in the World.
  8707. * @returns a Vector3.
  8708. */
  8709. getAbsolutePosition(): Vector3;
  8710. /**
  8711. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  8712. * @param absolutePosition the absolute position to set
  8713. * @returns the TransformNode.
  8714. */
  8715. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  8716. /**
  8717. * Sets the mesh position in its local space.
  8718. * @param vector3 the position to set in localspace
  8719. * @returns the TransformNode.
  8720. */
  8721. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  8722. /**
  8723. * Returns the mesh position in the local space from the current World matrix values.
  8724. * @returns a new Vector3.
  8725. */
  8726. getPositionExpressedInLocalSpace(): Vector3;
  8727. /**
  8728. * Translates the mesh along the passed Vector3 in its local space.
  8729. * @param vector3 the distance to translate in localspace
  8730. * @returns the TransformNode.
  8731. */
  8732. locallyTranslate(vector3: Vector3): TransformNode;
  8733. private static _lookAtVectorCache;
  8734. /**
  8735. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  8736. * @param targetPoint the position (must be in same space as current mesh) to look at
  8737. * @param yawCor optional yaw (y-axis) correction in radians
  8738. * @param pitchCor optional pitch (x-axis) correction in radians
  8739. * @param rollCor optional roll (z-axis) correction in radians
  8740. * @param space the choosen space of the target
  8741. * @returns the TransformNode.
  8742. */
  8743. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  8744. /**
  8745. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8746. * This Vector3 is expressed in the World space.
  8747. * @param localAxis axis to rotate
  8748. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  8749. */
  8750. getDirection(localAxis: Vector3): Vector3;
  8751. /**
  8752. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  8753. * localAxis is expressed in the mesh local space.
  8754. * result is computed in the Wordl space from the mesh World matrix.
  8755. * @param localAxis axis to rotate
  8756. * @param result the resulting transformnode
  8757. * @returns this TransformNode.
  8758. */
  8759. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  8760. /**
  8761. * Sets this transform node rotation to the given local axis.
  8762. * @param localAxis the axis in local space
  8763. * @param yawCor optional yaw (y-axis) correction in radians
  8764. * @param pitchCor optional pitch (x-axis) correction in radians
  8765. * @param rollCor optional roll (z-axis) correction in radians
  8766. * @returns this TransformNode
  8767. */
  8768. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  8769. /**
  8770. * Sets a new pivot point to the current node
  8771. * @param point defines the new pivot point to use
  8772. * @param space defines if the point is in world or local space (local by default)
  8773. * @returns the current TransformNode
  8774. */
  8775. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  8776. /**
  8777. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  8778. * @returns the pivot point
  8779. */
  8780. getPivotPoint(): Vector3;
  8781. /**
  8782. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  8783. * @param result the vector3 to store the result
  8784. * @returns this TransformNode.
  8785. */
  8786. getPivotPointToRef(result: Vector3): TransformNode;
  8787. /**
  8788. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  8789. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  8790. */
  8791. getAbsolutePivotPoint(): Vector3;
  8792. /**
  8793. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  8794. * @param result vector3 to store the result
  8795. * @returns this TransformNode.
  8796. */
  8797. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  8798. /**
  8799. * Defines the passed node as the parent of the current node.
  8800. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  8801. * @see https://doc.babylonjs.com/how_to/parenting
  8802. * @param node the node ot set as the parent
  8803. * @returns this TransformNode.
  8804. */
  8805. setParent(node: Nullable<Node>): TransformNode;
  8806. private _nonUniformScaling;
  8807. /**
  8808. * True if the scaling property of this object is non uniform eg. (1,2,1)
  8809. */
  8810. readonly nonUniformScaling: boolean;
  8811. /** @hidden */
  8812. _updateNonUniformScalingState(value: boolean): boolean;
  8813. /**
  8814. * Attach the current TransformNode to another TransformNode associated with a bone
  8815. * @param bone Bone affecting the TransformNode
  8816. * @param affectedTransformNode TransformNode associated with the bone
  8817. * @returns this object
  8818. */
  8819. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  8820. /**
  8821. * Detach the transform node if its associated with a bone
  8822. * @returns this object
  8823. */
  8824. detachFromBone(): TransformNode;
  8825. private static _rotationAxisCache;
  8826. /**
  8827. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  8828. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8829. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8830. * The passed axis is also normalized.
  8831. * @param axis the axis to rotate around
  8832. * @param amount the amount to rotate in radians
  8833. * @param space Space to rotate in (Default: local)
  8834. * @returns the TransformNode.
  8835. */
  8836. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  8837. /**
  8838. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  8839. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  8840. * The passed axis is also normalized. .
  8841. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  8842. * @param point the point to rotate around
  8843. * @param axis the axis to rotate around
  8844. * @param amount the amount to rotate in radians
  8845. * @returns the TransformNode
  8846. */
  8847. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  8848. /**
  8849. * Translates the mesh along the axis vector for the passed distance in the given space.
  8850. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  8851. * @param axis the axis to translate in
  8852. * @param distance the distance to translate
  8853. * @param space Space to rotate in (Default: local)
  8854. * @returns the TransformNode.
  8855. */
  8856. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  8857. /**
  8858. * Adds a rotation step to the mesh current rotation.
  8859. * x, y, z are Euler angles expressed in radians.
  8860. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  8861. * This means this rotation is made in the mesh local space only.
  8862. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  8863. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  8864. * ```javascript
  8865. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  8866. * ```
  8867. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  8868. * 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.
  8869. * @param x Rotation to add
  8870. * @param y Rotation to add
  8871. * @param z Rotation to add
  8872. * @returns the TransformNode.
  8873. */
  8874. addRotation(x: number, y: number, z: number): TransformNode;
  8875. /**
  8876. * @hidden
  8877. */
  8878. protected _getEffectiveParent(): Nullable<Node>;
  8879. /**
  8880. * Computes the world matrix of the node
  8881. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8882. * @returns the world matrix
  8883. */
  8884. computeWorldMatrix(force?: boolean): Matrix;
  8885. protected _afterComputeWorldMatrix(): void;
  8886. /**
  8887. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  8888. * @param func callback function to add
  8889. *
  8890. * @returns the TransformNode.
  8891. */
  8892. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8893. /**
  8894. * Removes a registered callback function.
  8895. * @param func callback function to remove
  8896. * @returns the TransformNode.
  8897. */
  8898. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  8899. /**
  8900. * Gets the position of the current mesh in camera space
  8901. * @param camera defines the camera to use
  8902. * @returns a position
  8903. */
  8904. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  8905. /**
  8906. * Returns the distance from the mesh to the active camera
  8907. * @param camera defines the camera to use
  8908. * @returns the distance
  8909. */
  8910. getDistanceToCamera(camera?: Nullable<Camera>): number;
  8911. /**
  8912. * Clone the current transform node
  8913. * @param name Name of the new clone
  8914. * @param newParent New parent for the clone
  8915. * @param doNotCloneChildren Do not clone children hierarchy
  8916. * @returns the new transform node
  8917. */
  8918. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  8919. /**
  8920. * Serializes the objects information.
  8921. * @param currentSerializationObject defines the object to serialize in
  8922. * @returns the serialized object
  8923. */
  8924. serialize(currentSerializationObject?: any): any;
  8925. /**
  8926. * Returns a new TransformNode object parsed from the source provided.
  8927. * @param parsedTransformNode is the source.
  8928. * @param scene the scne the object belongs to
  8929. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  8930. * @returns a new TransformNode object parsed from the source provided.
  8931. */
  8932. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  8933. /**
  8934. * Get all child-transformNodes of this node
  8935. * @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
  8936. * @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
  8937. * @returns an array of TransformNode
  8938. */
  8939. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  8940. /**
  8941. * Releases resources associated with this transform node.
  8942. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8943. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8944. */
  8945. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8946. /**
  8947. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  8948. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  8949. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  8950. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  8951. * @returns the current mesh
  8952. */
  8953. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  8954. }
  8955. }
  8956. declare module "babylonjs/Animations/animationPropertiesOverride" {
  8957. /**
  8958. * Class used to override all child animations of a given target
  8959. */
  8960. export class AnimationPropertiesOverride {
  8961. /**
  8962. * Gets or sets a value indicating if animation blending must be used
  8963. */
  8964. enableBlending: boolean;
  8965. /**
  8966. * Gets or sets the blending speed to use when enableBlending is true
  8967. */
  8968. blendingSpeed: number;
  8969. /**
  8970. * Gets or sets the default loop mode to use
  8971. */
  8972. loopMode: number;
  8973. }
  8974. }
  8975. declare module "babylonjs/Bones/bone" {
  8976. import { Skeleton } from "babylonjs/Bones/skeleton";
  8977. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  8978. import { Nullable } from "babylonjs/types";
  8979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8980. import { TransformNode } from "babylonjs/Meshes/transformNode";
  8981. import { Node } from "babylonjs/node";
  8982. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  8983. /**
  8984. * Class used to store bone information
  8985. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8986. */
  8987. export class Bone extends Node {
  8988. /**
  8989. * defines the bone name
  8990. */
  8991. name: string;
  8992. private static _tmpVecs;
  8993. private static _tmpQuat;
  8994. private static _tmpMats;
  8995. /**
  8996. * Gets the list of child bones
  8997. */
  8998. children: Bone[];
  8999. /** Gets the animations associated with this bone */
  9000. animations: import("babylonjs/Animations/animation").Animation[];
  9001. /**
  9002. * Gets or sets bone length
  9003. */
  9004. length: number;
  9005. /**
  9006. * @hidden Internal only
  9007. * Set this value to map this bone to a different index in the transform matrices
  9008. * Set this value to -1 to exclude the bone from the transform matrices
  9009. */
  9010. _index: Nullable<number>;
  9011. private _skeleton;
  9012. private _localMatrix;
  9013. private _restPose;
  9014. private _baseMatrix;
  9015. private _absoluteTransform;
  9016. private _invertedAbsoluteTransform;
  9017. private _parent;
  9018. private _scalingDeterminant;
  9019. private _worldTransform;
  9020. private _localScaling;
  9021. private _localRotation;
  9022. private _localPosition;
  9023. private _needToDecompose;
  9024. private _needToCompose;
  9025. /** @hidden */
  9026. _linkedTransformNode: Nullable<TransformNode>;
  9027. /** @hidden */
  9028. _waitingTransformNodeId: Nullable<string>;
  9029. /** @hidden */
  9030. /** @hidden */
  9031. _matrix: Matrix;
  9032. /**
  9033. * Create a new bone
  9034. * @param name defines the bone name
  9035. * @param skeleton defines the parent skeleton
  9036. * @param parentBone defines the parent (can be null if the bone is the root)
  9037. * @param localMatrix defines the local matrix
  9038. * @param restPose defines the rest pose matrix
  9039. * @param baseMatrix defines the base matrix
  9040. * @param index defines index of the bone in the hiearchy
  9041. */
  9042. constructor(
  9043. /**
  9044. * defines the bone name
  9045. */
  9046. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  9047. /**
  9048. * Gets the current object class name.
  9049. * @return the class name
  9050. */
  9051. getClassName(): string;
  9052. /**
  9053. * Gets the parent skeleton
  9054. * @returns a skeleton
  9055. */
  9056. getSkeleton(): Skeleton;
  9057. /**
  9058. * Gets parent bone
  9059. * @returns a bone or null if the bone is the root of the bone hierarchy
  9060. */
  9061. getParent(): Nullable<Bone>;
  9062. /**
  9063. * Returns an array containing the root bones
  9064. * @returns an array containing the root bones
  9065. */
  9066. getChildren(): Array<Bone>;
  9067. /**
  9068. * Sets the parent bone
  9069. * @param parent defines the parent (can be null if the bone is the root)
  9070. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9071. */
  9072. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  9073. /**
  9074. * Gets the local matrix
  9075. * @returns a matrix
  9076. */
  9077. getLocalMatrix(): Matrix;
  9078. /**
  9079. * Gets the base matrix (initial matrix which remains unchanged)
  9080. * @returns a matrix
  9081. */
  9082. getBaseMatrix(): Matrix;
  9083. /**
  9084. * Gets the rest pose matrix
  9085. * @returns a matrix
  9086. */
  9087. getRestPose(): Matrix;
  9088. /**
  9089. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  9090. */
  9091. getWorldMatrix(): Matrix;
  9092. /**
  9093. * Sets the local matrix to rest pose matrix
  9094. */
  9095. returnToRest(): void;
  9096. /**
  9097. * Gets the inverse of the absolute transform matrix.
  9098. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  9099. * @returns a matrix
  9100. */
  9101. getInvertedAbsoluteTransform(): Matrix;
  9102. /**
  9103. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9104. * @returns a matrix
  9105. */
  9106. getAbsoluteTransform(): Matrix;
  9107. /**
  9108. * Links with the given transform node.
  9109. * The local matrix of this bone is copied from the transform node every frame.
  9110. * @param transformNode defines the transform node to link to
  9111. */
  9112. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  9113. /** Gets or sets current position (in local space) */
  9114. position: Vector3;
  9115. /** Gets or sets current rotation (in local space) */
  9116. rotation: Vector3;
  9117. /** Gets or sets current rotation quaternion (in local space) */
  9118. rotationQuaternion: Quaternion;
  9119. /** Gets or sets current scaling (in local space) */
  9120. scaling: Vector3;
  9121. /**
  9122. * Gets the animation properties override
  9123. */
  9124. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  9125. private _decompose;
  9126. private _compose;
  9127. /**
  9128. * Update the base and local matrices
  9129. * @param matrix defines the new base or local matrix
  9130. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9131. * @param updateLocalMatrix defines if the local matrix should be updated
  9132. */
  9133. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  9134. /** @hidden */
  9135. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  9136. /**
  9137. * Flag the bone as dirty (Forcing it to update everything)
  9138. */
  9139. markAsDirty(): void;
  9140. /** @hidden */
  9141. _markAsDirtyAndCompose(): void;
  9142. private _markAsDirtyAndDecompose;
  9143. /**
  9144. * Translate the bone in local or world space
  9145. * @param vec The amount to translate the bone
  9146. * @param space The space that the translation is in
  9147. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9148. */
  9149. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9150. /**
  9151. * Set the postion of the bone in local or world space
  9152. * @param position The position to set the bone
  9153. * @param space The space that the position is in
  9154. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9155. */
  9156. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9157. /**
  9158. * Set the absolute position of the bone (world space)
  9159. * @param position The position to set the bone
  9160. * @param mesh The mesh that this bone is attached to
  9161. */
  9162. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  9163. /**
  9164. * Scale the bone on the x, y and z axes (in local space)
  9165. * @param x The amount to scale the bone on the x axis
  9166. * @param y The amount to scale the bone on the y axis
  9167. * @param z The amount to scale the bone on the z axis
  9168. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  9169. */
  9170. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  9171. /**
  9172. * Set the bone scaling in local space
  9173. * @param scale defines the scaling vector
  9174. */
  9175. setScale(scale: Vector3): void;
  9176. /**
  9177. * Gets the current scaling in local space
  9178. * @returns the current scaling vector
  9179. */
  9180. getScale(): Vector3;
  9181. /**
  9182. * Gets the current scaling in local space and stores it in a target vector
  9183. * @param result defines the target vector
  9184. */
  9185. getScaleToRef(result: Vector3): void;
  9186. /**
  9187. * Set the yaw, pitch, and roll of the bone in local or world space
  9188. * @param yaw The rotation of the bone on the y axis
  9189. * @param pitch The rotation of the bone on the x axis
  9190. * @param roll The rotation of the bone on the z axis
  9191. * @param space The space that the axes of rotation are in
  9192. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9193. */
  9194. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  9195. /**
  9196. * Add a rotation to the bone on an axis in local or world space
  9197. * @param axis The axis to rotate the bone on
  9198. * @param amount The amount to rotate the bone
  9199. * @param space The space that the axis is in
  9200. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9201. */
  9202. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  9203. /**
  9204. * Set the rotation of the bone to a particular axis angle in local or world space
  9205. * @param axis The axis to rotate the bone on
  9206. * @param angle The angle that the bone should be rotated to
  9207. * @param space The space that the axis is in
  9208. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9209. */
  9210. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  9211. /**
  9212. * Set the euler rotation of the bone in local of world space
  9213. * @param rotation The euler rotation that the bone should be set to
  9214. * @param space The space that the rotation is in
  9215. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9216. */
  9217. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  9218. /**
  9219. * Set the quaternion rotation of the bone in local of world space
  9220. * @param quat The quaternion rotation that the bone should be set to
  9221. * @param space The space that the rotation is in
  9222. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9223. */
  9224. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  9225. /**
  9226. * Set the rotation matrix of the bone in local of world space
  9227. * @param rotMat The rotation matrix that the bone should be set to
  9228. * @param space The space that the rotation is in
  9229. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9230. */
  9231. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  9232. private _rotateWithMatrix;
  9233. private _getNegativeRotationToRef;
  9234. /**
  9235. * Get the position of the bone in local or world space
  9236. * @param space The space that the returned position is in
  9237. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9238. * @returns The position of the bone
  9239. */
  9240. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9241. /**
  9242. * Copy the position of the bone to a vector3 in local or world space
  9243. * @param space The space that the returned position is in
  9244. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9245. * @param result The vector3 to copy the position to
  9246. */
  9247. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  9248. /**
  9249. * Get the absolute position of the bone (world space)
  9250. * @param mesh The mesh that this bone is attached to
  9251. * @returns The absolute position of the bone
  9252. */
  9253. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  9254. /**
  9255. * Copy the absolute position of the bone (world space) to the result param
  9256. * @param mesh The mesh that this bone is attached to
  9257. * @param result The vector3 to copy the absolute position to
  9258. */
  9259. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  9260. /**
  9261. * Compute the absolute transforms of this bone and its children
  9262. */
  9263. computeAbsoluteTransforms(): void;
  9264. /**
  9265. * Get the world direction from an axis that is in the local space of the bone
  9266. * @param localAxis The local direction that is used to compute the world direction
  9267. * @param mesh The mesh that this bone is attached to
  9268. * @returns The world direction
  9269. */
  9270. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9271. /**
  9272. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  9273. * @param localAxis The local direction that is used to compute the world direction
  9274. * @param mesh The mesh that this bone is attached to
  9275. * @param result The vector3 that the world direction will be copied to
  9276. */
  9277. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9278. /**
  9279. * Get the euler rotation of the bone in local or world space
  9280. * @param space The space that the rotation should be in
  9281. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9282. * @returns The euler rotation
  9283. */
  9284. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  9285. /**
  9286. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  9287. * @param space The space that the rotation should be in
  9288. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9289. * @param result The vector3 that the rotation should be copied to
  9290. */
  9291. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9292. /**
  9293. * Get the quaternion rotation of the bone in either local or world space
  9294. * @param space The space that the rotation should be in
  9295. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9296. * @returns The quaternion rotation
  9297. */
  9298. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  9299. /**
  9300. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  9301. * @param space The space that the rotation should be in
  9302. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9303. * @param result The quaternion that the rotation should be copied to
  9304. */
  9305. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  9306. /**
  9307. * Get the rotation matrix of the bone in local or world space
  9308. * @param space The space that the rotation should be in
  9309. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9310. * @returns The rotation matrix
  9311. */
  9312. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  9313. /**
  9314. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  9315. * @param space The space that the rotation should be in
  9316. * @param mesh The mesh that this bone is attached to. This is only used in world space
  9317. * @param result The quaternion that the rotation should be copied to
  9318. */
  9319. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  9320. /**
  9321. * Get the world position of a point that is in the local space of the bone
  9322. * @param position The local position
  9323. * @param mesh The mesh that this bone is attached to
  9324. * @returns The world position
  9325. */
  9326. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9327. /**
  9328. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  9329. * @param position The local position
  9330. * @param mesh The mesh that this bone is attached to
  9331. * @param result The vector3 that the world position should be copied to
  9332. */
  9333. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9334. /**
  9335. * Get the local position of a point that is in world space
  9336. * @param position The world position
  9337. * @param mesh The mesh that this bone is attached to
  9338. * @returns The local position
  9339. */
  9340. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  9341. /**
  9342. * Get the local position of a point that is in world space and copy it to the result param
  9343. * @param position The world position
  9344. * @param mesh The mesh that this bone is attached to
  9345. * @param result The vector3 that the local position should be copied to
  9346. */
  9347. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  9348. }
  9349. }
  9350. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  9351. import { Nullable } from "babylonjs/types";
  9352. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  9353. import { Scene } from "babylonjs/scene";
  9354. module "babylonjs/Engines/engine" {
  9355. interface Engine {
  9356. /**
  9357. * Creates a raw texture
  9358. * @param data defines the data to store in the texture
  9359. * @param width defines the width of the texture
  9360. * @param height defines the height of the texture
  9361. * @param format defines the format of the data
  9362. * @param generateMipMaps defines if the engine should generate the mip levels
  9363. * @param invertY defines if data must be stored with Y axis inverted
  9364. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  9365. * @param compression defines the compression used (null by default)
  9366. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9367. * @returns the raw texture inside an InternalTexture
  9368. */
  9369. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  9370. /**
  9371. * Update a raw texture
  9372. * @param texture defines the texture to update
  9373. * @param data defines the data to store in the texture
  9374. * @param format defines the format of the data
  9375. * @param invertY defines if data must be stored with Y axis inverted
  9376. */
  9377. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9378. /**
  9379. * Update a raw texture
  9380. * @param texture defines the texture to update
  9381. * @param data defines the data to store in the texture
  9382. * @param format defines the format of the data
  9383. * @param invertY defines if data must be stored with Y axis inverted
  9384. * @param compression defines the compression used (null by default)
  9385. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9386. */
  9387. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  9388. /**
  9389. * Creates a new raw cube texture
  9390. * @param data defines the array of data to use to create each face
  9391. * @param size defines the size of the textures
  9392. * @param format defines the format of the data
  9393. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9394. * @param generateMipMaps defines if the engine should generate the mip levels
  9395. * @param invertY defines if data must be stored with Y axis inverted
  9396. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9397. * @param compression defines the compression used (null by default)
  9398. * @returns the cube texture as an InternalTexture
  9399. */
  9400. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  9401. /**
  9402. * Update a raw cube texture
  9403. * @param texture defines the texture to udpdate
  9404. * @param data defines the data to store
  9405. * @param format defines the data format
  9406. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9407. * @param invertY defines if data must be stored with Y axis inverted
  9408. */
  9409. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  9410. /**
  9411. * Update a raw cube texture
  9412. * @param texture defines the texture to udpdate
  9413. * @param data defines the data to store
  9414. * @param format defines the data format
  9415. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9416. * @param invertY defines if data must be stored with Y axis inverted
  9417. * @param compression defines the compression used (null by default)
  9418. */
  9419. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  9420. /**
  9421. * Update a raw cube texture
  9422. * @param texture defines the texture to udpdate
  9423. * @param data defines the data to store
  9424. * @param format defines the data format
  9425. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  9426. * @param invertY defines if data must be stored with Y axis inverted
  9427. * @param compression defines the compression used (null by default)
  9428. * @param level defines which level of the texture to update
  9429. */
  9430. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  9431. /**
  9432. * Creates a new raw cube texture from a specified url
  9433. * @param url defines the url where the data is located
  9434. * @param scene defines the current scene
  9435. * @param size defines the size of the textures
  9436. * @param format defines the format of the data
  9437. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9438. * @param noMipmap defines if the engine should avoid generating the mip levels
  9439. * @param callback defines a callback used to extract texture data from loaded data
  9440. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9441. * @param onLoad defines a callback called when texture is loaded
  9442. * @param onError defines a callback called if there is an error
  9443. * @returns the cube texture as an InternalTexture
  9444. */
  9445. 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;
  9446. /**
  9447. * Creates a new raw cube texture from a specified url
  9448. * @param url defines the url where the data is located
  9449. * @param scene defines the current scene
  9450. * @param size defines the size of the textures
  9451. * @param format defines the format of the data
  9452. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  9453. * @param noMipmap defines if the engine should avoid generating the mip levels
  9454. * @param callback defines a callback used to extract texture data from loaded data
  9455. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  9456. * @param onLoad defines a callback called when texture is loaded
  9457. * @param onError defines a callback called if there is an error
  9458. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9459. * @param invertY defines if data must be stored with Y axis inverted
  9460. * @returns the cube texture as an InternalTexture
  9461. */
  9462. 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;
  9463. /**
  9464. * Creates a new raw 3D texture
  9465. * @param data defines the data used to create the texture
  9466. * @param width defines the width of the texture
  9467. * @param height defines the height of the texture
  9468. * @param depth defines the depth of the texture
  9469. * @param format defines the format of the texture
  9470. * @param generateMipMaps defines if the engine must generate mip levels
  9471. * @param invertY defines if data must be stored with Y axis inverted
  9472. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  9473. * @param compression defines the compressed used (can be null)
  9474. * @param textureType defines the compressed used (can be null)
  9475. * @returns a new raw 3D texture (stored in an InternalTexture)
  9476. */
  9477. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  9478. /**
  9479. * Update a raw 3D texture
  9480. * @param texture defines the texture to update
  9481. * @param data defines the data to store
  9482. * @param format defines the data format
  9483. * @param invertY defines if data must be stored with Y axis inverted
  9484. */
  9485. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  9486. /**
  9487. * Update a raw 3D texture
  9488. * @param texture defines the texture to update
  9489. * @param data defines the data to store
  9490. * @param format defines the data format
  9491. * @param invertY defines if data must be stored with Y axis inverted
  9492. * @param compression defines the used compression (can be null)
  9493. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  9494. */
  9495. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  9496. }
  9497. }
  9498. }
  9499. declare module "babylonjs/Materials/Textures/rawTexture" {
  9500. import { Scene } from "babylonjs/scene";
  9501. import { Texture } from "babylonjs/Materials/Textures/texture";
  9502. import "babylonjs/Engines/Extensions/engine.rawTexture";
  9503. /**
  9504. * Raw texture can help creating a texture directly from an array of data.
  9505. * This can be super useful if you either get the data from an uncompressed source or
  9506. * if you wish to create your texture pixel by pixel.
  9507. */
  9508. export class RawTexture extends Texture {
  9509. /**
  9510. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9511. */
  9512. format: number;
  9513. private _engine;
  9514. /**
  9515. * Instantiates a new RawTexture.
  9516. * Raw texture can help creating a texture directly from an array of data.
  9517. * This can be super useful if you either get the data from an uncompressed source or
  9518. * if you wish to create your texture pixel by pixel.
  9519. * @param data define the array of data to use to create the texture
  9520. * @param width define the width of the texture
  9521. * @param height define the height of the texture
  9522. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9523. * @param scene define the scene the texture belongs to
  9524. * @param generateMipMaps define whether mip maps should be generated or not
  9525. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9526. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9527. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9528. */
  9529. constructor(data: ArrayBufferView, width: number, height: number,
  9530. /**
  9531. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  9532. */
  9533. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  9534. /**
  9535. * Updates the texture underlying data.
  9536. * @param data Define the new data of the texture
  9537. */
  9538. update(data: ArrayBufferView): void;
  9539. /**
  9540. * Creates a luminance texture from some data.
  9541. * @param data Define the texture data
  9542. * @param width Define the width of the texture
  9543. * @param height Define the height of the texture
  9544. * @param scene Define the scene the texture belongs to
  9545. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9546. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9547. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9548. * @returns the luminance texture
  9549. */
  9550. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9551. /**
  9552. * Creates a luminance alpha texture from some data.
  9553. * @param data Define the texture data
  9554. * @param width Define the width of the texture
  9555. * @param height Define the height of the texture
  9556. * @param scene Define the scene the texture belongs to
  9557. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9558. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9559. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9560. * @returns the luminance alpha texture
  9561. */
  9562. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9563. /**
  9564. * Creates an alpha texture from some data.
  9565. * @param data Define the texture data
  9566. * @param width Define the width of the texture
  9567. * @param height Define the height of the texture
  9568. * @param scene Define the scene the texture belongs to
  9569. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9570. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9571. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9572. * @returns the alpha texture
  9573. */
  9574. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  9575. /**
  9576. * Creates a RGB texture from some data.
  9577. * @param data Define the texture data
  9578. * @param width Define the width of the texture
  9579. * @param height Define the height of the texture
  9580. * @param scene Define the scene the texture belongs to
  9581. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9582. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9583. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9584. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9585. * @returns the RGB alpha texture
  9586. */
  9587. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9588. /**
  9589. * Creates a RGBA texture from some data.
  9590. * @param data Define the texture data
  9591. * @param width Define the width of the texture
  9592. * @param height Define the height of the texture
  9593. * @param scene Define the scene the texture belongs to
  9594. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9595. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9596. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9597. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9598. * @returns the RGBA texture
  9599. */
  9600. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9601. /**
  9602. * Creates a R texture from some data.
  9603. * @param data Define the texture data
  9604. * @param width Define the width of the texture
  9605. * @param height Define the height of the texture
  9606. * @param scene Define the scene the texture belongs to
  9607. * @param generateMipMaps Define whether or not to create mip maps for the texture
  9608. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  9609. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  9610. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  9611. * @returns the R texture
  9612. */
  9613. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  9614. }
  9615. }
  9616. declare module "babylonjs/Animations/runtimeAnimation" {
  9617. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  9618. import { Animatable } from "babylonjs/Animations/animatable";
  9619. import { Scene } from "babylonjs/scene";
  9620. /**
  9621. * Defines a runtime animation
  9622. */
  9623. export class RuntimeAnimation {
  9624. private _events;
  9625. /**
  9626. * The current frame of the runtime animation
  9627. */
  9628. private _currentFrame;
  9629. /**
  9630. * The animation used by the runtime animation
  9631. */
  9632. private _animation;
  9633. /**
  9634. * The target of the runtime animation
  9635. */
  9636. private _target;
  9637. /**
  9638. * The initiating animatable
  9639. */
  9640. private _host;
  9641. /**
  9642. * The original value of the runtime animation
  9643. */
  9644. private _originalValue;
  9645. /**
  9646. * The original blend value of the runtime animation
  9647. */
  9648. private _originalBlendValue;
  9649. /**
  9650. * The offsets cache of the runtime animation
  9651. */
  9652. private _offsetsCache;
  9653. /**
  9654. * The high limits cache of the runtime animation
  9655. */
  9656. private _highLimitsCache;
  9657. /**
  9658. * Specifies if the runtime animation has been stopped
  9659. */
  9660. private _stopped;
  9661. /**
  9662. * The blending factor of the runtime animation
  9663. */
  9664. private _blendingFactor;
  9665. /**
  9666. * The BabylonJS scene
  9667. */
  9668. private _scene;
  9669. /**
  9670. * The current value of the runtime animation
  9671. */
  9672. private _currentValue;
  9673. /** @hidden */
  9674. _animationState: _IAnimationState;
  9675. /**
  9676. * The active target of the runtime animation
  9677. */
  9678. private _activeTargets;
  9679. private _currentActiveTarget;
  9680. private _directTarget;
  9681. /**
  9682. * The target path of the runtime animation
  9683. */
  9684. private _targetPath;
  9685. /**
  9686. * The weight of the runtime animation
  9687. */
  9688. private _weight;
  9689. /**
  9690. * The ratio offset of the runtime animation
  9691. */
  9692. private _ratioOffset;
  9693. /**
  9694. * The previous delay of the runtime animation
  9695. */
  9696. private _previousDelay;
  9697. /**
  9698. * The previous ratio of the runtime animation
  9699. */
  9700. private _previousRatio;
  9701. private _enableBlending;
  9702. private _keys;
  9703. private _minFrame;
  9704. private _maxFrame;
  9705. private _minValue;
  9706. private _maxValue;
  9707. private _targetIsArray;
  9708. /**
  9709. * Gets the current frame of the runtime animation
  9710. */
  9711. readonly currentFrame: number;
  9712. /**
  9713. * Gets the weight of the runtime animation
  9714. */
  9715. readonly weight: number;
  9716. /**
  9717. * Gets the current value of the runtime animation
  9718. */
  9719. readonly currentValue: any;
  9720. /**
  9721. * Gets the target path of the runtime animation
  9722. */
  9723. readonly targetPath: string;
  9724. /**
  9725. * Gets the actual target of the runtime animation
  9726. */
  9727. readonly target: any;
  9728. /** @hidden */
  9729. _onLoop: () => void;
  9730. /**
  9731. * Create a new RuntimeAnimation object
  9732. * @param target defines the target of the animation
  9733. * @param animation defines the source animation object
  9734. * @param scene defines the hosting scene
  9735. * @param host defines the initiating Animatable
  9736. */
  9737. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  9738. private _preparePath;
  9739. /**
  9740. * Gets the animation from the runtime animation
  9741. */
  9742. readonly animation: Animation;
  9743. /**
  9744. * Resets the runtime animation to the beginning
  9745. * @param restoreOriginal defines whether to restore the target property to the original value
  9746. */
  9747. reset(restoreOriginal?: boolean): void;
  9748. /**
  9749. * Specifies if the runtime animation is stopped
  9750. * @returns Boolean specifying if the runtime animation is stopped
  9751. */
  9752. isStopped(): boolean;
  9753. /**
  9754. * Disposes of the runtime animation
  9755. */
  9756. dispose(): void;
  9757. /**
  9758. * Apply the interpolated value to the target
  9759. * @param currentValue defines the value computed by the animation
  9760. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  9761. */
  9762. setValue(currentValue: any, weight: number): void;
  9763. private _getOriginalValues;
  9764. private _setValue;
  9765. /**
  9766. * Gets the loop pmode of the runtime animation
  9767. * @returns Loop Mode
  9768. */
  9769. private _getCorrectLoopMode;
  9770. /**
  9771. * Move the current animation to a given frame
  9772. * @param frame defines the frame to move to
  9773. */
  9774. goToFrame(frame: number): void;
  9775. /**
  9776. * @hidden Internal use only
  9777. */
  9778. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  9779. /**
  9780. * Execute the current animation
  9781. * @param delay defines the delay to add to the current frame
  9782. * @param from defines the lower bound of the animation range
  9783. * @param to defines the upper bound of the animation range
  9784. * @param loop defines if the current animation must loop
  9785. * @param speedRatio defines the current speed ratio
  9786. * @param weight defines the weight of the animation (default is -1 so no weight)
  9787. * @param onLoop optional callback called when animation loops
  9788. * @returns a boolean indicating if the animation is running
  9789. */
  9790. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  9791. }
  9792. }
  9793. declare module "babylonjs/Animations/animatable" {
  9794. import { Animation } from "babylonjs/Animations/animation";
  9795. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  9796. import { Nullable } from "babylonjs/types";
  9797. import { Observable } from "babylonjs/Misc/observable";
  9798. import { Scene } from "babylonjs/scene";
  9799. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  9800. import { Node } from "babylonjs/node";
  9801. /**
  9802. * Class used to store an actual running animation
  9803. */
  9804. export class Animatable {
  9805. /** defines the target object */
  9806. target: any;
  9807. /** defines the starting frame number (default is 0) */
  9808. fromFrame: number;
  9809. /** defines the ending frame number (default is 100) */
  9810. toFrame: number;
  9811. /** defines if the animation must loop (default is false) */
  9812. loopAnimation: boolean;
  9813. /** defines a callback to call when animation ends if it is not looping */
  9814. onAnimationEnd?: (() => void) | null | undefined;
  9815. /** defines a callback to call when animation loops */
  9816. onAnimationLoop?: (() => void) | null | undefined;
  9817. private _localDelayOffset;
  9818. private _pausedDelay;
  9819. private _runtimeAnimations;
  9820. private _paused;
  9821. private _scene;
  9822. private _speedRatio;
  9823. private _weight;
  9824. private _syncRoot;
  9825. /**
  9826. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  9827. * This will only apply for non looping animation (default is true)
  9828. */
  9829. disposeOnEnd: boolean;
  9830. /**
  9831. * Gets a boolean indicating if the animation has started
  9832. */
  9833. animationStarted: boolean;
  9834. /**
  9835. * Observer raised when the animation ends
  9836. */
  9837. onAnimationEndObservable: Observable<Animatable>;
  9838. /**
  9839. * Observer raised when the animation loops
  9840. */
  9841. onAnimationLoopObservable: Observable<Animatable>;
  9842. /**
  9843. * Gets the root Animatable used to synchronize and normalize animations
  9844. */
  9845. readonly syncRoot: Nullable<Animatable>;
  9846. /**
  9847. * Gets the current frame of the first RuntimeAnimation
  9848. * Used to synchronize Animatables
  9849. */
  9850. readonly masterFrame: number;
  9851. /**
  9852. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  9853. */
  9854. weight: number;
  9855. /**
  9856. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  9857. */
  9858. speedRatio: number;
  9859. /**
  9860. * Creates a new Animatable
  9861. * @param scene defines the hosting scene
  9862. * @param target defines the target object
  9863. * @param fromFrame defines the starting frame number (default is 0)
  9864. * @param toFrame defines the ending frame number (default is 100)
  9865. * @param loopAnimation defines if the animation must loop (default is false)
  9866. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  9867. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  9868. * @param animations defines a group of animation to add to the new Animatable
  9869. * @param onAnimationLoop defines a callback to call when animation loops
  9870. */
  9871. constructor(scene: Scene,
  9872. /** defines the target object */
  9873. target: any,
  9874. /** defines the starting frame number (default is 0) */
  9875. fromFrame?: number,
  9876. /** defines the ending frame number (default is 100) */
  9877. toFrame?: number,
  9878. /** defines if the animation must loop (default is false) */
  9879. loopAnimation?: boolean, speedRatio?: number,
  9880. /** defines a callback to call when animation ends if it is not looping */
  9881. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  9882. /** defines a callback to call when animation loops */
  9883. onAnimationLoop?: (() => void) | null | undefined);
  9884. /**
  9885. * Synchronize and normalize current Animatable with a source Animatable
  9886. * This is useful when using animation weights and when animations are not of the same length
  9887. * @param root defines the root Animatable to synchronize with
  9888. * @returns the current Animatable
  9889. */
  9890. syncWith(root: Animatable): Animatable;
  9891. /**
  9892. * Gets the list of runtime animations
  9893. * @returns an array of RuntimeAnimation
  9894. */
  9895. getAnimations(): RuntimeAnimation[];
  9896. /**
  9897. * Adds more animations to the current animatable
  9898. * @param target defines the target of the animations
  9899. * @param animations defines the new animations to add
  9900. */
  9901. appendAnimations(target: any, animations: Animation[]): void;
  9902. /**
  9903. * Gets the source animation for a specific property
  9904. * @param property defines the propertyu to look for
  9905. * @returns null or the source animation for the given property
  9906. */
  9907. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  9908. /**
  9909. * Gets the runtime animation for a specific property
  9910. * @param property defines the propertyu to look for
  9911. * @returns null or the runtime animation for the given property
  9912. */
  9913. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  9914. /**
  9915. * Resets the animatable to its original state
  9916. */
  9917. reset(): void;
  9918. /**
  9919. * Allows the animatable to blend with current running animations
  9920. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9921. * @param blendingSpeed defines the blending speed to use
  9922. */
  9923. enableBlending(blendingSpeed: number): void;
  9924. /**
  9925. * Disable animation blending
  9926. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  9927. */
  9928. disableBlending(): void;
  9929. /**
  9930. * Jump directly to a given frame
  9931. * @param frame defines the frame to jump to
  9932. */
  9933. goToFrame(frame: number): void;
  9934. /**
  9935. * Pause the animation
  9936. */
  9937. pause(): void;
  9938. /**
  9939. * Restart the animation
  9940. */
  9941. restart(): void;
  9942. private _raiseOnAnimationEnd;
  9943. /**
  9944. * Stop and delete the current animation
  9945. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  9946. * @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)
  9947. */
  9948. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  9949. /**
  9950. * Wait asynchronously for the animation to end
  9951. * @returns a promise which will be fullfilled when the animation ends
  9952. */
  9953. waitAsync(): Promise<Animatable>;
  9954. /** @hidden */
  9955. _animate(delay: number): boolean;
  9956. }
  9957. module "babylonjs/scene" {
  9958. interface Scene {
  9959. /** @hidden */
  9960. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  9961. /** @hidden */
  9962. _processLateAnimationBindingsForMatrices(holder: {
  9963. totalWeight: number;
  9964. animations: RuntimeAnimation[];
  9965. originalValue: Matrix;
  9966. }): any;
  9967. /** @hidden */
  9968. _processLateAnimationBindingsForQuaternions(holder: {
  9969. totalWeight: number;
  9970. animations: RuntimeAnimation[];
  9971. originalValue: Quaternion;
  9972. }, refQuaternion: Quaternion): Quaternion;
  9973. /** @hidden */
  9974. _processLateAnimationBindings(): void;
  9975. /**
  9976. * Will start the animation sequence of a given target
  9977. * @param target defines the target
  9978. * @param from defines from which frame should animation start
  9979. * @param to defines until which frame should animation run.
  9980. * @param weight defines the weight to apply to the animation (1.0 by default)
  9981. * @param loop defines if the animation loops
  9982. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9983. * @param onAnimationEnd defines the function to be executed when the animation ends
  9984. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9985. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  9986. * @param onAnimationLoop defines the callback to call when an animation loops
  9987. * @returns the animatable object created for this animation
  9988. */
  9989. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  9990. /**
  9991. * Will start the animation sequence of a given target
  9992. * @param target defines the target
  9993. * @param from defines from which frame should animation start
  9994. * @param to defines until which frame should animation run.
  9995. * @param loop defines if the animation loops
  9996. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  9997. * @param onAnimationEnd defines the function to be executed when the animation ends
  9998. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  9999. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  10000. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  10001. * @param onAnimationLoop defines the callback to call when an animation loops
  10002. * @returns the animatable object created for this animation
  10003. */
  10004. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  10005. /**
  10006. * Will start the animation sequence of a given target and its hierarchy
  10007. * @param target defines the target
  10008. * @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.
  10009. * @param from defines from which frame should animation start
  10010. * @param to defines until which frame should animation run.
  10011. * @param loop defines if the animation loops
  10012. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  10013. * @param onAnimationEnd defines the function to be executed when the animation ends
  10014. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  10015. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  10016. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  10017. * @param onAnimationLoop defines the callback to call when an animation loops
  10018. * @returns the list of created animatables
  10019. */
  10020. 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[];
  10021. /**
  10022. * Begin a new animation on a given node
  10023. * @param target defines the target where the animation will take place
  10024. * @param animations defines the list of animations to start
  10025. * @param from defines the initial value
  10026. * @param to defines the final value
  10027. * @param loop defines if you want animation to loop (off by default)
  10028. * @param speedRatio defines the speed ratio to apply to all animations
  10029. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  10030. * @param onAnimationLoop defines the callback to call when an animation loops
  10031. * @returns the list of created animatables
  10032. */
  10033. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  10034. /**
  10035. * Begin a new animation on a given node and its hierarchy
  10036. * @param target defines the root node where the animation will take place
  10037. * @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.
  10038. * @param animations defines the list of animations to start
  10039. * @param from defines the initial value
  10040. * @param to defines the final value
  10041. * @param loop defines if you want animation to loop (off by default)
  10042. * @param speedRatio defines the speed ratio to apply to all animations
  10043. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  10044. * @param onAnimationLoop defines the callback to call when an animation loops
  10045. * @returns the list of animatables created for all nodes
  10046. */
  10047. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  10048. /**
  10049. * Gets the animatable associated with a specific target
  10050. * @param target defines the target of the animatable
  10051. * @returns the required animatable if found
  10052. */
  10053. getAnimatableByTarget(target: any): Nullable<Animatable>;
  10054. /**
  10055. * Gets all animatables associated with a given target
  10056. * @param target defines the target to look animatables for
  10057. * @returns an array of Animatables
  10058. */
  10059. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  10060. /**
  10061. * Stops and removes all animations that have been applied to the scene
  10062. */
  10063. stopAllAnimations(): void;
  10064. }
  10065. }
  10066. module "babylonjs/Bones/bone" {
  10067. interface Bone {
  10068. /**
  10069. * Copy an animation range from another bone
  10070. * @param source defines the source bone
  10071. * @param rangeName defines the range name to copy
  10072. * @param frameOffset defines the frame offset
  10073. * @param rescaleAsRequired defines if rescaling must be applied if required
  10074. * @param skelDimensionsRatio defines the scaling ratio
  10075. * @returns true if operation was successful
  10076. */
  10077. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  10078. }
  10079. }
  10080. }
  10081. declare module "babylonjs/Bones/skeleton" {
  10082. import { Bone } from "babylonjs/Bones/bone";
  10083. import { IAnimatable } from "babylonjs/Misc/tools";
  10084. import { Observable } from "babylonjs/Misc/observable";
  10085. import { Vector3, Matrix } from "babylonjs/Maths/math";
  10086. import { Scene } from "babylonjs/scene";
  10087. import { Nullable } from "babylonjs/types";
  10088. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10089. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  10090. import { Animatable } from "babylonjs/Animations/animatable";
  10091. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  10092. import { Animation } from "babylonjs/Animations/animation";
  10093. import { AnimationRange } from "babylonjs/Animations/animationRange";
  10094. import { IInspectable } from "babylonjs/Misc/iInspectable";
  10095. /**
  10096. * Class used to handle skinning animations
  10097. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  10098. */
  10099. export class Skeleton implements IAnimatable {
  10100. /** defines the skeleton name */
  10101. name: string;
  10102. /** defines the skeleton Id */
  10103. id: string;
  10104. /**
  10105. * Defines the list of child bones
  10106. */
  10107. bones: Bone[];
  10108. /**
  10109. * Defines an estimate of the dimension of the skeleton at rest
  10110. */
  10111. dimensionsAtRest: Vector3;
  10112. /**
  10113. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  10114. */
  10115. needInitialSkinMatrix: boolean;
  10116. /**
  10117. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  10118. */
  10119. overrideMesh: Nullable<AbstractMesh>;
  10120. /**
  10121. * Gets the list of animations attached to this skeleton
  10122. */
  10123. animations: Array<Animation>;
  10124. private _scene;
  10125. private _isDirty;
  10126. private _transformMatrices;
  10127. private _transformMatrixTexture;
  10128. private _meshesWithPoseMatrix;
  10129. private _animatables;
  10130. private _identity;
  10131. private _synchronizedWithMesh;
  10132. private _ranges;
  10133. private _lastAbsoluteTransformsUpdateId;
  10134. private _canUseTextureForBones;
  10135. private _uniqueId;
  10136. /** @hidden */
  10137. _numBonesWithLinkedTransformNode: number;
  10138. /** @hidden */
  10139. _hasWaitingData: Nullable<boolean>;
  10140. /**
  10141. * Specifies if the skeleton should be serialized
  10142. */
  10143. doNotSerialize: boolean;
  10144. private _useTextureToStoreBoneMatrices;
  10145. /**
  10146. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  10147. * Please note that this option is not available if the hardware does not support it
  10148. */
  10149. useTextureToStoreBoneMatrices: boolean;
  10150. private _animationPropertiesOverride;
  10151. /**
  10152. * Gets or sets the animation properties override
  10153. */
  10154. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10155. /**
  10156. * List of inspectable custom properties (used by the Inspector)
  10157. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  10158. */
  10159. inspectableCustomProperties: IInspectable[];
  10160. /**
  10161. * An observable triggered before computing the skeleton's matrices
  10162. */
  10163. onBeforeComputeObservable: Observable<Skeleton>;
  10164. /**
  10165. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  10166. */
  10167. readonly isUsingTextureForMatrices: boolean;
  10168. /**
  10169. * Gets the unique ID of this skeleton
  10170. */
  10171. readonly uniqueId: number;
  10172. /**
  10173. * Creates a new skeleton
  10174. * @param name defines the skeleton name
  10175. * @param id defines the skeleton Id
  10176. * @param scene defines the hosting scene
  10177. */
  10178. constructor(
  10179. /** defines the skeleton name */
  10180. name: string,
  10181. /** defines the skeleton Id */
  10182. id: string, scene: Scene);
  10183. /**
  10184. * Gets the current object class name.
  10185. * @return the class name
  10186. */
  10187. getClassName(): string;
  10188. /**
  10189. * Returns an array containing the root bones
  10190. * @returns an array containing the root bones
  10191. */
  10192. getChildren(): Array<Bone>;
  10193. /**
  10194. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  10195. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  10196. * @returns a Float32Array containing matrices data
  10197. */
  10198. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  10199. /**
  10200. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  10201. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  10202. * @returns a raw texture containing the data
  10203. */
  10204. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  10205. /**
  10206. * Gets the current hosting scene
  10207. * @returns a scene object
  10208. */
  10209. getScene(): Scene;
  10210. /**
  10211. * Gets a string representing the current skeleton data
  10212. * @param fullDetails defines a boolean indicating if we want a verbose version
  10213. * @returns a string representing the current skeleton data
  10214. */
  10215. toString(fullDetails?: boolean): string;
  10216. /**
  10217. * Get bone's index searching by name
  10218. * @param name defines bone's name to search for
  10219. * @return the indice of the bone. Returns -1 if not found
  10220. */
  10221. getBoneIndexByName(name: string): number;
  10222. /**
  10223. * Creater a new animation range
  10224. * @param name defines the name of the range
  10225. * @param from defines the start key
  10226. * @param to defines the end key
  10227. */
  10228. createAnimationRange(name: string, from: number, to: number): void;
  10229. /**
  10230. * Delete a specific animation range
  10231. * @param name defines the name of the range
  10232. * @param deleteFrames defines if frames must be removed as well
  10233. */
  10234. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  10235. /**
  10236. * Gets a specific animation range
  10237. * @param name defines the name of the range to look for
  10238. * @returns the requested animation range or null if not found
  10239. */
  10240. getAnimationRange(name: string): Nullable<AnimationRange>;
  10241. /**
  10242. * Gets the list of all animation ranges defined on this skeleton
  10243. * @returns an array
  10244. */
  10245. getAnimationRanges(): Nullable<AnimationRange>[];
  10246. /**
  10247. * Copy animation range from a source skeleton.
  10248. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  10249. * @param source defines the source skeleton
  10250. * @param name defines the name of the range to copy
  10251. * @param rescaleAsRequired defines if rescaling must be applied if required
  10252. * @returns true if operation was successful
  10253. */
  10254. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  10255. /**
  10256. * Forces the skeleton to go to rest pose
  10257. */
  10258. returnToRest(): void;
  10259. private _getHighestAnimationFrame;
  10260. /**
  10261. * Begin a specific animation range
  10262. * @param name defines the name of the range to start
  10263. * @param loop defines if looping must be turned on (false by default)
  10264. * @param speedRatio defines the speed ratio to apply (1 by default)
  10265. * @param onAnimationEnd defines a callback which will be called when animation will end
  10266. * @returns a new animatable
  10267. */
  10268. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  10269. /** @hidden */
  10270. _markAsDirty(): void;
  10271. /** @hidden */
  10272. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10273. /** @hidden */
  10274. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  10275. private _computeTransformMatrices;
  10276. /**
  10277. * Build all resources required to render a skeleton
  10278. */
  10279. prepare(): void;
  10280. /**
  10281. * Gets the list of animatables currently running for this skeleton
  10282. * @returns an array of animatables
  10283. */
  10284. getAnimatables(): IAnimatable[];
  10285. /**
  10286. * Clone the current skeleton
  10287. * @param name defines the name of the new skeleton
  10288. * @param id defines the id of the new skeleton
  10289. * @returns the new skeleton
  10290. */
  10291. clone(name: string, id: string): Skeleton;
  10292. /**
  10293. * Enable animation blending for this skeleton
  10294. * @param blendingSpeed defines the blending speed to apply
  10295. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  10296. */
  10297. enableBlending(blendingSpeed?: number): void;
  10298. /**
  10299. * Releases all resources associated with the current skeleton
  10300. */
  10301. dispose(): void;
  10302. /**
  10303. * Serialize the skeleton in a JSON object
  10304. * @returns a JSON object
  10305. */
  10306. serialize(): any;
  10307. /**
  10308. * Creates a new skeleton from serialized data
  10309. * @param parsedSkeleton defines the serialized data
  10310. * @param scene defines the hosting scene
  10311. * @returns a new skeleton
  10312. */
  10313. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  10314. /**
  10315. * Compute all node absolute transforms
  10316. * @param forceUpdate defines if computation must be done even if cache is up to date
  10317. */
  10318. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  10319. /**
  10320. * Gets the root pose matrix
  10321. * @returns a matrix
  10322. */
  10323. getPoseMatrix(): Nullable<Matrix>;
  10324. /**
  10325. * Sorts bones per internal index
  10326. */
  10327. sortBones(): void;
  10328. private _sortBones;
  10329. }
  10330. }
  10331. declare module "babylonjs/Morph/morphTarget" {
  10332. import { IAnimatable } from "babylonjs/Misc/tools";
  10333. import { Observable } from "babylonjs/Misc/observable";
  10334. import { Nullable, FloatArray } from "babylonjs/types";
  10335. import { Scene } from "babylonjs/scene";
  10336. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10337. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  10338. /**
  10339. * Defines a target to use with MorphTargetManager
  10340. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10341. */
  10342. export class MorphTarget implements IAnimatable {
  10343. /** defines the name of the target */
  10344. name: string;
  10345. /**
  10346. * Gets or sets the list of animations
  10347. */
  10348. animations: import("babylonjs/Animations/animation").Animation[];
  10349. private _scene;
  10350. private _positions;
  10351. private _normals;
  10352. private _tangents;
  10353. private _uvs;
  10354. private _influence;
  10355. /**
  10356. * Observable raised when the influence changes
  10357. */
  10358. onInfluenceChanged: Observable<boolean>;
  10359. /** @hidden */
  10360. _onDataLayoutChanged: Observable<void>;
  10361. /**
  10362. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  10363. */
  10364. influence: number;
  10365. /**
  10366. * Gets or sets the id of the morph Target
  10367. */
  10368. id: string;
  10369. private _animationPropertiesOverride;
  10370. /**
  10371. * Gets or sets the animation properties override
  10372. */
  10373. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  10374. /**
  10375. * Creates a new MorphTarget
  10376. * @param name defines the name of the target
  10377. * @param influence defines the influence to use
  10378. * @param scene defines the scene the morphtarget belongs to
  10379. */
  10380. constructor(
  10381. /** defines the name of the target */
  10382. name: string, influence?: number, scene?: Nullable<Scene>);
  10383. /**
  10384. * Gets a boolean defining if the target contains position data
  10385. */
  10386. readonly hasPositions: boolean;
  10387. /**
  10388. * Gets a boolean defining if the target contains normal data
  10389. */
  10390. readonly hasNormals: boolean;
  10391. /**
  10392. * Gets a boolean defining if the target contains tangent data
  10393. */
  10394. readonly hasTangents: boolean;
  10395. /**
  10396. * Gets a boolean defining if the target contains texture coordinates data
  10397. */
  10398. readonly hasUVs: boolean;
  10399. /**
  10400. * Affects position data to this target
  10401. * @param data defines the position data to use
  10402. */
  10403. setPositions(data: Nullable<FloatArray>): void;
  10404. /**
  10405. * Gets the position data stored in this target
  10406. * @returns a FloatArray containing the position data (or null if not present)
  10407. */
  10408. getPositions(): Nullable<FloatArray>;
  10409. /**
  10410. * Affects normal data to this target
  10411. * @param data defines the normal data to use
  10412. */
  10413. setNormals(data: Nullable<FloatArray>): void;
  10414. /**
  10415. * Gets the normal data stored in this target
  10416. * @returns a FloatArray containing the normal data (or null if not present)
  10417. */
  10418. getNormals(): Nullable<FloatArray>;
  10419. /**
  10420. * Affects tangent data to this target
  10421. * @param data defines the tangent data to use
  10422. */
  10423. setTangents(data: Nullable<FloatArray>): void;
  10424. /**
  10425. * Gets the tangent data stored in this target
  10426. * @returns a FloatArray containing the tangent data (or null if not present)
  10427. */
  10428. getTangents(): Nullable<FloatArray>;
  10429. /**
  10430. * Affects texture coordinates data to this target
  10431. * @param data defines the texture coordinates data to use
  10432. */
  10433. setUVs(data: Nullable<FloatArray>): void;
  10434. /**
  10435. * Gets the texture coordinates data stored in this target
  10436. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  10437. */
  10438. getUVs(): Nullable<FloatArray>;
  10439. /**
  10440. * Serializes the current target into a Serialization object
  10441. * @returns the serialized object
  10442. */
  10443. serialize(): any;
  10444. /**
  10445. * Returns the string "MorphTarget"
  10446. * @returns "MorphTarget"
  10447. */
  10448. getClassName(): string;
  10449. /**
  10450. * Creates a new target from serialized data
  10451. * @param serializationObject defines the serialized data to use
  10452. * @returns a new MorphTarget
  10453. */
  10454. static Parse(serializationObject: any): MorphTarget;
  10455. /**
  10456. * Creates a MorphTarget from mesh data
  10457. * @param mesh defines the source mesh
  10458. * @param name defines the name to use for the new target
  10459. * @param influence defines the influence to attach to the target
  10460. * @returns a new MorphTarget
  10461. */
  10462. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  10463. }
  10464. }
  10465. declare module "babylonjs/Morph/morphTargetManager" {
  10466. import { Nullable } from "babylonjs/types";
  10467. import { Scene } from "babylonjs/scene";
  10468. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  10469. /**
  10470. * This class is used to deform meshes using morphing between different targets
  10471. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  10472. */
  10473. export class MorphTargetManager {
  10474. private _targets;
  10475. private _targetInfluenceChangedObservers;
  10476. private _targetDataLayoutChangedObservers;
  10477. private _activeTargets;
  10478. private _scene;
  10479. private _influences;
  10480. private _supportsNormals;
  10481. private _supportsTangents;
  10482. private _supportsUVs;
  10483. private _vertexCount;
  10484. private _uniqueId;
  10485. private _tempInfluences;
  10486. /**
  10487. * Gets or sets a boolean indicating if normals must be morphed
  10488. */
  10489. enableNormalMorphing: boolean;
  10490. /**
  10491. * Gets or sets a boolean indicating if tangents must be morphed
  10492. */
  10493. enableTangentMorphing: boolean;
  10494. /**
  10495. * Gets or sets a boolean indicating if UV must be morphed
  10496. */
  10497. enableUVMorphing: boolean;
  10498. /**
  10499. * Creates a new MorphTargetManager
  10500. * @param scene defines the current scene
  10501. */
  10502. constructor(scene?: Nullable<Scene>);
  10503. /**
  10504. * Gets the unique ID of this manager
  10505. */
  10506. readonly uniqueId: number;
  10507. /**
  10508. * Gets the number of vertices handled by this manager
  10509. */
  10510. readonly vertexCount: number;
  10511. /**
  10512. * Gets a boolean indicating if this manager supports morphing of normals
  10513. */
  10514. readonly supportsNormals: boolean;
  10515. /**
  10516. * Gets a boolean indicating if this manager supports morphing of tangents
  10517. */
  10518. readonly supportsTangents: boolean;
  10519. /**
  10520. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  10521. */
  10522. readonly supportsUVs: boolean;
  10523. /**
  10524. * Gets the number of targets stored in this manager
  10525. */
  10526. readonly numTargets: number;
  10527. /**
  10528. * Gets the number of influencers (ie. the number of targets with influences > 0)
  10529. */
  10530. readonly numInfluencers: number;
  10531. /**
  10532. * Gets the list of influences (one per target)
  10533. */
  10534. readonly influences: Float32Array;
  10535. /**
  10536. * Gets the active target at specified index. An active target is a target with an influence > 0
  10537. * @param index defines the index to check
  10538. * @returns the requested target
  10539. */
  10540. getActiveTarget(index: number): MorphTarget;
  10541. /**
  10542. * Gets the target at specified index
  10543. * @param index defines the index to check
  10544. * @returns the requested target
  10545. */
  10546. getTarget(index: number): MorphTarget;
  10547. /**
  10548. * Add a new target to this manager
  10549. * @param target defines the target to add
  10550. */
  10551. addTarget(target: MorphTarget): void;
  10552. /**
  10553. * Removes a target from the manager
  10554. * @param target defines the target to remove
  10555. */
  10556. removeTarget(target: MorphTarget): void;
  10557. /**
  10558. * Serializes the current manager into a Serialization object
  10559. * @returns the serialized object
  10560. */
  10561. serialize(): any;
  10562. private _syncActiveTargets;
  10563. /**
  10564. * Syncrhonize the targets with all the meshes using this morph target manager
  10565. */
  10566. synchronize(): void;
  10567. /**
  10568. * Creates a new MorphTargetManager from serialized data
  10569. * @param serializationObject defines the serialized data
  10570. * @param scene defines the hosting scene
  10571. * @returns the new MorphTargetManager
  10572. */
  10573. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  10574. }
  10575. }
  10576. declare module "babylonjs/sceneComponent" {
  10577. import { Scene } from "babylonjs/scene";
  10578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10579. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10580. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10581. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10582. import { Nullable } from "babylonjs/types";
  10583. import { Camera } from "babylonjs/Cameras/camera";
  10584. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10585. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10586. import { AbstractScene } from "babylonjs/abstractScene";
  10587. /**
  10588. * Groups all the scene component constants in one place to ease maintenance.
  10589. * @hidden
  10590. */
  10591. export class SceneComponentConstants {
  10592. static readonly NAME_EFFECTLAYER: string;
  10593. static readonly NAME_LAYER: string;
  10594. static readonly NAME_LENSFLARESYSTEM: string;
  10595. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10596. static readonly NAME_PARTICLESYSTEM: string;
  10597. static readonly NAME_GAMEPAD: string;
  10598. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10599. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10600. static readonly NAME_DEPTHRENDERER: string;
  10601. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10602. static readonly NAME_SPRITE: string;
  10603. static readonly NAME_OUTLINERENDERER: string;
  10604. static readonly NAME_PROCEDURALTEXTURE: string;
  10605. static readonly NAME_SHADOWGENERATOR: string;
  10606. static readonly NAME_OCTREE: string;
  10607. static readonly NAME_PHYSICSENGINE: string;
  10608. static readonly NAME_AUDIO: string;
  10609. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10610. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10611. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10612. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10613. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10614. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10615. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10616. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10617. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10618. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10619. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10620. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10621. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10622. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10623. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10624. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10625. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10626. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10627. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10628. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10629. static readonly STEP_AFTERRENDER_AUDIO: number;
  10630. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10631. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10632. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10633. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10634. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10635. static readonly STEP_POINTERMOVE_SPRITE: number;
  10636. static readonly STEP_POINTERDOWN_SPRITE: number;
  10637. static readonly STEP_POINTERUP_SPRITE: number;
  10638. }
  10639. /**
  10640. * This represents a scene component.
  10641. *
  10642. * This is used to decouple the dependency the scene is having on the different workloads like
  10643. * layers, post processes...
  10644. */
  10645. export interface ISceneComponent {
  10646. /**
  10647. * The name of the component. Each component must have a unique name.
  10648. */
  10649. name: string;
  10650. /**
  10651. * The scene the component belongs to.
  10652. */
  10653. scene: Scene;
  10654. /**
  10655. * Register the component to one instance of a scene.
  10656. */
  10657. register(): void;
  10658. /**
  10659. * Rebuilds the elements related to this component in case of
  10660. * context lost for instance.
  10661. */
  10662. rebuild(): void;
  10663. /**
  10664. * Disposes the component and the associated ressources.
  10665. */
  10666. dispose(): void;
  10667. }
  10668. /**
  10669. * This represents a SERIALIZABLE scene component.
  10670. *
  10671. * This extends Scene Component to add Serialization methods on top.
  10672. */
  10673. export interface ISceneSerializableComponent extends ISceneComponent {
  10674. /**
  10675. * Adds all the elements from the container to the scene
  10676. * @param container the container holding the elements
  10677. */
  10678. addFromContainer(container: AbstractScene): void;
  10679. /**
  10680. * Removes all the elements in the container from the scene
  10681. * @param container contains the elements to remove
  10682. * @param dispose if the removed element should be disposed (default: false)
  10683. */
  10684. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10685. /**
  10686. * Serializes the component data to the specified json object
  10687. * @param serializationObject The object to serialize to
  10688. */
  10689. serialize(serializationObject: any): void;
  10690. }
  10691. /**
  10692. * Strong typing of a Mesh related stage step action
  10693. */
  10694. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10695. /**
  10696. * Strong typing of a Evaluate Sub Mesh related stage step action
  10697. */
  10698. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10699. /**
  10700. * Strong typing of a Active Mesh related stage step action
  10701. */
  10702. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10703. /**
  10704. * Strong typing of a Camera related stage step action
  10705. */
  10706. export type CameraStageAction = (camera: Camera) => void;
  10707. /**
  10708. * Strong typing of a Camera Frame buffer related stage step action
  10709. */
  10710. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10711. /**
  10712. * Strong typing of a Render Target related stage step action
  10713. */
  10714. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10715. /**
  10716. * Strong typing of a RenderingGroup related stage step action
  10717. */
  10718. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10719. /**
  10720. * Strong typing of a Mesh Render related stage step action
  10721. */
  10722. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10723. /**
  10724. * Strong typing of a simple stage step action
  10725. */
  10726. export type SimpleStageAction = () => void;
  10727. /**
  10728. * Strong typing of a render target action.
  10729. */
  10730. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10731. /**
  10732. * Strong typing of a pointer move action.
  10733. */
  10734. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  10735. /**
  10736. * Strong typing of a pointer up/down action.
  10737. */
  10738. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10739. /**
  10740. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  10741. * @hidden
  10742. */
  10743. export class Stage<T extends Function> extends Array<{
  10744. index: number;
  10745. component: ISceneComponent;
  10746. action: T;
  10747. }> {
  10748. /**
  10749. * Hide ctor from the rest of the world.
  10750. * @param items The items to add.
  10751. */
  10752. private constructor();
  10753. /**
  10754. * Creates a new Stage.
  10755. * @returns A new instance of a Stage
  10756. */
  10757. static Create<T extends Function>(): Stage<T>;
  10758. /**
  10759. * Registers a step in an ordered way in the targeted stage.
  10760. * @param index Defines the position to register the step in
  10761. * @param component Defines the component attached to the step
  10762. * @param action Defines the action to launch during the step
  10763. */
  10764. registerStep(index: number, component: ISceneComponent, action: T): void;
  10765. /**
  10766. * Clears all the steps from the stage.
  10767. */
  10768. clear(): void;
  10769. }
  10770. }
  10771. declare module "babylonjs/Meshes/meshLODLevel" {
  10772. import { Mesh } from "babylonjs/Meshes/mesh";
  10773. import { Nullable } from "babylonjs/types";
  10774. /**
  10775. * Class used to represent a specific level of detail of a mesh
  10776. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  10777. */
  10778. export class MeshLODLevel {
  10779. /** Defines the distance where this level should star being displayed */
  10780. distance: number;
  10781. /** Defines the mesh to use to render this level */
  10782. mesh: Nullable<Mesh>;
  10783. /**
  10784. * Creates a new LOD level
  10785. * @param distance defines the distance where this level should star being displayed
  10786. * @param mesh defines the mesh to use to render this level
  10787. */
  10788. constructor(
  10789. /** Defines the distance where this level should star being displayed */
  10790. distance: number,
  10791. /** Defines the mesh to use to render this level */
  10792. mesh: Nullable<Mesh>);
  10793. }
  10794. }
  10795. declare module "babylonjs/Lights/shadowLight" {
  10796. import { Camera } from "babylonjs/Cameras/camera";
  10797. import { Scene } from "babylonjs/scene";
  10798. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  10799. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10800. import { Light } from "babylonjs/Lights/light";
  10801. /**
  10802. * Interface describing all the common properties and methods a shadow light needs to implement.
  10803. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  10804. * as well as binding the different shadow properties to the effects.
  10805. */
  10806. export interface IShadowLight extends Light {
  10807. /**
  10808. * The light id in the scene (used in scene.findLighById for instance)
  10809. */
  10810. id: string;
  10811. /**
  10812. * The position the shdow will be casted from.
  10813. */
  10814. position: Vector3;
  10815. /**
  10816. * In 2d mode (needCube being false), the direction used to cast the shadow.
  10817. */
  10818. direction: Vector3;
  10819. /**
  10820. * The transformed position. Position of the light in world space taking parenting in account.
  10821. */
  10822. transformedPosition: Vector3;
  10823. /**
  10824. * The transformed direction. Direction of the light in world space taking parenting in account.
  10825. */
  10826. transformedDirection: Vector3;
  10827. /**
  10828. * The friendly name of the light in the scene.
  10829. */
  10830. name: string;
  10831. /**
  10832. * Defines the shadow projection clipping minimum z value.
  10833. */
  10834. shadowMinZ: number;
  10835. /**
  10836. * Defines the shadow projection clipping maximum z value.
  10837. */
  10838. shadowMaxZ: number;
  10839. /**
  10840. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10841. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10842. */
  10843. computeTransformedInformation(): boolean;
  10844. /**
  10845. * Gets the scene the light belongs to.
  10846. * @returns The scene
  10847. */
  10848. getScene(): Scene;
  10849. /**
  10850. * Callback defining a custom Projection Matrix Builder.
  10851. * This can be used to override the default projection matrix computation.
  10852. */
  10853. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10854. /**
  10855. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  10856. * @param matrix The materix to updated with the projection information
  10857. * @param viewMatrix The transform matrix of the light
  10858. * @param renderList The list of mesh to render in the map
  10859. * @returns The current light
  10860. */
  10861. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  10862. /**
  10863. * Gets the current depth scale used in ESM.
  10864. * @returns The scale
  10865. */
  10866. getDepthScale(): number;
  10867. /**
  10868. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10869. * @returns true if a cube texture needs to be use
  10870. */
  10871. needCube(): boolean;
  10872. /**
  10873. * Detects if the projection matrix requires to be recomputed this frame.
  10874. * @returns true if it requires to be recomputed otherwise, false.
  10875. */
  10876. needProjectionMatrixCompute(): boolean;
  10877. /**
  10878. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  10879. */
  10880. forceProjectionMatrixCompute(): void;
  10881. /**
  10882. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10883. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10884. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10885. */
  10886. getShadowDirection(faceIndex?: number): Vector3;
  10887. /**
  10888. * Gets the minZ used for shadow according to both the scene and the light.
  10889. * @param activeCamera The camera we are returning the min for
  10890. * @returns the depth min z
  10891. */
  10892. getDepthMinZ(activeCamera: Camera): number;
  10893. /**
  10894. * Gets the maxZ used for shadow according to both the scene and the light.
  10895. * @param activeCamera The camera we are returning the max for
  10896. * @returns the depth max z
  10897. */
  10898. getDepthMaxZ(activeCamera: Camera): number;
  10899. }
  10900. /**
  10901. * Base implementation IShadowLight
  10902. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  10903. */
  10904. export abstract class ShadowLight extends Light implements IShadowLight {
  10905. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  10906. protected _position: Vector3;
  10907. protected _setPosition(value: Vector3): void;
  10908. /**
  10909. * Sets the position the shadow will be casted from. Also use as the light position for both
  10910. * point and spot lights.
  10911. */
  10912. /**
  10913. * Sets the position the shadow will be casted from. Also use as the light position for both
  10914. * point and spot lights.
  10915. */
  10916. position: Vector3;
  10917. protected _direction: Vector3;
  10918. protected _setDirection(value: Vector3): void;
  10919. /**
  10920. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  10921. * Also use as the light direction on spot and directional lights.
  10922. */
  10923. /**
  10924. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  10925. * Also use as the light direction on spot and directional lights.
  10926. */
  10927. direction: Vector3;
  10928. private _shadowMinZ;
  10929. /**
  10930. * Gets the shadow projection clipping minimum z value.
  10931. */
  10932. /**
  10933. * Sets the shadow projection clipping minimum z value.
  10934. */
  10935. shadowMinZ: number;
  10936. private _shadowMaxZ;
  10937. /**
  10938. * Sets the shadow projection clipping maximum z value.
  10939. */
  10940. /**
  10941. * Gets the shadow projection clipping maximum z value.
  10942. */
  10943. shadowMaxZ: number;
  10944. /**
  10945. * Callback defining a custom Projection Matrix Builder.
  10946. * This can be used to override the default projection matrix computation.
  10947. */
  10948. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  10949. /**
  10950. * The transformed position. Position of the light in world space taking parenting in account.
  10951. */
  10952. transformedPosition: Vector3;
  10953. /**
  10954. * The transformed direction. Direction of the light in world space taking parenting in account.
  10955. */
  10956. transformedDirection: Vector3;
  10957. private _needProjectionMatrixCompute;
  10958. /**
  10959. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  10960. * @returns true if the information has been computed, false if it does not need to (no parenting)
  10961. */
  10962. computeTransformedInformation(): boolean;
  10963. /**
  10964. * Return the depth scale used for the shadow map.
  10965. * @returns the depth scale.
  10966. */
  10967. getDepthScale(): number;
  10968. /**
  10969. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  10970. * @param faceIndex The index of the face we are computed the direction to generate shadow
  10971. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  10972. */
  10973. getShadowDirection(faceIndex?: number): Vector3;
  10974. /**
  10975. * Returns the ShadowLight absolute position in the World.
  10976. * @returns the position vector in world space
  10977. */
  10978. getAbsolutePosition(): Vector3;
  10979. /**
  10980. * Sets the ShadowLight direction toward the passed target.
  10981. * @param target The point to target in local space
  10982. * @returns the updated ShadowLight direction
  10983. */
  10984. setDirectionToTarget(target: Vector3): Vector3;
  10985. /**
  10986. * Returns the light rotation in euler definition.
  10987. * @returns the x y z rotation in local space.
  10988. */
  10989. getRotation(): Vector3;
  10990. /**
  10991. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  10992. * @returns true if a cube texture needs to be use
  10993. */
  10994. needCube(): boolean;
  10995. /**
  10996. * Detects if the projection matrix requires to be recomputed this frame.
  10997. * @returns true if it requires to be recomputed otherwise, false.
  10998. */
  10999. needProjectionMatrixCompute(): boolean;
  11000. /**
  11001. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  11002. */
  11003. forceProjectionMatrixCompute(): void;
  11004. /** @hidden */
  11005. _initCache(): void;
  11006. /** @hidden */
  11007. _isSynchronized(): boolean;
  11008. /**
  11009. * Computes the world matrix of the node
  11010. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  11011. * @returns the world matrix
  11012. */
  11013. computeWorldMatrix(force?: boolean): Matrix;
  11014. /**
  11015. * Gets the minZ used for shadow according to both the scene and the light.
  11016. * @param activeCamera The camera we are returning the min for
  11017. * @returns the depth min z
  11018. */
  11019. getDepthMinZ(activeCamera: Camera): number;
  11020. /**
  11021. * Gets the maxZ used for shadow according to both the scene and the light.
  11022. * @param activeCamera The camera we are returning the max for
  11023. * @returns the depth max z
  11024. */
  11025. getDepthMaxZ(activeCamera: Camera): number;
  11026. /**
  11027. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  11028. * @param matrix The materix to updated with the projection information
  11029. * @param viewMatrix The transform matrix of the light
  11030. * @param renderList The list of mesh to render in the map
  11031. * @returns The current light
  11032. */
  11033. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  11034. }
  11035. }
  11036. declare module "babylonjs/Materials/materialHelper" {
  11037. import { Nullable } from "babylonjs/types";
  11038. import { Scene } from "babylonjs/scene";
  11039. import { Engine } from "babylonjs/Engines/engine";
  11040. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11041. import { Light } from "babylonjs/Lights/light";
  11042. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  11043. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  11044. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  11045. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  11046. /**
  11047. * "Static Class" containing the most commonly used helper while dealing with material for
  11048. * rendering purpose.
  11049. *
  11050. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  11051. *
  11052. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  11053. */
  11054. export class MaterialHelper {
  11055. /**
  11056. * Bind the current view position to an effect.
  11057. * @param effect The effect to be bound
  11058. * @param scene The scene the eyes position is used from
  11059. */
  11060. static BindEyePosition(effect: Effect, scene: Scene): void;
  11061. /**
  11062. * Helps preparing the defines values about the UVs in used in the effect.
  11063. * UVs are shared as much as we can accross channels in the shaders.
  11064. * @param texture The texture we are preparing the UVs for
  11065. * @param defines The defines to update
  11066. * @param key The channel key "diffuse", "specular"... used in the shader
  11067. */
  11068. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  11069. /**
  11070. * Binds a texture matrix value to its corrsponding uniform
  11071. * @param texture The texture to bind the matrix for
  11072. * @param uniformBuffer The uniform buffer receivin the data
  11073. * @param key The channel key "diffuse", "specular"... used in the shader
  11074. */
  11075. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  11076. /**
  11077. * Gets the current status of the fog (should it be enabled?)
  11078. * @param mesh defines the mesh to evaluate for fog support
  11079. * @param scene defines the hosting scene
  11080. * @returns true if fog must be enabled
  11081. */
  11082. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  11083. /**
  11084. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  11085. * @param mesh defines the current mesh
  11086. * @param scene defines the current scene
  11087. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  11088. * @param pointsCloud defines if point cloud rendering has to be turned on
  11089. * @param fogEnabled defines if fog has to be turned on
  11090. * @param alphaTest defines if alpha testing has to be turned on
  11091. * @param defines defines the current list of defines
  11092. */
  11093. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  11094. /**
  11095. * Helper used to prepare the list of defines associated with frame values for shader compilation
  11096. * @param scene defines the current scene
  11097. * @param engine defines the current engine
  11098. * @param defines specifies the list of active defines
  11099. * @param useInstances defines if instances have to be turned on
  11100. * @param useClipPlane defines if clip plane have to be turned on
  11101. */
  11102. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  11103. /**
  11104. * Prepares the defines for bones
  11105. * @param mesh The mesh containing the geometry data we will draw
  11106. * @param defines The defines to update
  11107. */
  11108. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  11109. /**
  11110. * Prepares the defines for morph targets
  11111. * @param mesh The mesh containing the geometry data we will draw
  11112. * @param defines The defines to update
  11113. */
  11114. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  11115. /**
  11116. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  11117. * @param mesh The mesh containing the geometry data we will draw
  11118. * @param defines The defines to update
  11119. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  11120. * @param useBones Precise whether bones should be used or not (override mesh info)
  11121. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  11122. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  11123. * @returns false if defines are considered not dirty and have not been checked
  11124. */
  11125. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  11126. /**
  11127. * Prepares the defines related to multiview
  11128. * @param scene The scene we are intending to draw
  11129. * @param defines The defines to update
  11130. */
  11131. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  11132. /**
  11133. * Prepares the defines related to the light information passed in parameter
  11134. * @param scene The scene we are intending to draw
  11135. * @param mesh The mesh the effect is compiling for
  11136. * @param light The light the effect is compiling for
  11137. * @param lightIndex The index of the light
  11138. * @param defines The defines to update
  11139. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  11140. * @param state Defines the current state regarding what is needed (normals, etc...)
  11141. */
  11142. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  11143. needNormals: boolean;
  11144. needRebuild: boolean;
  11145. shadowEnabled: boolean;
  11146. specularEnabled: boolean;
  11147. lightmapMode: boolean;
  11148. }): void;
  11149. /**
  11150. * Prepares the defines related to the light information passed in parameter
  11151. * @param scene The scene we are intending to draw
  11152. * @param mesh The mesh the effect is compiling for
  11153. * @param defines The defines to update
  11154. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  11155. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  11156. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  11157. * @returns true if normals will be required for the rest of the effect
  11158. */
  11159. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  11160. /**
  11161. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  11162. * @param lightIndex defines the light index
  11163. * @param uniformsList The uniform list
  11164. * @param samplersList The sampler list
  11165. * @param projectedLightTexture defines if projected texture must be used
  11166. * @param uniformBuffersList defines an optional list of uniform buffers
  11167. */
  11168. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  11169. /**
  11170. * Prepares the uniforms and samplers list to be used in the effect
  11171. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  11172. * @param samplersList The sampler list
  11173. * @param defines The defines helping in the list generation
  11174. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  11175. */
  11176. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  11177. /**
  11178. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  11179. * @param defines The defines to update while falling back
  11180. * @param fallbacks The authorized effect fallbacks
  11181. * @param maxSimultaneousLights The maximum number of lights allowed
  11182. * @param rank the current rank of the Effect
  11183. * @returns The newly affected rank
  11184. */
  11185. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  11186. private static _TmpMorphInfluencers;
  11187. /**
  11188. * Prepares the list of attributes required for morph targets according to the effect defines.
  11189. * @param attribs The current list of supported attribs
  11190. * @param mesh The mesh to prepare the morph targets attributes for
  11191. * @param influencers The number of influencers
  11192. */
  11193. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  11194. /**
  11195. * Prepares the list of attributes required for morph targets according to the effect defines.
  11196. * @param attribs The current list of supported attribs
  11197. * @param mesh The mesh to prepare the morph targets attributes for
  11198. * @param defines The current Defines of the effect
  11199. */
  11200. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  11201. /**
  11202. * Prepares the list of attributes required for bones according to the effect defines.
  11203. * @param attribs The current list of supported attribs
  11204. * @param mesh The mesh to prepare the bones attributes for
  11205. * @param defines The current Defines of the effect
  11206. * @param fallbacks The current efffect fallback strategy
  11207. */
  11208. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  11209. /**
  11210. * Check and prepare the list of attributes required for instances according to the effect defines.
  11211. * @param attribs The current list of supported attribs
  11212. * @param defines The current MaterialDefines of the effect
  11213. */
  11214. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  11215. /**
  11216. * Add the list of attributes required for instances to the attribs array.
  11217. * @param attribs The current list of supported attribs
  11218. */
  11219. static PushAttributesForInstances(attribs: string[]): void;
  11220. /**
  11221. * Binds the light shadow information to the effect for the given mesh.
  11222. * @param light The light containing the generator
  11223. * @param scene The scene the lights belongs to
  11224. * @param mesh The mesh we are binding the information to render
  11225. * @param lightIndex The light index in the effect used to render the mesh
  11226. * @param effect The effect we are binding the data to
  11227. */
  11228. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  11229. /**
  11230. * Binds the light information to the effect.
  11231. * @param light The light containing the generator
  11232. * @param effect The effect we are binding the data to
  11233. * @param lightIndex The light index in the effect used to render
  11234. */
  11235. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  11236. /**
  11237. * Binds the lights information from the scene to the effect for the given mesh.
  11238. * @param light Light to bind
  11239. * @param lightIndex Light index
  11240. * @param scene The scene where the light belongs to
  11241. * @param mesh The mesh we are binding the information to render
  11242. * @param effect The effect we are binding the data to
  11243. * @param useSpecular Defines if specular is supported
  11244. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  11245. */
  11246. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  11247. /**
  11248. * Binds the lights information from the scene to the effect for the given mesh.
  11249. * @param scene The scene the lights belongs to
  11250. * @param mesh The mesh we are binding the information to render
  11251. * @param effect The effect we are binding the data to
  11252. * @param defines The generated defines for the effect
  11253. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  11254. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  11255. */
  11256. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  11257. private static _tempFogColor;
  11258. /**
  11259. * Binds the fog information from the scene to the effect for the given mesh.
  11260. * @param scene The scene the lights belongs to
  11261. * @param mesh The mesh we are binding the information to render
  11262. * @param effect The effect we are binding the data to
  11263. * @param linearSpace Defines if the fog effect is applied in linear space
  11264. */
  11265. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  11266. /**
  11267. * Binds the bones information from the mesh to the effect.
  11268. * @param mesh The mesh we are binding the information to render
  11269. * @param effect The effect we are binding the data to
  11270. */
  11271. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  11272. /**
  11273. * Binds the morph targets information from the mesh to the effect.
  11274. * @param abstractMesh The mesh we are binding the information to render
  11275. * @param effect The effect we are binding the data to
  11276. */
  11277. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  11278. /**
  11279. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  11280. * @param defines The generated defines used in the effect
  11281. * @param effect The effect we are binding the data to
  11282. * @param scene The scene we are willing to render with logarithmic scale for
  11283. */
  11284. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  11285. /**
  11286. * Binds the clip plane information from the scene to the effect.
  11287. * @param scene The scene the clip plane information are extracted from
  11288. * @param effect The effect we are binding the data to
  11289. */
  11290. static BindClipPlane(effect: Effect, scene: Scene): void;
  11291. }
  11292. }
  11293. declare module "babylonjs/Shaders/shadowMap.fragment" {
  11294. /** @hidden */
  11295. export var shadowMapPixelShader: {
  11296. name: string;
  11297. shader: string;
  11298. };
  11299. }
  11300. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  11301. /** @hidden */
  11302. export var bonesDeclaration: {
  11303. name: string;
  11304. shader: string;
  11305. };
  11306. }
  11307. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  11308. /** @hidden */
  11309. export var morphTargetsVertexGlobalDeclaration: {
  11310. name: string;
  11311. shader: string;
  11312. };
  11313. }
  11314. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  11315. /** @hidden */
  11316. export var morphTargetsVertexDeclaration: {
  11317. name: string;
  11318. shader: string;
  11319. };
  11320. }
  11321. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  11322. /** @hidden */
  11323. export var instancesDeclaration: {
  11324. name: string;
  11325. shader: string;
  11326. };
  11327. }
  11328. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  11329. /** @hidden */
  11330. export var helperFunctions: {
  11331. name: string;
  11332. shader: string;
  11333. };
  11334. }
  11335. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  11336. /** @hidden */
  11337. export var morphTargetsVertex: {
  11338. name: string;
  11339. shader: string;
  11340. };
  11341. }
  11342. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  11343. /** @hidden */
  11344. export var instancesVertex: {
  11345. name: string;
  11346. shader: string;
  11347. };
  11348. }
  11349. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  11350. /** @hidden */
  11351. export var bonesVertex: {
  11352. name: string;
  11353. shader: string;
  11354. };
  11355. }
  11356. declare module "babylonjs/Shaders/shadowMap.vertex" {
  11357. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  11358. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  11359. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  11360. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  11361. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11362. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  11363. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  11364. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  11365. /** @hidden */
  11366. export var shadowMapVertexShader: {
  11367. name: string;
  11368. shader: string;
  11369. };
  11370. }
  11371. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  11372. /** @hidden */
  11373. export var depthBoxBlurPixelShader: {
  11374. name: string;
  11375. shader: string;
  11376. };
  11377. }
  11378. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  11379. import { Nullable } from "babylonjs/types";
  11380. import { Scene } from "babylonjs/scene";
  11381. import { Matrix } from "babylonjs/Maths/math";
  11382. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11383. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11384. import { Mesh } from "babylonjs/Meshes/mesh";
  11385. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  11386. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  11387. import { Effect } from "babylonjs/Materials/effect";
  11388. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11389. import "babylonjs/Shaders/shadowMap.fragment";
  11390. import "babylonjs/Shaders/shadowMap.vertex";
  11391. import "babylonjs/Shaders/depthBoxBlur.fragment";
  11392. import { Observable } from "babylonjs/Misc/observable";
  11393. /**
  11394. * Defines the options associated with the creation of a custom shader for a shadow generator.
  11395. */
  11396. export interface ICustomShaderOptions {
  11397. /**
  11398. * Gets or sets the custom shader name to use
  11399. */
  11400. shaderName: string;
  11401. /**
  11402. * The list of attribute names used in the shader
  11403. */
  11404. attributes?: string[];
  11405. /**
  11406. * The list of unifrom names used in the shader
  11407. */
  11408. uniforms?: string[];
  11409. /**
  11410. * The list of sampler names used in the shader
  11411. */
  11412. samplers?: string[];
  11413. /**
  11414. * The list of defines used in the shader
  11415. */
  11416. defines?: string[];
  11417. }
  11418. /**
  11419. * Interface to implement to create a shadow generator compatible with BJS.
  11420. */
  11421. export interface IShadowGenerator {
  11422. /**
  11423. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11424. * @returns The render target texture if present otherwise, null
  11425. */
  11426. getShadowMap(): Nullable<RenderTargetTexture>;
  11427. /**
  11428. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11429. * @returns The render target texture if the shadow map is present otherwise, null
  11430. */
  11431. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11432. /**
  11433. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11434. * @param subMesh The submesh we want to render in the shadow map
  11435. * @param useInstances Defines wether will draw in the map using instances
  11436. * @returns true if ready otherwise, false
  11437. */
  11438. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11439. /**
  11440. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11441. * @param defines Defines of the material we want to update
  11442. * @param lightIndex Index of the light in the enabled light list of the material
  11443. */
  11444. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  11445. /**
  11446. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11447. * defined in the generator but impacting the effect).
  11448. * It implies the unifroms available on the materials are the standard BJS ones.
  11449. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11450. * @param effect The effect we are binfing the information for
  11451. */
  11452. bindShadowLight(lightIndex: string, effect: Effect): void;
  11453. /**
  11454. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11455. * (eq to shadow prjection matrix * light transform matrix)
  11456. * @returns The transform matrix used to create the shadow map
  11457. */
  11458. getTransformMatrix(): Matrix;
  11459. /**
  11460. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11461. * Cube and 2D textures for instance.
  11462. */
  11463. recreateShadowMap(): void;
  11464. /**
  11465. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11466. * @param onCompiled Callback triggered at the and of the effects compilation
  11467. * @param options Sets of optional options forcing the compilation with different modes
  11468. */
  11469. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11470. useInstances: boolean;
  11471. }>): void;
  11472. /**
  11473. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11474. * @param options Sets of optional options forcing the compilation with different modes
  11475. * @returns A promise that resolves when the compilation completes
  11476. */
  11477. forceCompilationAsync(options?: Partial<{
  11478. useInstances: boolean;
  11479. }>): Promise<void>;
  11480. /**
  11481. * Serializes the shadow generator setup to a json object.
  11482. * @returns The serialized JSON object
  11483. */
  11484. serialize(): any;
  11485. /**
  11486. * Disposes the Shadow map and related Textures and effects.
  11487. */
  11488. dispose(): void;
  11489. }
  11490. /**
  11491. * Default implementation IShadowGenerator.
  11492. * This is the main object responsible of generating shadows in the framework.
  11493. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  11494. */
  11495. export class ShadowGenerator implements IShadowGenerator {
  11496. /**
  11497. * Shadow generator mode None: no filtering applied.
  11498. */
  11499. static readonly FILTER_NONE: number;
  11500. /**
  11501. * Shadow generator mode ESM: Exponential Shadow Mapping.
  11502. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11503. */
  11504. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  11505. /**
  11506. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  11507. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  11508. */
  11509. static readonly FILTER_POISSONSAMPLING: number;
  11510. /**
  11511. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  11512. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11513. */
  11514. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  11515. /**
  11516. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  11517. * edge artifacts on steep falloff.
  11518. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11519. */
  11520. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  11521. /**
  11522. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  11523. * edge artifacts on steep falloff.
  11524. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  11525. */
  11526. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  11527. /**
  11528. * Shadow generator mode PCF: Percentage Closer Filtering
  11529. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11530. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  11531. */
  11532. static readonly FILTER_PCF: number;
  11533. /**
  11534. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  11535. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  11536. * Contact Hardening
  11537. */
  11538. static readonly FILTER_PCSS: number;
  11539. /**
  11540. * Reserved for PCF and PCSS
  11541. * Highest Quality.
  11542. *
  11543. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  11544. *
  11545. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  11546. */
  11547. static readonly QUALITY_HIGH: number;
  11548. /**
  11549. * Reserved for PCF and PCSS
  11550. * Good tradeoff for quality/perf cross devices
  11551. *
  11552. * Execute PCF on a 3*3 kernel.
  11553. *
  11554. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  11555. */
  11556. static readonly QUALITY_MEDIUM: number;
  11557. /**
  11558. * Reserved for PCF and PCSS
  11559. * The lowest quality but the fastest.
  11560. *
  11561. * Execute PCF on a 1*1 kernel.
  11562. *
  11563. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  11564. */
  11565. static readonly QUALITY_LOW: number;
  11566. /** Gets or sets the custom shader name to use */
  11567. customShaderOptions: ICustomShaderOptions;
  11568. /**
  11569. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  11570. */
  11571. onBeforeShadowMapRenderObservable: Observable<Effect>;
  11572. /**
  11573. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  11574. */
  11575. onAfterShadowMapRenderObservable: Observable<Effect>;
  11576. /**
  11577. * Observable triggered before a mesh is rendered in the shadow map.
  11578. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  11579. */
  11580. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  11581. /**
  11582. * Observable triggered after a mesh is rendered in the shadow map.
  11583. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  11584. */
  11585. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  11586. private _bias;
  11587. /**
  11588. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  11589. */
  11590. /**
  11591. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  11592. */
  11593. bias: number;
  11594. private _normalBias;
  11595. /**
  11596. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11597. */
  11598. /**
  11599. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  11600. */
  11601. normalBias: number;
  11602. private _blurBoxOffset;
  11603. /**
  11604. * Gets the blur box offset: offset applied during the blur pass.
  11605. * Only useful if useKernelBlur = false
  11606. */
  11607. /**
  11608. * Sets the blur box offset: offset applied during the blur pass.
  11609. * Only useful if useKernelBlur = false
  11610. */
  11611. blurBoxOffset: number;
  11612. private _blurScale;
  11613. /**
  11614. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  11615. * 2 means half of the size.
  11616. */
  11617. /**
  11618. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  11619. * 2 means half of the size.
  11620. */
  11621. blurScale: number;
  11622. private _blurKernel;
  11623. /**
  11624. * Gets the blur kernel: kernel size of the blur pass.
  11625. * Only useful if useKernelBlur = true
  11626. */
  11627. /**
  11628. * Sets the blur kernel: kernel size of the blur pass.
  11629. * Only useful if useKernelBlur = true
  11630. */
  11631. blurKernel: number;
  11632. private _useKernelBlur;
  11633. /**
  11634. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  11635. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11636. */
  11637. /**
  11638. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  11639. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  11640. */
  11641. useKernelBlur: boolean;
  11642. private _depthScale;
  11643. /**
  11644. * Gets the depth scale used in ESM mode.
  11645. */
  11646. /**
  11647. * Sets the depth scale used in ESM mode.
  11648. * This can override the scale stored on the light.
  11649. */
  11650. depthScale: number;
  11651. private _filter;
  11652. /**
  11653. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  11654. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11655. */
  11656. /**
  11657. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  11658. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  11659. */
  11660. filter: number;
  11661. /**
  11662. * Gets if the current filter is set to Poisson Sampling.
  11663. */
  11664. /**
  11665. * Sets the current filter to Poisson Sampling.
  11666. */
  11667. usePoissonSampling: boolean;
  11668. /**
  11669. * Gets if the current filter is set to ESM.
  11670. */
  11671. /**
  11672. * Sets the current filter is to ESM.
  11673. */
  11674. useExponentialShadowMap: boolean;
  11675. /**
  11676. * Gets if the current filter is set to filtered ESM.
  11677. */
  11678. /**
  11679. * Gets if the current filter is set to filtered ESM.
  11680. */
  11681. useBlurExponentialShadowMap: boolean;
  11682. /**
  11683. * Gets if the current filter is set to "close ESM" (using the inverse of the
  11684. * exponential to prevent steep falloff artifacts).
  11685. */
  11686. /**
  11687. * Sets the current filter to "close ESM" (using the inverse of the
  11688. * exponential to prevent steep falloff artifacts).
  11689. */
  11690. useCloseExponentialShadowMap: boolean;
  11691. /**
  11692. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  11693. * exponential to prevent steep falloff artifacts).
  11694. */
  11695. /**
  11696. * Sets the current filter to filtered "close ESM" (using the inverse of the
  11697. * exponential to prevent steep falloff artifacts).
  11698. */
  11699. useBlurCloseExponentialShadowMap: boolean;
  11700. /**
  11701. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  11702. */
  11703. /**
  11704. * Sets the current filter to "PCF" (percentage closer filtering).
  11705. */
  11706. usePercentageCloserFiltering: boolean;
  11707. private _filteringQuality;
  11708. /**
  11709. * Gets the PCF or PCSS Quality.
  11710. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11711. */
  11712. /**
  11713. * Sets the PCF or PCSS Quality.
  11714. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  11715. */
  11716. filteringQuality: number;
  11717. /**
  11718. * Gets if the current filter is set to "PCSS" (contact hardening).
  11719. */
  11720. /**
  11721. * Sets the current filter to "PCSS" (contact hardening).
  11722. */
  11723. useContactHardeningShadow: boolean;
  11724. private _contactHardeningLightSizeUVRatio;
  11725. /**
  11726. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11727. * Using a ratio helps keeping shape stability independently of the map size.
  11728. *
  11729. * It does not account for the light projection as it was having too much
  11730. * instability during the light setup or during light position changes.
  11731. *
  11732. * Only valid if useContactHardeningShadow is true.
  11733. */
  11734. /**
  11735. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  11736. * Using a ratio helps keeping shape stability independently of the map size.
  11737. *
  11738. * It does not account for the light projection as it was having too much
  11739. * instability during the light setup or during light position changes.
  11740. *
  11741. * Only valid if useContactHardeningShadow is true.
  11742. */
  11743. contactHardeningLightSizeUVRatio: number;
  11744. private _darkness;
  11745. /** Gets or sets the actual darkness of a shadow */
  11746. darkness: number;
  11747. /**
  11748. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  11749. * 0 means strongest and 1 would means no shadow.
  11750. * @returns the darkness.
  11751. */
  11752. getDarkness(): number;
  11753. /**
  11754. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  11755. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  11756. * @returns the shadow generator allowing fluent coding.
  11757. */
  11758. setDarkness(darkness: number): ShadowGenerator;
  11759. private _transparencyShadow;
  11760. /** Gets or sets the ability to have transparent shadow */
  11761. transparencyShadow: boolean;
  11762. /**
  11763. * Sets the ability to have transparent shadow (boolean).
  11764. * @param transparent True if transparent else False
  11765. * @returns the shadow generator allowing fluent coding
  11766. */
  11767. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  11768. private _shadowMap;
  11769. private _shadowMap2;
  11770. /**
  11771. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  11772. * @returns The render target texture if present otherwise, null
  11773. */
  11774. getShadowMap(): Nullable<RenderTargetTexture>;
  11775. /**
  11776. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  11777. * @returns The render target texture if the shadow map is present otherwise, null
  11778. */
  11779. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  11780. /**
  11781. * Gets the class name of that object
  11782. * @returns "ShadowGenerator"
  11783. */
  11784. getClassName(): string;
  11785. /**
  11786. * Helper function to add a mesh and its descendants to the list of shadow casters.
  11787. * @param mesh Mesh to add
  11788. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  11789. * @returns the Shadow Generator itself
  11790. */
  11791. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11792. /**
  11793. * Helper function to remove a mesh and its descendants from the list of shadow casters
  11794. * @param mesh Mesh to remove
  11795. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  11796. * @returns the Shadow Generator itself
  11797. */
  11798. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  11799. /**
  11800. * Controls the extent to which the shadows fade out at the edge of the frustum
  11801. * Used only by directionals and spots
  11802. */
  11803. frustumEdgeFalloff: number;
  11804. private _light;
  11805. /**
  11806. * Returns the associated light object.
  11807. * @returns the light generating the shadow
  11808. */
  11809. getLight(): IShadowLight;
  11810. /**
  11811. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  11812. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  11813. * It might on the other hand introduce peter panning.
  11814. */
  11815. forceBackFacesOnly: boolean;
  11816. private _scene;
  11817. private _lightDirection;
  11818. private _effect;
  11819. private _viewMatrix;
  11820. private _projectionMatrix;
  11821. private _transformMatrix;
  11822. private _cachedPosition;
  11823. private _cachedDirection;
  11824. private _cachedDefines;
  11825. private _currentRenderID;
  11826. private _boxBlurPostprocess;
  11827. private _kernelBlurXPostprocess;
  11828. private _kernelBlurYPostprocess;
  11829. private _blurPostProcesses;
  11830. private _mapSize;
  11831. private _currentFaceIndex;
  11832. private _currentFaceIndexCache;
  11833. private _textureType;
  11834. private _defaultTextureMatrix;
  11835. /** @hidden */
  11836. static _SceneComponentInitialization: (scene: Scene) => void;
  11837. /**
  11838. * Creates a ShadowGenerator object.
  11839. * A ShadowGenerator is the required tool to use the shadows.
  11840. * Each light casting shadows needs to use its own ShadowGenerator.
  11841. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  11842. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  11843. * @param light The light object generating the shadows.
  11844. * @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.
  11845. */
  11846. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  11847. private _initializeGenerator;
  11848. private _initializeShadowMap;
  11849. private _initializeBlurRTTAndPostProcesses;
  11850. private _renderForShadowMap;
  11851. private _renderSubMeshForShadowMap;
  11852. private _applyFilterValues;
  11853. /**
  11854. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11855. * @param onCompiled Callback triggered at the and of the effects compilation
  11856. * @param options Sets of optional options forcing the compilation with different modes
  11857. */
  11858. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  11859. useInstances: boolean;
  11860. }>): void;
  11861. /**
  11862. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  11863. * @param options Sets of optional options forcing the compilation with different modes
  11864. * @returns A promise that resolves when the compilation completes
  11865. */
  11866. forceCompilationAsync(options?: Partial<{
  11867. useInstances: boolean;
  11868. }>): Promise<void>;
  11869. /**
  11870. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  11871. * @param subMesh The submesh we want to render in the shadow map
  11872. * @param useInstances Defines wether will draw in the map using instances
  11873. * @returns true if ready otherwise, false
  11874. */
  11875. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  11876. /**
  11877. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  11878. * @param defines Defines of the material we want to update
  11879. * @param lightIndex Index of the light in the enabled light list of the material
  11880. */
  11881. prepareDefines(defines: any, lightIndex: number): void;
  11882. /**
  11883. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  11884. * defined in the generator but impacting the effect).
  11885. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  11886. * @param effect The effect we are binfing the information for
  11887. */
  11888. bindShadowLight(lightIndex: string, effect: Effect): void;
  11889. /**
  11890. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  11891. * (eq to shadow prjection matrix * light transform matrix)
  11892. * @returns The transform matrix used to create the shadow map
  11893. */
  11894. getTransformMatrix(): Matrix;
  11895. /**
  11896. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  11897. * Cube and 2D textures for instance.
  11898. */
  11899. recreateShadowMap(): void;
  11900. private _disposeBlurPostProcesses;
  11901. private _disposeRTTandPostProcesses;
  11902. /**
  11903. * Disposes the ShadowGenerator.
  11904. * Returns nothing.
  11905. */
  11906. dispose(): void;
  11907. /**
  11908. * Serializes the shadow generator setup to a json object.
  11909. * @returns The serialized JSON object
  11910. */
  11911. serialize(): any;
  11912. /**
  11913. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  11914. * @param parsedShadowGenerator The JSON object to parse
  11915. * @param scene The scene to create the shadow map for
  11916. * @returns The parsed shadow generator
  11917. */
  11918. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  11919. }
  11920. }
  11921. declare module "babylonjs/Lights/light" {
  11922. import { Nullable } from "babylonjs/types";
  11923. import { Scene } from "babylonjs/scene";
  11924. import { Vector3, Color3 } from "babylonjs/Maths/math";
  11925. import { Node } from "babylonjs/node";
  11926. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11927. import { Effect } from "babylonjs/Materials/effect";
  11928. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  11929. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  11930. /**
  11931. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  11932. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  11933. * 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.
  11934. */
  11935. export abstract class Light extends Node {
  11936. /**
  11937. * Falloff Default: light is falling off following the material specification:
  11938. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  11939. */
  11940. static readonly FALLOFF_DEFAULT: number;
  11941. /**
  11942. * Falloff Physical: light is falling off following the inverse squared distance law.
  11943. */
  11944. static readonly FALLOFF_PHYSICAL: number;
  11945. /**
  11946. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  11947. * to enhance interoperability with other engines.
  11948. */
  11949. static readonly FALLOFF_GLTF: number;
  11950. /**
  11951. * Falloff Standard: light is falling off like in the standard material
  11952. * to enhance interoperability with other materials.
  11953. */
  11954. static readonly FALLOFF_STANDARD: number;
  11955. /**
  11956. * If every light affecting the material is in this lightmapMode,
  11957. * material.lightmapTexture adds or multiplies
  11958. * (depends on material.useLightmapAsShadowmap)
  11959. * after every other light calculations.
  11960. */
  11961. static readonly LIGHTMAP_DEFAULT: number;
  11962. /**
  11963. * material.lightmapTexture as only diffuse lighting from this light
  11964. * adds only specular lighting from this light
  11965. * adds dynamic shadows
  11966. */
  11967. static readonly LIGHTMAP_SPECULAR: number;
  11968. /**
  11969. * material.lightmapTexture as only lighting
  11970. * no light calculation from this light
  11971. * only adds dynamic shadows from this light
  11972. */
  11973. static readonly LIGHTMAP_SHADOWSONLY: number;
  11974. /**
  11975. * Each light type uses the default quantity according to its type:
  11976. * point/spot lights use luminous intensity
  11977. * directional lights use illuminance
  11978. */
  11979. static readonly INTENSITYMODE_AUTOMATIC: number;
  11980. /**
  11981. * lumen (lm)
  11982. */
  11983. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  11984. /**
  11985. * candela (lm/sr)
  11986. */
  11987. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  11988. /**
  11989. * lux (lm/m^2)
  11990. */
  11991. static readonly INTENSITYMODE_ILLUMINANCE: number;
  11992. /**
  11993. * nit (cd/m^2)
  11994. */
  11995. static readonly INTENSITYMODE_LUMINANCE: number;
  11996. /**
  11997. * Light type const id of the point light.
  11998. */
  11999. static readonly LIGHTTYPEID_POINTLIGHT: number;
  12000. /**
  12001. * Light type const id of the directional light.
  12002. */
  12003. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  12004. /**
  12005. * Light type const id of the spot light.
  12006. */
  12007. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  12008. /**
  12009. * Light type const id of the hemispheric light.
  12010. */
  12011. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  12012. /**
  12013. * Diffuse gives the basic color to an object.
  12014. */
  12015. diffuse: Color3;
  12016. /**
  12017. * Specular produces a highlight color on an object.
  12018. * Note: This is note affecting PBR materials.
  12019. */
  12020. specular: Color3;
  12021. /**
  12022. * Defines the falloff type for this light. This lets overrriding how punctual light are
  12023. * falling off base on range or angle.
  12024. * This can be set to any values in Light.FALLOFF_x.
  12025. *
  12026. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  12027. * other types of materials.
  12028. */
  12029. falloffType: number;
  12030. /**
  12031. * Strength of the light.
  12032. * Note: By default it is define in the framework own unit.
  12033. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  12034. */
  12035. intensity: number;
  12036. private _range;
  12037. protected _inverseSquaredRange: number;
  12038. /**
  12039. * Defines how far from the source the light is impacting in scene units.
  12040. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  12041. */
  12042. /**
  12043. * Defines how far from the source the light is impacting in scene units.
  12044. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  12045. */
  12046. range: number;
  12047. /**
  12048. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  12049. * of light.
  12050. */
  12051. private _photometricScale;
  12052. private _intensityMode;
  12053. /**
  12054. * Gets the photometric scale used to interpret the intensity.
  12055. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12056. */
  12057. /**
  12058. * Sets the photometric scale used to interpret the intensity.
  12059. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  12060. */
  12061. intensityMode: number;
  12062. private _radius;
  12063. /**
  12064. * Gets the light radius used by PBR Materials to simulate soft area lights.
  12065. */
  12066. /**
  12067. * sets the light radius used by PBR Materials to simulate soft area lights.
  12068. */
  12069. radius: number;
  12070. private _renderPriority;
  12071. /**
  12072. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  12073. * exceeding the number allowed of the materials.
  12074. */
  12075. renderPriority: number;
  12076. private _shadowEnabled;
  12077. /**
  12078. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12079. * the current shadow generator.
  12080. */
  12081. /**
  12082. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  12083. * the current shadow generator.
  12084. */
  12085. shadowEnabled: boolean;
  12086. private _includedOnlyMeshes;
  12087. /**
  12088. * Gets the only meshes impacted by this light.
  12089. */
  12090. /**
  12091. * Sets the only meshes impacted by this light.
  12092. */
  12093. includedOnlyMeshes: AbstractMesh[];
  12094. private _excludedMeshes;
  12095. /**
  12096. * Gets the meshes not impacted by this light.
  12097. */
  12098. /**
  12099. * Sets the meshes not impacted by this light.
  12100. */
  12101. excludedMeshes: AbstractMesh[];
  12102. private _excludeWithLayerMask;
  12103. /**
  12104. * Gets the layer id use to find what meshes are not impacted by the light.
  12105. * Inactive if 0
  12106. */
  12107. /**
  12108. * Sets the layer id use to find what meshes are not impacted by the light.
  12109. * Inactive if 0
  12110. */
  12111. excludeWithLayerMask: number;
  12112. private _includeOnlyWithLayerMask;
  12113. /**
  12114. * Gets the layer id use to find what meshes are impacted by the light.
  12115. * Inactive if 0
  12116. */
  12117. /**
  12118. * Sets the layer id use to find what meshes are impacted by the light.
  12119. * Inactive if 0
  12120. */
  12121. includeOnlyWithLayerMask: number;
  12122. private _lightmapMode;
  12123. /**
  12124. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12125. */
  12126. /**
  12127. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  12128. */
  12129. lightmapMode: number;
  12130. /**
  12131. * Shadow generator associted to the light.
  12132. * @hidden Internal use only.
  12133. */
  12134. _shadowGenerator: Nullable<IShadowGenerator>;
  12135. /**
  12136. * @hidden Internal use only.
  12137. */
  12138. _excludedMeshesIds: string[];
  12139. /**
  12140. * @hidden Internal use only.
  12141. */
  12142. _includedOnlyMeshesIds: string[];
  12143. /**
  12144. * The current light unifom buffer.
  12145. * @hidden Internal use only.
  12146. */
  12147. _uniformBuffer: UniformBuffer;
  12148. /**
  12149. * Creates a Light object in the scene.
  12150. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12151. * @param name The firendly name of the light
  12152. * @param scene The scene the light belongs too
  12153. */
  12154. constructor(name: string, scene: Scene);
  12155. protected abstract _buildUniformLayout(): void;
  12156. /**
  12157. * Sets the passed Effect "effect" with the Light information.
  12158. * @param effect The effect to update
  12159. * @param lightIndex The index of the light in the effect to update
  12160. * @returns The light
  12161. */
  12162. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  12163. /**
  12164. * Returns the string "Light".
  12165. * @returns the class name
  12166. */
  12167. getClassName(): string;
  12168. /** @hidden */
  12169. readonly _isLight: boolean;
  12170. /**
  12171. * Converts the light information to a readable string for debug purpose.
  12172. * @param fullDetails Supports for multiple levels of logging within scene loading
  12173. * @returns the human readable light info
  12174. */
  12175. toString(fullDetails?: boolean): string;
  12176. /** @hidden */
  12177. protected _syncParentEnabledState(): void;
  12178. /**
  12179. * Set the enabled state of this node.
  12180. * @param value - the new enabled state
  12181. */
  12182. setEnabled(value: boolean): void;
  12183. /**
  12184. * Returns the Light associated shadow generator if any.
  12185. * @return the associated shadow generator.
  12186. */
  12187. getShadowGenerator(): Nullable<IShadowGenerator>;
  12188. /**
  12189. * Returns a Vector3, the absolute light position in the World.
  12190. * @returns the world space position of the light
  12191. */
  12192. getAbsolutePosition(): Vector3;
  12193. /**
  12194. * Specifies if the light will affect the passed mesh.
  12195. * @param mesh The mesh to test against the light
  12196. * @return true the mesh is affected otherwise, false.
  12197. */
  12198. canAffectMesh(mesh: AbstractMesh): boolean;
  12199. /**
  12200. * Sort function to order lights for rendering.
  12201. * @param a First Light object to compare to second.
  12202. * @param b Second Light object to compare first.
  12203. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  12204. */
  12205. static CompareLightsPriority(a: Light, b: Light): number;
  12206. /**
  12207. * Releases resources associated with this node.
  12208. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  12209. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  12210. */
  12211. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12212. /**
  12213. * Returns the light type ID (integer).
  12214. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12215. */
  12216. getTypeID(): number;
  12217. /**
  12218. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  12219. * @returns the scaled intensity in intensity mode unit
  12220. */
  12221. getScaledIntensity(): number;
  12222. /**
  12223. * Returns a new Light object, named "name", from the current one.
  12224. * @param name The name of the cloned light
  12225. * @returns the new created light
  12226. */
  12227. clone(name: string): Nullable<Light>;
  12228. /**
  12229. * Serializes the current light into a Serialization object.
  12230. * @returns the serialized object.
  12231. */
  12232. serialize(): any;
  12233. /**
  12234. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  12235. * This new light is named "name" and added to the passed scene.
  12236. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  12237. * @param name The friendly name of the light
  12238. * @param scene The scene the new light will belong to
  12239. * @returns the constructor function
  12240. */
  12241. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  12242. /**
  12243. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  12244. * @param parsedLight The JSON representation of the light
  12245. * @param scene The scene to create the parsed light in
  12246. * @returns the created light after parsing
  12247. */
  12248. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  12249. private _hookArrayForExcluded;
  12250. private _hookArrayForIncludedOnly;
  12251. private _resyncMeshes;
  12252. /**
  12253. * Forces the meshes to update their light related information in their rendering used effects
  12254. * @hidden Internal Use Only
  12255. */
  12256. _markMeshesAsLightDirty(): void;
  12257. /**
  12258. * Recomputes the cached photometric scale if needed.
  12259. */
  12260. private _computePhotometricScale;
  12261. /**
  12262. * Returns the Photometric Scale according to the light type and intensity mode.
  12263. */
  12264. private _getPhotometricScale;
  12265. /**
  12266. * Reorder the light in the scene according to their defined priority.
  12267. * @hidden Internal Use Only
  12268. */
  12269. _reorderLightsInScene(): void;
  12270. /**
  12271. * Prepares the list of defines specific to the light type.
  12272. * @param defines the list of defines
  12273. * @param lightIndex defines the index of the light for the effect
  12274. */
  12275. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12276. }
  12277. }
  12278. declare module "babylonjs/Meshes/instancedMesh" {
  12279. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  12280. import { Vector3, Matrix } from "babylonjs/Maths/math";
  12281. import { Camera } from "babylonjs/Cameras/camera";
  12282. import { Node } from "babylonjs/node";
  12283. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12284. import { Mesh } from "babylonjs/Meshes/mesh";
  12285. import { Material } from "babylonjs/Materials/material";
  12286. import { Skeleton } from "babylonjs/Bones/skeleton";
  12287. import { Light } from "babylonjs/Lights/light";
  12288. /**
  12289. * Creates an instance based on a source mesh.
  12290. */
  12291. export class InstancedMesh extends AbstractMesh {
  12292. private _sourceMesh;
  12293. private _currentLOD;
  12294. /** @hidden */
  12295. _indexInSourceMeshInstanceArray: number;
  12296. constructor(name: string, source: Mesh);
  12297. /**
  12298. * Returns the string "InstancedMesh".
  12299. */
  12300. getClassName(): string;
  12301. /** Gets the list of lights affecting that mesh */
  12302. readonly lightSources: Light[];
  12303. _resyncLightSources(): void;
  12304. _resyncLighSource(light: Light): void;
  12305. _removeLightSource(light: Light): void;
  12306. /**
  12307. * If the source mesh receives shadows
  12308. */
  12309. readonly receiveShadows: boolean;
  12310. /**
  12311. * The material of the source mesh
  12312. */
  12313. readonly material: Nullable<Material>;
  12314. /**
  12315. * Visibility of the source mesh
  12316. */
  12317. readonly visibility: number;
  12318. /**
  12319. * Skeleton of the source mesh
  12320. */
  12321. readonly skeleton: Nullable<Skeleton>;
  12322. /**
  12323. * Rendering ground id of the source mesh
  12324. */
  12325. renderingGroupId: number;
  12326. /**
  12327. * Returns the total number of vertices (integer).
  12328. */
  12329. getTotalVertices(): number;
  12330. /**
  12331. * Returns a positive integer : the total number of indices in this mesh geometry.
  12332. * @returns the numner of indices or zero if the mesh has no geometry.
  12333. */
  12334. getTotalIndices(): number;
  12335. /**
  12336. * The source mesh of the instance
  12337. */
  12338. readonly sourceMesh: Mesh;
  12339. /**
  12340. * Is this node ready to be used/rendered
  12341. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  12342. * @return {boolean} is it ready
  12343. */
  12344. isReady(completeCheck?: boolean): boolean;
  12345. /**
  12346. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  12347. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  12348. * @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.
  12349. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  12350. */
  12351. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  12352. /**
  12353. * Sets the vertex data of the mesh geometry for the requested `kind`.
  12354. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  12355. * The `data` are either a numeric array either a Float32Array.
  12356. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  12357. * 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).
  12358. * Note that a new underlying VertexBuffer object is created each call.
  12359. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  12360. *
  12361. * Possible `kind` values :
  12362. * - VertexBuffer.PositionKind
  12363. * - VertexBuffer.UVKind
  12364. * - VertexBuffer.UV2Kind
  12365. * - VertexBuffer.UV3Kind
  12366. * - VertexBuffer.UV4Kind
  12367. * - VertexBuffer.UV5Kind
  12368. * - VertexBuffer.UV6Kind
  12369. * - VertexBuffer.ColorKind
  12370. * - VertexBuffer.MatricesIndicesKind
  12371. * - VertexBuffer.MatricesIndicesExtraKind
  12372. * - VertexBuffer.MatricesWeightsKind
  12373. * - VertexBuffer.MatricesWeightsExtraKind
  12374. *
  12375. * Returns the Mesh.
  12376. */
  12377. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  12378. /**
  12379. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  12380. * If the mesh has no geometry, it is simply returned as it is.
  12381. * The `data` are either a numeric array either a Float32Array.
  12382. * No new underlying VertexBuffer object is created.
  12383. * 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.
  12384. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  12385. *
  12386. * Possible `kind` values :
  12387. * - VertexBuffer.PositionKind
  12388. * - VertexBuffer.UVKind
  12389. * - VertexBuffer.UV2Kind
  12390. * - VertexBuffer.UV3Kind
  12391. * - VertexBuffer.UV4Kind
  12392. * - VertexBuffer.UV5Kind
  12393. * - VertexBuffer.UV6Kind
  12394. * - VertexBuffer.ColorKind
  12395. * - VertexBuffer.MatricesIndicesKind
  12396. * - VertexBuffer.MatricesIndicesExtraKind
  12397. * - VertexBuffer.MatricesWeightsKind
  12398. * - VertexBuffer.MatricesWeightsExtraKind
  12399. *
  12400. * Returns the Mesh.
  12401. */
  12402. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  12403. /**
  12404. * Sets the mesh indices.
  12405. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  12406. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  12407. * This method creates a new index buffer each call.
  12408. * Returns the Mesh.
  12409. */
  12410. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  12411. /**
  12412. * Boolean : True if the mesh owns the requested kind of data.
  12413. */
  12414. isVerticesDataPresent(kind: string): boolean;
  12415. /**
  12416. * Returns an array of indices (IndicesArray).
  12417. */
  12418. getIndices(): Nullable<IndicesArray>;
  12419. readonly _positions: Nullable<Vector3[]>;
  12420. /**
  12421. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  12422. * This means the mesh underlying bounding box and sphere are recomputed.
  12423. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  12424. * @returns the current mesh
  12425. */
  12426. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  12427. /** @hidden */
  12428. _preActivate(): InstancedMesh;
  12429. /** @hidden */
  12430. _activate(renderId: number, intermediateRendering: boolean): boolean;
  12431. /** @hidden */
  12432. _postActivate(): void;
  12433. getWorldMatrix(): Matrix;
  12434. readonly isAnInstance: boolean;
  12435. /**
  12436. * Returns the current associated LOD AbstractMesh.
  12437. */
  12438. getLOD(camera: Camera): AbstractMesh;
  12439. /** @hidden */
  12440. _syncSubMeshes(): InstancedMesh;
  12441. /** @hidden */
  12442. _generatePointsArray(): boolean;
  12443. /**
  12444. * Creates a new InstancedMesh from the current mesh.
  12445. * - name (string) : the cloned mesh name
  12446. * - newParent (optional Node) : the optional Node to parent the clone to.
  12447. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  12448. *
  12449. * Returns the clone.
  12450. */
  12451. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  12452. /**
  12453. * Disposes the InstancedMesh.
  12454. * Returns nothing.
  12455. */
  12456. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  12457. }
  12458. }
  12459. declare module "babylonjs/Materials/shaderMaterial" {
  12460. import { Scene } from "babylonjs/scene";
  12461. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  12462. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12463. import { Mesh } from "babylonjs/Meshes/mesh";
  12464. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  12465. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12466. import { Texture } from "babylonjs/Materials/Textures/texture";
  12467. import { Material } from "babylonjs/Materials/material";
  12468. /**
  12469. * Defines the options associated with the creation of a shader material.
  12470. */
  12471. export interface IShaderMaterialOptions {
  12472. /**
  12473. * Does the material work in alpha blend mode
  12474. */
  12475. needAlphaBlending: boolean;
  12476. /**
  12477. * Does the material work in alpha test mode
  12478. */
  12479. needAlphaTesting: boolean;
  12480. /**
  12481. * The list of attribute names used in the shader
  12482. */
  12483. attributes: string[];
  12484. /**
  12485. * The list of unifrom names used in the shader
  12486. */
  12487. uniforms: string[];
  12488. /**
  12489. * The list of UBO names used in the shader
  12490. */
  12491. uniformBuffers: string[];
  12492. /**
  12493. * The list of sampler names used in the shader
  12494. */
  12495. samplers: string[];
  12496. /**
  12497. * The list of defines used in the shader
  12498. */
  12499. defines: string[];
  12500. }
  12501. /**
  12502. * 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.
  12503. *
  12504. * This returned material effects how the mesh will look based on the code in the shaders.
  12505. *
  12506. * @see http://doc.babylonjs.com/how_to/shader_material
  12507. */
  12508. export class ShaderMaterial extends Material {
  12509. private _shaderPath;
  12510. private _options;
  12511. private _textures;
  12512. private _textureArrays;
  12513. private _floats;
  12514. private _ints;
  12515. private _floatsArrays;
  12516. private _colors3;
  12517. private _colors3Arrays;
  12518. private _colors4;
  12519. private _colors4Arrays;
  12520. private _vectors2;
  12521. private _vectors3;
  12522. private _vectors4;
  12523. private _matrices;
  12524. private _matrices3x3;
  12525. private _matrices2x2;
  12526. private _vectors2Arrays;
  12527. private _vectors3Arrays;
  12528. private _vectors4Arrays;
  12529. private _cachedWorldViewMatrix;
  12530. private _cachedWorldViewProjectionMatrix;
  12531. private _renderId;
  12532. /**
  12533. * Instantiate a new shader material.
  12534. * 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.
  12535. * This returned material effects how the mesh will look based on the code in the shaders.
  12536. * @see http://doc.babylonjs.com/how_to/shader_material
  12537. * @param name Define the name of the material in the scene
  12538. * @param scene Define the scene the material belongs to
  12539. * @param shaderPath Defines the route to the shader code in one of three ways:
  12540. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  12541. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  12542. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  12543. * @param options Define the options used to create the shader
  12544. */
  12545. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  12546. /**
  12547. * Gets the options used to compile the shader.
  12548. * They can be modified to trigger a new compilation
  12549. */
  12550. readonly options: IShaderMaterialOptions;
  12551. /**
  12552. * Gets the current class name of the material e.g. "ShaderMaterial"
  12553. * Mainly use in serialization.
  12554. * @returns the class name
  12555. */
  12556. getClassName(): string;
  12557. /**
  12558. * Specifies if the material will require alpha blending
  12559. * @returns a boolean specifying if alpha blending is needed
  12560. */
  12561. needAlphaBlending(): boolean;
  12562. /**
  12563. * Specifies if this material should be rendered in alpha test mode
  12564. * @returns a boolean specifying if an alpha test is needed.
  12565. */
  12566. needAlphaTesting(): boolean;
  12567. private _checkUniform;
  12568. /**
  12569. * Set a texture in the shader.
  12570. * @param name Define the name of the uniform samplers as defined in the shader
  12571. * @param texture Define the texture to bind to this sampler
  12572. * @return the material itself allowing "fluent" like uniform updates
  12573. */
  12574. setTexture(name: string, texture: Texture): ShaderMaterial;
  12575. /**
  12576. * Set a texture array in the shader.
  12577. * @param name Define the name of the uniform sampler array as defined in the shader
  12578. * @param textures Define the list of textures to bind to this sampler
  12579. * @return the material itself allowing "fluent" like uniform updates
  12580. */
  12581. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  12582. /**
  12583. * Set a float in the shader.
  12584. * @param name Define the name of the uniform as defined in the shader
  12585. * @param value Define the value to give to the uniform
  12586. * @return the material itself allowing "fluent" like uniform updates
  12587. */
  12588. setFloat(name: string, value: number): ShaderMaterial;
  12589. /**
  12590. * Set a int in the shader.
  12591. * @param name Define the name of the uniform as defined in the shader
  12592. * @param value Define the value to give to the uniform
  12593. * @return the material itself allowing "fluent" like uniform updates
  12594. */
  12595. setInt(name: string, value: number): ShaderMaterial;
  12596. /**
  12597. * Set an array of floats in the shader.
  12598. * @param name Define the name of the uniform as defined in the shader
  12599. * @param value Define the value to give to the uniform
  12600. * @return the material itself allowing "fluent" like uniform updates
  12601. */
  12602. setFloats(name: string, value: number[]): ShaderMaterial;
  12603. /**
  12604. * Set a vec3 in the shader from a Color3.
  12605. * @param name Define the name of the uniform as defined in the shader
  12606. * @param value Define the value to give to the uniform
  12607. * @return the material itself allowing "fluent" like uniform updates
  12608. */
  12609. setColor3(name: string, value: Color3): ShaderMaterial;
  12610. /**
  12611. * Set a vec3 array in the shader from a Color3 array.
  12612. * @param name Define the name of the uniform as defined in the shader
  12613. * @param value Define the value to give to the uniform
  12614. * @return the material itself allowing "fluent" like uniform updates
  12615. */
  12616. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  12617. /**
  12618. * Set a vec4 in the shader from a Color4.
  12619. * @param name Define the name of the uniform as defined in the shader
  12620. * @param value Define the value to give to the uniform
  12621. * @return the material itself allowing "fluent" like uniform updates
  12622. */
  12623. setColor4(name: string, value: Color4): ShaderMaterial;
  12624. /**
  12625. * Set a vec4 array in the shader from a Color4 array.
  12626. * @param name Define the name of the uniform as defined in the shader
  12627. * @param value Define the value to give to the uniform
  12628. * @return the material itself allowing "fluent" like uniform updates
  12629. */
  12630. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  12631. /**
  12632. * Set a vec2 in the shader from a Vector2.
  12633. * @param name Define the name of the uniform as defined in the shader
  12634. * @param value Define the value to give to the uniform
  12635. * @return the material itself allowing "fluent" like uniform updates
  12636. */
  12637. setVector2(name: string, value: Vector2): ShaderMaterial;
  12638. /**
  12639. * Set a vec3 in the shader from a Vector3.
  12640. * @param name Define the name of the uniform as defined in the shader
  12641. * @param value Define the value to give to the uniform
  12642. * @return the material itself allowing "fluent" like uniform updates
  12643. */
  12644. setVector3(name: string, value: Vector3): ShaderMaterial;
  12645. /**
  12646. * Set a vec4 in the shader from a Vector4.
  12647. * @param name Define the name of the uniform as defined in the shader
  12648. * @param value Define the value to give to the uniform
  12649. * @return the material itself allowing "fluent" like uniform updates
  12650. */
  12651. setVector4(name: string, value: Vector4): ShaderMaterial;
  12652. /**
  12653. * Set a mat4 in the shader from a Matrix.
  12654. * @param name Define the name of the uniform as defined in the shader
  12655. * @param value Define the value to give to the uniform
  12656. * @return the material itself allowing "fluent" like uniform updates
  12657. */
  12658. setMatrix(name: string, value: Matrix): ShaderMaterial;
  12659. /**
  12660. * Set a mat3 in the shader from a Float32Array.
  12661. * @param name Define the name of the uniform as defined in the shader
  12662. * @param value Define the value to give to the uniform
  12663. * @return the material itself allowing "fluent" like uniform updates
  12664. */
  12665. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  12666. /**
  12667. * Set a mat2 in the shader from a Float32Array.
  12668. * @param name Define the name of the uniform as defined in the shader
  12669. * @param value Define the value to give to the uniform
  12670. * @return the material itself allowing "fluent" like uniform updates
  12671. */
  12672. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  12673. /**
  12674. * Set a vec2 array in the shader from a number array.
  12675. * @param name Define the name of the uniform as defined in the shader
  12676. * @param value Define the value to give to the uniform
  12677. * @return the material itself allowing "fluent" like uniform updates
  12678. */
  12679. setArray2(name: string, value: number[]): ShaderMaterial;
  12680. /**
  12681. * Set a vec3 array in the shader from a number array.
  12682. * @param name Define the name of the uniform as defined in the shader
  12683. * @param value Define the value to give to the uniform
  12684. * @return the material itself allowing "fluent" like uniform updates
  12685. */
  12686. setArray3(name: string, value: number[]): ShaderMaterial;
  12687. /**
  12688. * Set a vec4 array in the shader from a number array.
  12689. * @param name Define the name of the uniform as defined in the shader
  12690. * @param value Define the value to give to the uniform
  12691. * @return the material itself allowing "fluent" like uniform updates
  12692. */
  12693. setArray4(name: string, value: number[]): ShaderMaterial;
  12694. private _checkCache;
  12695. /**
  12696. * Specifies that the submesh is ready to be used
  12697. * @param mesh defines the mesh to check
  12698. * @param subMesh defines which submesh to check
  12699. * @param useInstances specifies that instances should be used
  12700. * @returns a boolean indicating that the submesh is ready or not
  12701. */
  12702. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  12703. /**
  12704. * Checks if the material is ready to render the requested mesh
  12705. * @param mesh Define the mesh to render
  12706. * @param useInstances Define whether or not the material is used with instances
  12707. * @returns true if ready, otherwise false
  12708. */
  12709. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  12710. /**
  12711. * Binds the world matrix to the material
  12712. * @param world defines the world transformation matrix
  12713. */
  12714. bindOnlyWorldMatrix(world: Matrix): void;
  12715. /**
  12716. * Binds the material to the mesh
  12717. * @param world defines the world transformation matrix
  12718. * @param mesh defines the mesh to bind the material to
  12719. */
  12720. bind(world: Matrix, mesh?: Mesh): void;
  12721. /**
  12722. * Gets the active textures from the material
  12723. * @returns an array of textures
  12724. */
  12725. getActiveTextures(): BaseTexture[];
  12726. /**
  12727. * Specifies if the material uses a texture
  12728. * @param texture defines the texture to check against the material
  12729. * @returns a boolean specifying if the material uses the texture
  12730. */
  12731. hasTexture(texture: BaseTexture): boolean;
  12732. /**
  12733. * Makes a duplicate of the material, and gives it a new name
  12734. * @param name defines the new name for the duplicated material
  12735. * @returns the cloned material
  12736. */
  12737. clone(name: string): ShaderMaterial;
  12738. /**
  12739. * Disposes the material
  12740. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  12741. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  12742. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  12743. */
  12744. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  12745. /**
  12746. * Serializes this material in a JSON representation
  12747. * @returns the serialized material object
  12748. */
  12749. serialize(): any;
  12750. /**
  12751. * Creates a shader material from parsed shader material data
  12752. * @param source defines the JSON represnetation of the material
  12753. * @param scene defines the hosting scene
  12754. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  12755. * @returns a new material
  12756. */
  12757. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  12758. }
  12759. }
  12760. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  12761. /** @hidden */
  12762. export var clipPlaneFragmentDeclaration: {
  12763. name: string;
  12764. shader: string;
  12765. };
  12766. }
  12767. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  12768. /** @hidden */
  12769. export var clipPlaneFragment: {
  12770. name: string;
  12771. shader: string;
  12772. };
  12773. }
  12774. declare module "babylonjs/Shaders/color.fragment" {
  12775. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12776. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12777. /** @hidden */
  12778. export var colorPixelShader: {
  12779. name: string;
  12780. shader: string;
  12781. };
  12782. }
  12783. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  12784. /** @hidden */
  12785. export var clipPlaneVertexDeclaration: {
  12786. name: string;
  12787. shader: string;
  12788. };
  12789. }
  12790. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  12791. /** @hidden */
  12792. export var clipPlaneVertex: {
  12793. name: string;
  12794. shader: string;
  12795. };
  12796. }
  12797. declare module "babylonjs/Shaders/color.vertex" {
  12798. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  12799. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12800. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  12801. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  12802. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  12803. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12804. /** @hidden */
  12805. export var colorVertexShader: {
  12806. name: string;
  12807. shader: string;
  12808. };
  12809. }
  12810. declare module "babylonjs/Meshes/linesMesh" {
  12811. import { Nullable } from "babylonjs/types";
  12812. import { Scene } from "babylonjs/scene";
  12813. import { Color3 } from "babylonjs/Maths/math";
  12814. import { Node } from "babylonjs/node";
  12815. import { SubMesh } from "babylonjs/Meshes/subMesh";
  12816. import { Mesh } from "babylonjs/Meshes/mesh";
  12817. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  12818. import { Effect } from "babylonjs/Materials/effect";
  12819. import { Material } from "babylonjs/Materials/material";
  12820. import "babylonjs/Shaders/color.fragment";
  12821. import "babylonjs/Shaders/color.vertex";
  12822. /**
  12823. * Line mesh
  12824. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  12825. */
  12826. export class LinesMesh extends Mesh {
  12827. /**
  12828. * If vertex color should be applied to the mesh
  12829. */
  12830. readonly useVertexColor?: boolean | undefined;
  12831. /**
  12832. * If vertex alpha should be applied to the mesh
  12833. */
  12834. readonly useVertexAlpha?: boolean | undefined;
  12835. /**
  12836. * Color of the line (Default: White)
  12837. */
  12838. color: Color3;
  12839. /**
  12840. * Alpha of the line (Default: 1)
  12841. */
  12842. alpha: number;
  12843. /**
  12844. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12845. * This margin is expressed in world space coordinates, so its value may vary.
  12846. * Default value is 0.1
  12847. */
  12848. intersectionThreshold: number;
  12849. private _colorShader;
  12850. private color4;
  12851. /**
  12852. * Creates a new LinesMesh
  12853. * @param name defines the name
  12854. * @param scene defines the hosting scene
  12855. * @param parent defines the parent mesh if any
  12856. * @param source defines the optional source LinesMesh used to clone data from
  12857. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  12858. * When false, achieved by calling a clone(), also passing False.
  12859. * This will make creation of children, recursive.
  12860. * @param useVertexColor defines if this LinesMesh supports vertex color
  12861. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  12862. */
  12863. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  12864. /**
  12865. * If vertex color should be applied to the mesh
  12866. */
  12867. useVertexColor?: boolean | undefined,
  12868. /**
  12869. * If vertex alpha should be applied to the mesh
  12870. */
  12871. useVertexAlpha?: boolean | undefined);
  12872. private _addClipPlaneDefine;
  12873. private _removeClipPlaneDefine;
  12874. isReady(): boolean;
  12875. /**
  12876. * Returns the string "LineMesh"
  12877. */
  12878. getClassName(): string;
  12879. /**
  12880. * @hidden
  12881. */
  12882. /**
  12883. * @hidden
  12884. */
  12885. material: Material;
  12886. /**
  12887. * @hidden
  12888. */
  12889. readonly checkCollisions: boolean;
  12890. /** @hidden */
  12891. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  12892. /** @hidden */
  12893. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  12894. /**
  12895. * Disposes of the line mesh
  12896. * @param doNotRecurse If children should be disposed
  12897. */
  12898. dispose(doNotRecurse?: boolean): void;
  12899. /**
  12900. * Returns a new LineMesh object cloned from the current one.
  12901. */
  12902. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  12903. /**
  12904. * Creates a new InstancedLinesMesh object from the mesh model.
  12905. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  12906. * @param name defines the name of the new instance
  12907. * @returns a new InstancedLinesMesh
  12908. */
  12909. createInstance(name: string): InstancedLinesMesh;
  12910. }
  12911. /**
  12912. * Creates an instance based on a source LinesMesh
  12913. */
  12914. export class InstancedLinesMesh extends InstancedMesh {
  12915. /**
  12916. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  12917. * This margin is expressed in world space coordinates, so its value may vary.
  12918. * Initilized with the intersectionThreshold value of the source LinesMesh
  12919. */
  12920. intersectionThreshold: number;
  12921. constructor(name: string, source: LinesMesh);
  12922. /**
  12923. * Returns the string "InstancedLinesMesh".
  12924. */
  12925. getClassName(): string;
  12926. }
  12927. }
  12928. declare module "babylonjs/Meshes/groundMesh" {
  12929. import { Scene } from "babylonjs/scene";
  12930. import { Vector3 } from "babylonjs/Maths/math";
  12931. import { Mesh } from "babylonjs/Meshes/mesh";
  12932. /**
  12933. * Mesh representing the gorund
  12934. */
  12935. export class GroundMesh extends Mesh {
  12936. /** If octree should be generated */
  12937. generateOctree: boolean;
  12938. private _heightQuads;
  12939. /** @hidden */
  12940. _subdivisionsX: number;
  12941. /** @hidden */
  12942. _subdivisionsY: number;
  12943. /** @hidden */
  12944. _width: number;
  12945. /** @hidden */
  12946. _height: number;
  12947. /** @hidden */
  12948. _minX: number;
  12949. /** @hidden */
  12950. _maxX: number;
  12951. /** @hidden */
  12952. _minZ: number;
  12953. /** @hidden */
  12954. _maxZ: number;
  12955. constructor(name: string, scene: Scene);
  12956. /**
  12957. * "GroundMesh"
  12958. * @returns "GroundMesh"
  12959. */
  12960. getClassName(): string;
  12961. /**
  12962. * The minimum of x and y subdivisions
  12963. */
  12964. readonly subdivisions: number;
  12965. /**
  12966. * X subdivisions
  12967. */
  12968. readonly subdivisionsX: number;
  12969. /**
  12970. * Y subdivisions
  12971. */
  12972. readonly subdivisionsY: number;
  12973. /**
  12974. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  12975. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  12976. * @param chunksCount the number of subdivisions for x and y
  12977. * @param octreeBlocksSize (Default: 32)
  12978. */
  12979. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  12980. /**
  12981. * Returns a height (y) value in the Worl system :
  12982. * the ground altitude at the coordinates (x, z) expressed in the World system.
  12983. * @param x x coordinate
  12984. * @param z z coordinate
  12985. * @returns the ground y position if (x, z) are outside the ground surface.
  12986. */
  12987. getHeightAtCoordinates(x: number, z: number): number;
  12988. /**
  12989. * Returns a normalized vector (Vector3) orthogonal to the ground
  12990. * at the ground coordinates (x, z) expressed in the World system.
  12991. * @param x x coordinate
  12992. * @param z z coordinate
  12993. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  12994. */
  12995. getNormalAtCoordinates(x: number, z: number): Vector3;
  12996. /**
  12997. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  12998. * at the ground coordinates (x, z) expressed in the World system.
  12999. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  13000. * @param x x coordinate
  13001. * @param z z coordinate
  13002. * @param ref vector to store the result
  13003. * @returns the GroundMesh.
  13004. */
  13005. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  13006. /**
  13007. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  13008. * if the ground has been updated.
  13009. * This can be used in the render loop.
  13010. * @returns the GroundMesh.
  13011. */
  13012. updateCoordinateHeights(): GroundMesh;
  13013. private _getFacetAt;
  13014. private _initHeightQuads;
  13015. private _computeHeightQuads;
  13016. /**
  13017. * Serializes this ground mesh
  13018. * @param serializationObject object to write serialization to
  13019. */
  13020. serialize(serializationObject: any): void;
  13021. /**
  13022. * Parses a serialized ground mesh
  13023. * @param parsedMesh the serialized mesh
  13024. * @param scene the scene to create the ground mesh in
  13025. * @returns the created ground mesh
  13026. */
  13027. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  13028. }
  13029. }
  13030. declare module "babylonjs/Physics/physicsJoint" {
  13031. import { Vector3 } from "babylonjs/Maths/math";
  13032. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  13033. /**
  13034. * Interface for Physics-Joint data
  13035. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13036. */
  13037. export interface PhysicsJointData {
  13038. /**
  13039. * The main pivot of the joint
  13040. */
  13041. mainPivot?: Vector3;
  13042. /**
  13043. * The connected pivot of the joint
  13044. */
  13045. connectedPivot?: Vector3;
  13046. /**
  13047. * The main axis of the joint
  13048. */
  13049. mainAxis?: Vector3;
  13050. /**
  13051. * The connected axis of the joint
  13052. */
  13053. connectedAxis?: Vector3;
  13054. /**
  13055. * The collision of the joint
  13056. */
  13057. collision?: boolean;
  13058. /**
  13059. * Native Oimo/Cannon/Energy data
  13060. */
  13061. nativeParams?: any;
  13062. }
  13063. /**
  13064. * This is a holder class for the physics joint created by the physics plugin
  13065. * It holds a set of functions to control the underlying joint
  13066. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13067. */
  13068. export class PhysicsJoint {
  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. private _physicsJoint;
  13078. protected _physicsPlugin: IPhysicsEnginePlugin;
  13079. /**
  13080. * Initializes the physics joint
  13081. * @param type The type of the physics joint
  13082. * @param jointData The data for the physics joint
  13083. */
  13084. constructor(
  13085. /**
  13086. * The type of the physics joint
  13087. */
  13088. type: number,
  13089. /**
  13090. * The data for the physics joint
  13091. */
  13092. jointData: PhysicsJointData);
  13093. /**
  13094. * Gets the physics joint
  13095. */
  13096. /**
  13097. * Sets the physics joint
  13098. */
  13099. physicsJoint: any;
  13100. /**
  13101. * Sets the physics plugin
  13102. */
  13103. physicsPlugin: IPhysicsEnginePlugin;
  13104. /**
  13105. * Execute a function that is physics-plugin specific.
  13106. * @param {Function} func the function that will be executed.
  13107. * It accepts two parameters: the physics world and the physics joint
  13108. */
  13109. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  13110. /**
  13111. * Distance-Joint type
  13112. */
  13113. static DistanceJoint: number;
  13114. /**
  13115. * Hinge-Joint type
  13116. */
  13117. static HingeJoint: number;
  13118. /**
  13119. * Ball-and-Socket joint type
  13120. */
  13121. static BallAndSocketJoint: number;
  13122. /**
  13123. * Wheel-Joint type
  13124. */
  13125. static WheelJoint: number;
  13126. /**
  13127. * Slider-Joint type
  13128. */
  13129. static SliderJoint: number;
  13130. /**
  13131. * Prismatic-Joint type
  13132. */
  13133. static PrismaticJoint: number;
  13134. /**
  13135. * Universal-Joint type
  13136. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  13137. */
  13138. static UniversalJoint: number;
  13139. /**
  13140. * Hinge-Joint 2 type
  13141. */
  13142. static Hinge2Joint: number;
  13143. /**
  13144. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  13145. */
  13146. static PointToPointJoint: number;
  13147. /**
  13148. * Spring-Joint type
  13149. */
  13150. static SpringJoint: number;
  13151. /**
  13152. * Lock-Joint type
  13153. */
  13154. static LockJoint: number;
  13155. }
  13156. /**
  13157. * A class representing a physics distance joint
  13158. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13159. */
  13160. export class DistanceJoint extends PhysicsJoint {
  13161. /**
  13162. *
  13163. * @param jointData The data for the Distance-Joint
  13164. */
  13165. constructor(jointData: DistanceJointData);
  13166. /**
  13167. * Update the predefined distance.
  13168. * @param maxDistance The maximum preferred distance
  13169. * @param minDistance The minimum preferred distance
  13170. */
  13171. updateDistance(maxDistance: number, minDistance?: number): void;
  13172. }
  13173. /**
  13174. * Represents a Motor-Enabled Joint
  13175. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13176. */
  13177. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  13178. /**
  13179. * Initializes the Motor-Enabled Joint
  13180. * @param type The type of the joint
  13181. * @param jointData The physica joint data for the joint
  13182. */
  13183. constructor(type: number, jointData: PhysicsJointData);
  13184. /**
  13185. * Set the motor values.
  13186. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13187. * @param force the force to apply
  13188. * @param maxForce max force for this motor.
  13189. */
  13190. setMotor(force?: number, maxForce?: number): void;
  13191. /**
  13192. * Set the motor's limits.
  13193. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13194. * @param upperLimit The upper limit of the motor
  13195. * @param lowerLimit The lower limit of the motor
  13196. */
  13197. setLimit(upperLimit: number, lowerLimit?: number): void;
  13198. }
  13199. /**
  13200. * This class represents a single physics Hinge-Joint
  13201. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13202. */
  13203. export class HingeJoint extends MotorEnabledJoint {
  13204. /**
  13205. * Initializes the Hinge-Joint
  13206. * @param jointData The joint data for the Hinge-Joint
  13207. */
  13208. constructor(jointData: PhysicsJointData);
  13209. /**
  13210. * Set the motor values.
  13211. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13212. * @param {number} force the force to apply
  13213. * @param {number} maxForce max force for this motor.
  13214. */
  13215. setMotor(force?: number, maxForce?: number): void;
  13216. /**
  13217. * Set the motor's limits.
  13218. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13219. * @param upperLimit The upper limit of the motor
  13220. * @param lowerLimit The lower limit of the motor
  13221. */
  13222. setLimit(upperLimit: number, lowerLimit?: number): void;
  13223. }
  13224. /**
  13225. * This class represents a dual hinge physics joint (same as wheel joint)
  13226. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13227. */
  13228. export class Hinge2Joint extends MotorEnabledJoint {
  13229. /**
  13230. * Initializes the Hinge2-Joint
  13231. * @param jointData The joint data for the Hinge2-Joint
  13232. */
  13233. constructor(jointData: PhysicsJointData);
  13234. /**
  13235. * Set the motor values.
  13236. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13237. * @param {number} targetSpeed the speed the motor is to reach
  13238. * @param {number} maxForce max force for this motor.
  13239. * @param {motorIndex} the motor's index, 0 or 1.
  13240. */
  13241. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  13242. /**
  13243. * Set the motor limits.
  13244. * Attention, this function is plugin specific. Engines won't react 100% the same.
  13245. * @param {number} upperLimit the upper limit
  13246. * @param {number} lowerLimit lower limit
  13247. * @param {motorIndex} the motor's index, 0 or 1.
  13248. */
  13249. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13250. }
  13251. /**
  13252. * Interface for a motor enabled joint
  13253. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13254. */
  13255. export interface IMotorEnabledJoint {
  13256. /**
  13257. * Physics joint
  13258. */
  13259. physicsJoint: any;
  13260. /**
  13261. * Sets the motor of the motor-enabled joint
  13262. * @param force The force of the motor
  13263. * @param maxForce The maximum force of the motor
  13264. * @param motorIndex The index of the motor
  13265. */
  13266. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  13267. /**
  13268. * Sets the limit of the motor
  13269. * @param upperLimit The upper limit of the motor
  13270. * @param lowerLimit The lower limit of the motor
  13271. * @param motorIndex The index of the motor
  13272. */
  13273. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13274. }
  13275. /**
  13276. * Joint data for a Distance-Joint
  13277. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13278. */
  13279. export interface DistanceJointData extends PhysicsJointData {
  13280. /**
  13281. * Max distance the 2 joint objects can be apart
  13282. */
  13283. maxDistance: number;
  13284. }
  13285. /**
  13286. * Joint data from a spring joint
  13287. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13288. */
  13289. export interface SpringJointData extends PhysicsJointData {
  13290. /**
  13291. * Length of the spring
  13292. */
  13293. length: number;
  13294. /**
  13295. * Stiffness of the spring
  13296. */
  13297. stiffness: number;
  13298. /**
  13299. * Damping of the spring
  13300. */
  13301. damping: number;
  13302. /** this callback will be called when applying the force to the impostors. */
  13303. forceApplicationCallback: () => void;
  13304. }
  13305. }
  13306. declare module "babylonjs/Physics/physicsRaycastResult" {
  13307. import { Vector3 } from "babylonjs/Maths/math";
  13308. /**
  13309. * Holds the data for the raycast result
  13310. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13311. */
  13312. export class PhysicsRaycastResult {
  13313. private _hasHit;
  13314. private _hitDistance;
  13315. private _hitNormalWorld;
  13316. private _hitPointWorld;
  13317. private _rayFromWorld;
  13318. private _rayToWorld;
  13319. /**
  13320. * Gets if there was a hit
  13321. */
  13322. readonly hasHit: boolean;
  13323. /**
  13324. * Gets the distance from the hit
  13325. */
  13326. readonly hitDistance: number;
  13327. /**
  13328. * Gets the hit normal/direction in the world
  13329. */
  13330. readonly hitNormalWorld: Vector3;
  13331. /**
  13332. * Gets the hit point in the world
  13333. */
  13334. readonly hitPointWorld: Vector3;
  13335. /**
  13336. * Gets the ray "start point" of the ray in the world
  13337. */
  13338. readonly rayFromWorld: Vector3;
  13339. /**
  13340. * Gets the ray "end point" of the ray in the world
  13341. */
  13342. readonly rayToWorld: Vector3;
  13343. /**
  13344. * Sets the hit data (normal & point in world space)
  13345. * @param hitNormalWorld defines the normal in world space
  13346. * @param hitPointWorld defines the point in world space
  13347. */
  13348. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  13349. /**
  13350. * Sets the distance from the start point to the hit point
  13351. * @param distance
  13352. */
  13353. setHitDistance(distance: number): void;
  13354. /**
  13355. * Calculates the distance manually
  13356. */
  13357. calculateHitDistance(): void;
  13358. /**
  13359. * Resets all the values to default
  13360. * @param from The from point on world space
  13361. * @param to The to point on world space
  13362. */
  13363. reset(from?: Vector3, to?: Vector3): void;
  13364. }
  13365. /**
  13366. * Interface for the size containing width and height
  13367. */
  13368. interface IXYZ {
  13369. /**
  13370. * X
  13371. */
  13372. x: number;
  13373. /**
  13374. * Y
  13375. */
  13376. y: number;
  13377. /**
  13378. * Z
  13379. */
  13380. z: number;
  13381. }
  13382. }
  13383. declare module "babylonjs/Physics/IPhysicsEngine" {
  13384. import { Nullable } from "babylonjs/types";
  13385. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  13386. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13387. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  13388. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  13389. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  13390. /**
  13391. * Interface used to describe a physics joint
  13392. */
  13393. export interface PhysicsImpostorJoint {
  13394. /** Defines the main impostor to which the joint is linked */
  13395. mainImpostor: PhysicsImpostor;
  13396. /** Defines the impostor that is connected to the main impostor using this joint */
  13397. connectedImpostor: PhysicsImpostor;
  13398. /** Defines the joint itself */
  13399. joint: PhysicsJoint;
  13400. }
  13401. /** @hidden */
  13402. export interface IPhysicsEnginePlugin {
  13403. world: any;
  13404. name: string;
  13405. setGravity(gravity: Vector3): void;
  13406. setTimeStep(timeStep: number): void;
  13407. getTimeStep(): number;
  13408. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  13409. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13410. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  13411. generatePhysicsBody(impostor: PhysicsImpostor): void;
  13412. removePhysicsBody(impostor: PhysicsImpostor): void;
  13413. generateJoint(joint: PhysicsImpostorJoint): void;
  13414. removeJoint(joint: PhysicsImpostorJoint): void;
  13415. isSupported(): boolean;
  13416. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  13417. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  13418. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13419. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  13420. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13421. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  13422. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  13423. getBodyMass(impostor: PhysicsImpostor): number;
  13424. getBodyFriction(impostor: PhysicsImpostor): number;
  13425. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  13426. getBodyRestitution(impostor: PhysicsImpostor): number;
  13427. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  13428. getBodyPressure?(impostor: PhysicsImpostor): number;
  13429. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  13430. getBodyStiffness?(impostor: PhysicsImpostor): number;
  13431. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  13432. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  13433. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  13434. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  13435. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  13436. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13437. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  13438. sleepBody(impostor: PhysicsImpostor): void;
  13439. wakeUpBody(impostor: PhysicsImpostor): void;
  13440. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13441. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  13442. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  13443. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  13444. getRadius(impostor: PhysicsImpostor): number;
  13445. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  13446. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  13447. dispose(): void;
  13448. }
  13449. /**
  13450. * Interface used to define a physics engine
  13451. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  13452. */
  13453. export interface IPhysicsEngine {
  13454. /**
  13455. * Gets the gravity vector used by the simulation
  13456. */
  13457. gravity: Vector3;
  13458. /**
  13459. * Sets the gravity vector used by the simulation
  13460. * @param gravity defines the gravity vector to use
  13461. */
  13462. setGravity(gravity: Vector3): void;
  13463. /**
  13464. * Set the time step of the physics engine.
  13465. * Default is 1/60.
  13466. * To slow it down, enter 1/600 for example.
  13467. * To speed it up, 1/30
  13468. * @param newTimeStep the new timestep to apply to this world.
  13469. */
  13470. setTimeStep(newTimeStep: number): void;
  13471. /**
  13472. * Get the time step of the physics engine.
  13473. * @returns the current time step
  13474. */
  13475. getTimeStep(): number;
  13476. /**
  13477. * Release all resources
  13478. */
  13479. dispose(): void;
  13480. /**
  13481. * Gets the name of the current physics plugin
  13482. * @returns the name of the plugin
  13483. */
  13484. getPhysicsPluginName(): string;
  13485. /**
  13486. * Adding a new impostor for the impostor tracking.
  13487. * This will be done by the impostor itself.
  13488. * @param impostor the impostor to add
  13489. */
  13490. addImpostor(impostor: PhysicsImpostor): void;
  13491. /**
  13492. * Remove an impostor from the engine.
  13493. * This impostor and its mesh will not longer be updated by the physics engine.
  13494. * @param impostor the impostor to remove
  13495. */
  13496. removeImpostor(impostor: PhysicsImpostor): void;
  13497. /**
  13498. * Add a joint to the physics engine
  13499. * @param mainImpostor defines the main impostor to which the joint is added.
  13500. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  13501. * @param joint defines the joint that will connect both impostors.
  13502. */
  13503. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13504. /**
  13505. * Removes a joint from the simulation
  13506. * @param mainImpostor defines the impostor used with the joint
  13507. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  13508. * @param joint defines the joint to remove
  13509. */
  13510. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  13511. /**
  13512. * Gets the current plugin used to run the simulation
  13513. * @returns current plugin
  13514. */
  13515. getPhysicsPlugin(): IPhysicsEnginePlugin;
  13516. /**
  13517. * Gets the list of physic impostors
  13518. * @returns an array of PhysicsImpostor
  13519. */
  13520. getImpostors(): Array<PhysicsImpostor>;
  13521. /**
  13522. * Gets the impostor for a physics enabled object
  13523. * @param object defines the object impersonated by the impostor
  13524. * @returns the PhysicsImpostor or null if not found
  13525. */
  13526. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  13527. /**
  13528. * Gets the impostor for a physics body object
  13529. * @param body defines physics body used by the impostor
  13530. * @returns the PhysicsImpostor or null if not found
  13531. */
  13532. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  13533. /**
  13534. * Does a raycast in the physics world
  13535. * @param from when should the ray start?
  13536. * @param to when should the ray end?
  13537. * @returns PhysicsRaycastResult
  13538. */
  13539. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  13540. /**
  13541. * Called by the scene. No need to call it.
  13542. * @param delta defines the timespam between frames
  13543. */
  13544. _step(delta: number): void;
  13545. }
  13546. }
  13547. declare module "babylonjs/Physics/physicsImpostor" {
  13548. import { Nullable, IndicesArray } from "babylonjs/types";
  13549. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  13550. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13552. import { Scene } from "babylonjs/scene";
  13553. import { Bone } from "babylonjs/Bones/bone";
  13554. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  13555. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  13556. /**
  13557. * The interface for the physics imposter parameters
  13558. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13559. */
  13560. export interface PhysicsImpostorParameters {
  13561. /**
  13562. * The mass of the physics imposter
  13563. */
  13564. mass: number;
  13565. /**
  13566. * The friction of the physics imposter
  13567. */
  13568. friction?: number;
  13569. /**
  13570. * The coefficient of restitution of the physics imposter
  13571. */
  13572. restitution?: number;
  13573. /**
  13574. * The native options of the physics imposter
  13575. */
  13576. nativeOptions?: any;
  13577. /**
  13578. * Specifies if the parent should be ignored
  13579. */
  13580. ignoreParent?: boolean;
  13581. /**
  13582. * Specifies if bi-directional transformations should be disabled
  13583. */
  13584. disableBidirectionalTransformation?: boolean;
  13585. /**
  13586. * The pressure inside the physics imposter, soft object only
  13587. */
  13588. pressure?: number;
  13589. /**
  13590. * The stiffness the physics imposter, soft object only
  13591. */
  13592. stiffness?: number;
  13593. /**
  13594. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  13595. */
  13596. velocityIterations?: number;
  13597. /**
  13598. * The number of iterations used in maintaining consistent vertex positions, soft object only
  13599. */
  13600. positionIterations?: number;
  13601. /**
  13602. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  13603. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  13604. * Add to fix multiple points
  13605. */
  13606. fixedPoints?: number;
  13607. /**
  13608. * The collision margin around a soft object
  13609. */
  13610. margin?: number;
  13611. /**
  13612. * The collision margin around a soft object
  13613. */
  13614. damping?: number;
  13615. /**
  13616. * The path for a rope based on an extrusion
  13617. */
  13618. path?: any;
  13619. /**
  13620. * The shape of an extrusion used for a rope based on an extrusion
  13621. */
  13622. shape?: any;
  13623. }
  13624. /**
  13625. * Interface for a physics-enabled object
  13626. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13627. */
  13628. export interface IPhysicsEnabledObject {
  13629. /**
  13630. * The position of the physics-enabled object
  13631. */
  13632. position: Vector3;
  13633. /**
  13634. * The rotation of the physics-enabled object
  13635. */
  13636. rotationQuaternion: Nullable<Quaternion>;
  13637. /**
  13638. * The scale of the physics-enabled object
  13639. */
  13640. scaling: Vector3;
  13641. /**
  13642. * The rotation of the physics-enabled object
  13643. */
  13644. rotation?: Vector3;
  13645. /**
  13646. * The parent of the physics-enabled object
  13647. */
  13648. parent?: any;
  13649. /**
  13650. * The bounding info of the physics-enabled object
  13651. * @returns The bounding info of the physics-enabled object
  13652. */
  13653. getBoundingInfo(): BoundingInfo;
  13654. /**
  13655. * Computes the world matrix
  13656. * @param force Specifies if the world matrix should be computed by force
  13657. * @returns A world matrix
  13658. */
  13659. computeWorldMatrix(force: boolean): Matrix;
  13660. /**
  13661. * Gets the world matrix
  13662. * @returns A world matrix
  13663. */
  13664. getWorldMatrix?(): Matrix;
  13665. /**
  13666. * Gets the child meshes
  13667. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  13668. * @returns An array of abstract meshes
  13669. */
  13670. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  13671. /**
  13672. * Gets the vertex data
  13673. * @param kind The type of vertex data
  13674. * @returns A nullable array of numbers, or a float32 array
  13675. */
  13676. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  13677. /**
  13678. * Gets the indices from the mesh
  13679. * @returns A nullable array of index arrays
  13680. */
  13681. getIndices?(): Nullable<IndicesArray>;
  13682. /**
  13683. * Gets the scene from the mesh
  13684. * @returns the indices array or null
  13685. */
  13686. getScene?(): Scene;
  13687. /**
  13688. * Gets the absolute position from the mesh
  13689. * @returns the absolute position
  13690. */
  13691. getAbsolutePosition(): Vector3;
  13692. /**
  13693. * Gets the absolute pivot point from the mesh
  13694. * @returns the absolute pivot point
  13695. */
  13696. getAbsolutePivotPoint(): Vector3;
  13697. /**
  13698. * Rotates the mesh
  13699. * @param axis The axis of rotation
  13700. * @param amount The amount of rotation
  13701. * @param space The space of the rotation
  13702. * @returns The rotation transform node
  13703. */
  13704. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13705. /**
  13706. * Translates the mesh
  13707. * @param axis The axis of translation
  13708. * @param distance The distance of translation
  13709. * @param space The space of the translation
  13710. * @returns The transform node
  13711. */
  13712. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13713. /**
  13714. * Sets the absolute position of the mesh
  13715. * @param absolutePosition The absolute position of the mesh
  13716. * @returns The transform node
  13717. */
  13718. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13719. /**
  13720. * Gets the class name of the mesh
  13721. * @returns The class name
  13722. */
  13723. getClassName(): string;
  13724. }
  13725. /**
  13726. * Represents a physics imposter
  13727. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  13728. */
  13729. export class PhysicsImpostor {
  13730. /**
  13731. * The physics-enabled object used as the physics imposter
  13732. */
  13733. object: IPhysicsEnabledObject;
  13734. /**
  13735. * The type of the physics imposter
  13736. */
  13737. type: number;
  13738. private _options;
  13739. private _scene?;
  13740. /**
  13741. * The default object size of the imposter
  13742. */
  13743. static DEFAULT_OBJECT_SIZE: Vector3;
  13744. /**
  13745. * The identity quaternion of the imposter
  13746. */
  13747. static IDENTITY_QUATERNION: Quaternion;
  13748. /** @hidden */
  13749. _pluginData: any;
  13750. private _physicsEngine;
  13751. private _physicsBody;
  13752. private _bodyUpdateRequired;
  13753. private _onBeforePhysicsStepCallbacks;
  13754. private _onAfterPhysicsStepCallbacks;
  13755. /** @hidden */
  13756. _onPhysicsCollideCallbacks: Array<{
  13757. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  13758. otherImpostors: Array<PhysicsImpostor>;
  13759. }>;
  13760. private _deltaPosition;
  13761. private _deltaRotation;
  13762. private _deltaRotationConjugated;
  13763. /** @hidden */
  13764. _isFromLine: boolean;
  13765. private _parent;
  13766. private _isDisposed;
  13767. private static _tmpVecs;
  13768. private static _tmpQuat;
  13769. /**
  13770. * Specifies if the physics imposter is disposed
  13771. */
  13772. readonly isDisposed: boolean;
  13773. /**
  13774. * Gets the mass of the physics imposter
  13775. */
  13776. mass: number;
  13777. /**
  13778. * Gets the coefficient of friction
  13779. */
  13780. /**
  13781. * Sets the coefficient of friction
  13782. */
  13783. friction: number;
  13784. /**
  13785. * Gets the coefficient of restitution
  13786. */
  13787. /**
  13788. * Sets the coefficient of restitution
  13789. */
  13790. restitution: number;
  13791. /**
  13792. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  13793. */
  13794. /**
  13795. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  13796. */
  13797. pressure: number;
  13798. /**
  13799. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13800. */
  13801. /**
  13802. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  13803. */
  13804. stiffness: number;
  13805. /**
  13806. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13807. */
  13808. /**
  13809. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  13810. */
  13811. velocityIterations: number;
  13812. /**
  13813. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13814. */
  13815. /**
  13816. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  13817. */
  13818. positionIterations: number;
  13819. /**
  13820. * The unique id of the physics imposter
  13821. * set by the physics engine when adding this impostor to the array
  13822. */
  13823. uniqueId: number;
  13824. /**
  13825. * @hidden
  13826. */
  13827. soft: boolean;
  13828. /**
  13829. * @hidden
  13830. */
  13831. segments: number;
  13832. private _joints;
  13833. /**
  13834. * Initializes the physics imposter
  13835. * @param object The physics-enabled object used as the physics imposter
  13836. * @param type The type of the physics imposter
  13837. * @param _options The options for the physics imposter
  13838. * @param _scene The Babylon scene
  13839. */
  13840. constructor(
  13841. /**
  13842. * The physics-enabled object used as the physics imposter
  13843. */
  13844. object: IPhysicsEnabledObject,
  13845. /**
  13846. * The type of the physics imposter
  13847. */
  13848. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  13849. /**
  13850. * This function will completly initialize this impostor.
  13851. * It will create a new body - but only if this mesh has no parent.
  13852. * If it has, this impostor will not be used other than to define the impostor
  13853. * of the child mesh.
  13854. * @hidden
  13855. */
  13856. _init(): void;
  13857. private _getPhysicsParent;
  13858. /**
  13859. * Should a new body be generated.
  13860. * @returns boolean specifying if body initialization is required
  13861. */
  13862. isBodyInitRequired(): boolean;
  13863. /**
  13864. * Sets the updated scaling
  13865. * @param updated Specifies if the scaling is updated
  13866. */
  13867. setScalingUpdated(): void;
  13868. /**
  13869. * Force a regeneration of this or the parent's impostor's body.
  13870. * Use under cautious - This will remove all joints already implemented.
  13871. */
  13872. forceUpdate(): void;
  13873. /**
  13874. * Gets the body that holds this impostor. Either its own, or its parent.
  13875. */
  13876. /**
  13877. * Set the physics body. Used mainly by the physics engine/plugin
  13878. */
  13879. physicsBody: any;
  13880. /**
  13881. * Get the parent of the physics imposter
  13882. * @returns Physics imposter or null
  13883. */
  13884. /**
  13885. * Sets the parent of the physics imposter
  13886. */
  13887. parent: Nullable<PhysicsImpostor>;
  13888. /**
  13889. * Resets the update flags
  13890. */
  13891. resetUpdateFlags(): void;
  13892. /**
  13893. * Gets the object extend size
  13894. * @returns the object extend size
  13895. */
  13896. getObjectExtendSize(): Vector3;
  13897. /**
  13898. * Gets the object center
  13899. * @returns The object center
  13900. */
  13901. getObjectCenter(): Vector3;
  13902. /**
  13903. * Get a specific parametes from the options parameter
  13904. * @param paramName The object parameter name
  13905. * @returns The object parameter
  13906. */
  13907. getParam(paramName: string): any;
  13908. /**
  13909. * Sets a specific parameter in the options given to the physics plugin
  13910. * @param paramName The parameter name
  13911. * @param value The value of the parameter
  13912. */
  13913. setParam(paramName: string, value: number): void;
  13914. /**
  13915. * Specifically change the body's mass option. Won't recreate the physics body object
  13916. * @param mass The mass of the physics imposter
  13917. */
  13918. setMass(mass: number): void;
  13919. /**
  13920. * Gets the linear velocity
  13921. * @returns linear velocity or null
  13922. */
  13923. getLinearVelocity(): Nullable<Vector3>;
  13924. /**
  13925. * Sets the linear velocity
  13926. * @param velocity linear velocity or null
  13927. */
  13928. setLinearVelocity(velocity: Nullable<Vector3>): void;
  13929. /**
  13930. * Gets the angular velocity
  13931. * @returns angular velocity or null
  13932. */
  13933. getAngularVelocity(): Nullable<Vector3>;
  13934. /**
  13935. * Sets the angular velocity
  13936. * @param velocity The velocity or null
  13937. */
  13938. setAngularVelocity(velocity: Nullable<Vector3>): void;
  13939. /**
  13940. * Execute a function with the physics plugin native code
  13941. * Provide a function the will have two variables - the world object and the physics body object
  13942. * @param func The function to execute with the physics plugin native code
  13943. */
  13944. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  13945. /**
  13946. * Register a function that will be executed before the physics world is stepping forward
  13947. * @param func The function to execute before the physics world is stepped forward
  13948. */
  13949. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13950. /**
  13951. * Unregister a function that will be executed before the physics world is stepping forward
  13952. * @param func The function to execute before the physics world is stepped forward
  13953. */
  13954. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13955. /**
  13956. * Register a function that will be executed after the physics step
  13957. * @param func The function to execute after physics step
  13958. */
  13959. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13960. /**
  13961. * Unregisters a function that will be executed after the physics step
  13962. * @param func The function to execute after physics step
  13963. */
  13964. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  13965. /**
  13966. * register a function that will be executed when this impostor collides against a different body
  13967. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  13968. * @param func Callback that is executed on collision
  13969. */
  13970. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  13971. /**
  13972. * Unregisters the physics imposter on contact
  13973. * @param collideAgainst The physics object to collide against
  13974. * @param func Callback to execute on collision
  13975. */
  13976. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  13977. private _tmpQuat;
  13978. private _tmpQuat2;
  13979. /**
  13980. * Get the parent rotation
  13981. * @returns The parent rotation
  13982. */
  13983. getParentsRotation(): Quaternion;
  13984. /**
  13985. * this function is executed by the physics engine.
  13986. */
  13987. beforeStep: () => void;
  13988. /**
  13989. * this function is executed by the physics engine
  13990. */
  13991. afterStep: () => void;
  13992. /**
  13993. * Legacy collision detection event support
  13994. */
  13995. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  13996. /**
  13997. * event and body object due to cannon's event-based architecture.
  13998. */
  13999. onCollide: (e: {
  14000. body: any;
  14001. }) => void;
  14002. /**
  14003. * Apply a force
  14004. * @param force The force to apply
  14005. * @param contactPoint The contact point for the force
  14006. * @returns The physics imposter
  14007. */
  14008. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  14009. /**
  14010. * Apply an impulse
  14011. * @param force The impulse force
  14012. * @param contactPoint The contact point for the impulse force
  14013. * @returns The physics imposter
  14014. */
  14015. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  14016. /**
  14017. * A help function to create a joint
  14018. * @param otherImpostor A physics imposter used to create a joint
  14019. * @param jointType The type of joint
  14020. * @param jointData The data for the joint
  14021. * @returns The physics imposter
  14022. */
  14023. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  14024. /**
  14025. * Add a joint to this impostor with a different impostor
  14026. * @param otherImpostor A physics imposter used to add a joint
  14027. * @param joint The joint to add
  14028. * @returns The physics imposter
  14029. */
  14030. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  14031. /**
  14032. * Add an anchor to a cloth impostor
  14033. * @param otherImpostor rigid impostor to anchor to
  14034. * @param width ratio across width from 0 to 1
  14035. * @param height ratio up height from 0 to 1
  14036. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  14037. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  14038. * @returns impostor the soft imposter
  14039. */
  14040. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  14041. /**
  14042. * Add a hook to a rope impostor
  14043. * @param otherImpostor rigid impostor to anchor to
  14044. * @param length ratio across rope from 0 to 1
  14045. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  14046. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  14047. * @returns impostor the rope imposter
  14048. */
  14049. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  14050. /**
  14051. * Will keep this body still, in a sleep mode.
  14052. * @returns the physics imposter
  14053. */
  14054. sleep(): PhysicsImpostor;
  14055. /**
  14056. * Wake the body up.
  14057. * @returns The physics imposter
  14058. */
  14059. wakeUp(): PhysicsImpostor;
  14060. /**
  14061. * Clones the physics imposter
  14062. * @param newObject The physics imposter clones to this physics-enabled object
  14063. * @returns A nullable physics imposter
  14064. */
  14065. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  14066. /**
  14067. * Disposes the physics imposter
  14068. */
  14069. dispose(): void;
  14070. /**
  14071. * Sets the delta position
  14072. * @param position The delta position amount
  14073. */
  14074. setDeltaPosition(position: Vector3): void;
  14075. /**
  14076. * Sets the delta rotation
  14077. * @param rotation The delta rotation amount
  14078. */
  14079. setDeltaRotation(rotation: Quaternion): void;
  14080. /**
  14081. * Gets the box size of the physics imposter and stores the result in the input parameter
  14082. * @param result Stores the box size
  14083. * @returns The physics imposter
  14084. */
  14085. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  14086. /**
  14087. * Gets the radius of the physics imposter
  14088. * @returns Radius of the physics imposter
  14089. */
  14090. getRadius(): number;
  14091. /**
  14092. * Sync a bone with this impostor
  14093. * @param bone The bone to sync to the impostor.
  14094. * @param boneMesh The mesh that the bone is influencing.
  14095. * @param jointPivot The pivot of the joint / bone in local space.
  14096. * @param distToJoint Optional distance from the impostor to the joint.
  14097. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  14098. */
  14099. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  14100. /**
  14101. * Sync impostor to a bone
  14102. * @param bone The bone that the impostor will be synced to.
  14103. * @param boneMesh The mesh that the bone is influencing.
  14104. * @param jointPivot The pivot of the joint / bone in local space.
  14105. * @param distToJoint Optional distance from the impostor to the joint.
  14106. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  14107. * @param boneAxis Optional vector3 axis the bone is aligned with
  14108. */
  14109. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  14110. /**
  14111. * No-Imposter type
  14112. */
  14113. static NoImpostor: number;
  14114. /**
  14115. * Sphere-Imposter type
  14116. */
  14117. static SphereImpostor: number;
  14118. /**
  14119. * Box-Imposter type
  14120. */
  14121. static BoxImpostor: number;
  14122. /**
  14123. * Plane-Imposter type
  14124. */
  14125. static PlaneImpostor: number;
  14126. /**
  14127. * Mesh-imposter type
  14128. */
  14129. static MeshImpostor: number;
  14130. /**
  14131. * Capsule-Impostor type (Ammo.js plugin only)
  14132. */
  14133. static CapsuleImpostor: number;
  14134. /**
  14135. * Cylinder-Imposter type
  14136. */
  14137. static CylinderImpostor: number;
  14138. /**
  14139. * Particle-Imposter type
  14140. */
  14141. static ParticleImpostor: number;
  14142. /**
  14143. * Heightmap-Imposter type
  14144. */
  14145. static HeightmapImpostor: number;
  14146. /**
  14147. * ConvexHull-Impostor type (Ammo.js plugin only)
  14148. */
  14149. static ConvexHullImpostor: number;
  14150. /**
  14151. * Rope-Imposter type
  14152. */
  14153. static RopeImpostor: number;
  14154. /**
  14155. * Cloth-Imposter type
  14156. */
  14157. static ClothImpostor: number;
  14158. /**
  14159. * Softbody-Imposter type
  14160. */
  14161. static SoftbodyImpostor: number;
  14162. }
  14163. }
  14164. declare module "babylonjs/Meshes/mesh" {
  14165. import { Observable } from "babylonjs/Misc/observable";
  14166. import { IAnimatable } from "babylonjs/Misc/tools";
  14167. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  14168. import { Camera } from "babylonjs/Cameras/camera";
  14169. import { Scene } from "babylonjs/scene";
  14170. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  14171. import { Engine } from "babylonjs/Engines/engine";
  14172. import { Node } from "babylonjs/node";
  14173. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  14174. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  14175. import { Buffer } from "babylonjs/Meshes/buffer";
  14176. import { Geometry } from "babylonjs/Meshes/geometry";
  14177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14178. import { SubMesh } from "babylonjs/Meshes/subMesh";
  14179. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  14180. import { Effect } from "babylonjs/Materials/effect";
  14181. import { Material } from "babylonjs/Materials/material";
  14182. import { Skeleton } from "babylonjs/Bones/skeleton";
  14183. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  14184. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  14185. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  14186. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  14187. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  14188. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  14189. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  14190. /**
  14191. * @hidden
  14192. **/
  14193. export class _CreationDataStorage {
  14194. closePath?: boolean;
  14195. closeArray?: boolean;
  14196. idx: number[];
  14197. dashSize: number;
  14198. gapSize: number;
  14199. path3D: Path3D;
  14200. pathArray: Vector3[][];
  14201. arc: number;
  14202. radius: number;
  14203. cap: number;
  14204. tessellation: number;
  14205. }
  14206. /**
  14207. * @hidden
  14208. **/
  14209. class _InstanceDataStorage {
  14210. visibleInstances: any;
  14211. batchCache: _InstancesBatch;
  14212. instancesBufferSize: number;
  14213. instancesBuffer: Nullable<Buffer>;
  14214. instancesData: Float32Array;
  14215. overridenInstanceCount: number;
  14216. isFrozen: boolean;
  14217. previousBatch: Nullable<_InstancesBatch>;
  14218. hardwareInstancedRendering: boolean;
  14219. sideOrientation: number;
  14220. }
  14221. /**
  14222. * @hidden
  14223. **/
  14224. export class _InstancesBatch {
  14225. mustReturn: boolean;
  14226. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  14227. renderSelf: boolean[];
  14228. hardwareInstancedRendering: boolean[];
  14229. }
  14230. /**
  14231. * Class used to represent renderable models
  14232. */
  14233. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  14234. /**
  14235. * Mesh side orientation : usually the external or front surface
  14236. */
  14237. static readonly FRONTSIDE: number;
  14238. /**
  14239. * Mesh side orientation : usually the internal or back surface
  14240. */
  14241. static readonly BACKSIDE: number;
  14242. /**
  14243. * Mesh side orientation : both internal and external or front and back surfaces
  14244. */
  14245. static readonly DOUBLESIDE: number;
  14246. /**
  14247. * Mesh side orientation : by default, `FRONTSIDE`
  14248. */
  14249. static readonly DEFAULTSIDE: number;
  14250. /**
  14251. * Mesh cap setting : no cap
  14252. */
  14253. static readonly NO_CAP: number;
  14254. /**
  14255. * Mesh cap setting : one cap at the beginning of the mesh
  14256. */
  14257. static readonly CAP_START: number;
  14258. /**
  14259. * Mesh cap setting : one cap at the end of the mesh
  14260. */
  14261. static readonly CAP_END: number;
  14262. /**
  14263. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  14264. */
  14265. static readonly CAP_ALL: number;
  14266. /**
  14267. * Mesh pattern setting : no flip or rotate
  14268. */
  14269. static readonly NO_FLIP: number;
  14270. /**
  14271. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  14272. */
  14273. static readonly FLIP_TILE: number;
  14274. /**
  14275. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  14276. */
  14277. static readonly ROTATE_TILE: number;
  14278. /**
  14279. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  14280. */
  14281. static readonly FLIP_ROW: number;
  14282. /**
  14283. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  14284. */
  14285. static readonly ROTATE_ROW: number;
  14286. /**
  14287. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  14288. */
  14289. static readonly FLIP_N_ROTATE_TILE: number;
  14290. /**
  14291. * Mesh pattern setting : rotate pattern and rotate
  14292. */
  14293. static readonly FLIP_N_ROTATE_ROW: number;
  14294. /**
  14295. * Mesh tile positioning : part tiles same on left/right or top/bottom
  14296. */
  14297. static readonly CENTER: number;
  14298. /**
  14299. * Mesh tile positioning : part tiles on left
  14300. */
  14301. static readonly LEFT: number;
  14302. /**
  14303. * Mesh tile positioning : part tiles on right
  14304. */
  14305. static readonly RIGHT: number;
  14306. /**
  14307. * Mesh tile positioning : part tiles on top
  14308. */
  14309. static readonly TOP: number;
  14310. /**
  14311. * Mesh tile positioning : part tiles on bottom
  14312. */
  14313. static readonly BOTTOM: number;
  14314. /**
  14315. * Gets the default side orientation.
  14316. * @param orientation the orientation to value to attempt to get
  14317. * @returns the default orientation
  14318. * @hidden
  14319. */
  14320. static _GetDefaultSideOrientation(orientation?: number): number;
  14321. private _internalMeshDataInfo;
  14322. /**
  14323. * An event triggered before rendering the mesh
  14324. */
  14325. readonly onBeforeRenderObservable: Observable<Mesh>;
  14326. /**
  14327. * An event triggered before binding the mesh
  14328. */
  14329. readonly onBeforeBindObservable: Observable<Mesh>;
  14330. /**
  14331. * An event triggered after rendering the mesh
  14332. */
  14333. readonly onAfterRenderObservable: Observable<Mesh>;
  14334. /**
  14335. * An event triggered before drawing the mesh
  14336. */
  14337. readonly onBeforeDrawObservable: Observable<Mesh>;
  14338. private _onBeforeDrawObserver;
  14339. /**
  14340. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  14341. */
  14342. onBeforeDraw: () => void;
  14343. /**
  14344. * Gets the delay loading state of the mesh (when delay loading is turned on)
  14345. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  14346. */
  14347. delayLoadState: number;
  14348. /**
  14349. * Gets the list of instances created from this mesh
  14350. * it is not supposed to be modified manually.
  14351. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  14352. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14353. */
  14354. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  14355. /**
  14356. * Gets the file containing delay loading data for this mesh
  14357. */
  14358. delayLoadingFile: string;
  14359. /** @hidden */
  14360. _binaryInfo: any;
  14361. /**
  14362. * User defined function used to change how LOD level selection is done
  14363. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  14364. */
  14365. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  14366. /**
  14367. * Gets or sets the morph target manager
  14368. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  14369. */
  14370. morphTargetManager: Nullable<MorphTargetManager>;
  14371. /** @hidden */
  14372. _creationDataStorage: Nullable<_CreationDataStorage>;
  14373. /** @hidden */
  14374. _geometry: Nullable<Geometry>;
  14375. /** @hidden */
  14376. _delayInfo: Array<string>;
  14377. /** @hidden */
  14378. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  14379. /** @hidden */
  14380. _instanceDataStorage: _InstanceDataStorage;
  14381. private _effectiveMaterial;
  14382. /** @hidden */
  14383. _shouldGenerateFlatShading: boolean;
  14384. /** @hidden */
  14385. _originalBuilderSideOrientation: number;
  14386. /**
  14387. * Use this property to change the original side orientation defined at construction time
  14388. */
  14389. overrideMaterialSideOrientation: Nullable<number>;
  14390. /**
  14391. * Gets the source mesh (the one used to clone this one from)
  14392. */
  14393. readonly source: Nullable<Mesh>;
  14394. /**
  14395. * Gets or sets a boolean indicating that this mesh does not use index buffer
  14396. */
  14397. isUnIndexed: boolean;
  14398. /**
  14399. * @constructor
  14400. * @param name The value used by scene.getMeshByName() to do a lookup.
  14401. * @param scene The scene to add this mesh to.
  14402. * @param parent The parent of this mesh, if it has one
  14403. * @param source An optional Mesh from which geometry is shared, cloned.
  14404. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  14405. * When false, achieved by calling a clone(), also passing False.
  14406. * This will make creation of children, recursive.
  14407. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  14408. */
  14409. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  14410. /**
  14411. * Gets the class name
  14412. * @returns the string "Mesh".
  14413. */
  14414. getClassName(): string;
  14415. /** @hidden */
  14416. readonly _isMesh: boolean;
  14417. /**
  14418. * Returns a description of this mesh
  14419. * @param fullDetails define if full details about this mesh must be used
  14420. * @returns a descriptive string representing this mesh
  14421. */
  14422. toString(fullDetails?: boolean): string;
  14423. /** @hidden */
  14424. _unBindEffect(): void;
  14425. /**
  14426. * Gets a boolean indicating if this mesh has LOD
  14427. */
  14428. readonly hasLODLevels: boolean;
  14429. /**
  14430. * Gets the list of MeshLODLevel associated with the current mesh
  14431. * @returns an array of MeshLODLevel
  14432. */
  14433. getLODLevels(): MeshLODLevel[];
  14434. private _sortLODLevels;
  14435. /**
  14436. * Add a mesh as LOD level triggered at the given distance.
  14437. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14438. * @param distance The distance from the center of the object to show this level
  14439. * @param mesh The mesh to be added as LOD level (can be null)
  14440. * @return This mesh (for chaining)
  14441. */
  14442. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  14443. /**
  14444. * Returns the LOD level mesh at the passed distance or null if not found.
  14445. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14446. * @param distance The distance from the center of the object to show this level
  14447. * @returns a Mesh or `null`
  14448. */
  14449. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  14450. /**
  14451. * Remove a mesh from the LOD array
  14452. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14453. * @param mesh defines the mesh to be removed
  14454. * @return This mesh (for chaining)
  14455. */
  14456. removeLODLevel(mesh: Mesh): Mesh;
  14457. /**
  14458. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  14459. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  14460. * @param camera defines the camera to use to compute distance
  14461. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  14462. * @return This mesh (for chaining)
  14463. */
  14464. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  14465. /**
  14466. * Gets the mesh internal Geometry object
  14467. */
  14468. readonly geometry: Nullable<Geometry>;
  14469. /**
  14470. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  14471. * @returns the total number of vertices
  14472. */
  14473. getTotalVertices(): number;
  14474. /**
  14475. * Returns the content of an associated vertex buffer
  14476. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14477. * - VertexBuffer.PositionKind
  14478. * - VertexBuffer.UVKind
  14479. * - VertexBuffer.UV2Kind
  14480. * - VertexBuffer.UV3Kind
  14481. * - VertexBuffer.UV4Kind
  14482. * - VertexBuffer.UV5Kind
  14483. * - VertexBuffer.UV6Kind
  14484. * - VertexBuffer.ColorKind
  14485. * - VertexBuffer.MatricesIndicesKind
  14486. * - VertexBuffer.MatricesIndicesExtraKind
  14487. * - VertexBuffer.MatricesWeightsKind
  14488. * - VertexBuffer.MatricesWeightsExtraKind
  14489. * @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
  14490. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  14491. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  14492. */
  14493. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  14494. /**
  14495. * Returns the mesh VertexBuffer object from the requested `kind`
  14496. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14497. * - VertexBuffer.PositionKind
  14498. * - VertexBuffer.NormalKind
  14499. * - VertexBuffer.UVKind
  14500. * - VertexBuffer.UV2Kind
  14501. * - VertexBuffer.UV3Kind
  14502. * - VertexBuffer.UV4Kind
  14503. * - VertexBuffer.UV5Kind
  14504. * - VertexBuffer.UV6Kind
  14505. * - VertexBuffer.ColorKind
  14506. * - VertexBuffer.MatricesIndicesKind
  14507. * - VertexBuffer.MatricesIndicesExtraKind
  14508. * - VertexBuffer.MatricesWeightsKind
  14509. * - VertexBuffer.MatricesWeightsExtraKind
  14510. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  14511. */
  14512. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  14513. /**
  14514. * Tests if a specific vertex buffer is associated with this mesh
  14515. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14516. * - VertexBuffer.PositionKind
  14517. * - VertexBuffer.NormalKind
  14518. * - VertexBuffer.UVKind
  14519. * - VertexBuffer.UV2Kind
  14520. * - VertexBuffer.UV3Kind
  14521. * - VertexBuffer.UV4Kind
  14522. * - VertexBuffer.UV5Kind
  14523. * - VertexBuffer.UV6Kind
  14524. * - VertexBuffer.ColorKind
  14525. * - VertexBuffer.MatricesIndicesKind
  14526. * - VertexBuffer.MatricesIndicesExtraKind
  14527. * - VertexBuffer.MatricesWeightsKind
  14528. * - VertexBuffer.MatricesWeightsExtraKind
  14529. * @returns a boolean
  14530. */
  14531. isVerticesDataPresent(kind: string): boolean;
  14532. /**
  14533. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  14534. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  14535. * - VertexBuffer.PositionKind
  14536. * - VertexBuffer.UVKind
  14537. * - VertexBuffer.UV2Kind
  14538. * - VertexBuffer.UV3Kind
  14539. * - VertexBuffer.UV4Kind
  14540. * - VertexBuffer.UV5Kind
  14541. * - VertexBuffer.UV6Kind
  14542. * - VertexBuffer.ColorKind
  14543. * - VertexBuffer.MatricesIndicesKind
  14544. * - VertexBuffer.MatricesIndicesExtraKind
  14545. * - VertexBuffer.MatricesWeightsKind
  14546. * - VertexBuffer.MatricesWeightsExtraKind
  14547. * @returns a boolean
  14548. */
  14549. isVertexBufferUpdatable(kind: string): boolean;
  14550. /**
  14551. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  14552. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  14553. * - VertexBuffer.PositionKind
  14554. * - VertexBuffer.NormalKind
  14555. * - VertexBuffer.UVKind
  14556. * - VertexBuffer.UV2Kind
  14557. * - VertexBuffer.UV3Kind
  14558. * - VertexBuffer.UV4Kind
  14559. * - VertexBuffer.UV5Kind
  14560. * - VertexBuffer.UV6Kind
  14561. * - VertexBuffer.ColorKind
  14562. * - VertexBuffer.MatricesIndicesKind
  14563. * - VertexBuffer.MatricesIndicesExtraKind
  14564. * - VertexBuffer.MatricesWeightsKind
  14565. * - VertexBuffer.MatricesWeightsExtraKind
  14566. * @returns an array of strings
  14567. */
  14568. getVerticesDataKinds(): string[];
  14569. /**
  14570. * Returns a positive integer : the total number of indices in this mesh geometry.
  14571. * @returns the numner of indices or zero if the mesh has no geometry.
  14572. */
  14573. getTotalIndices(): number;
  14574. /**
  14575. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  14576. * @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.
  14577. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  14578. * @returns the indices array or an empty array if the mesh has no geometry
  14579. */
  14580. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  14581. readonly isBlocked: boolean;
  14582. /**
  14583. * Determine if the current mesh is ready to be rendered
  14584. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  14585. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  14586. * @returns true if all associated assets are ready (material, textures, shaders)
  14587. */
  14588. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  14589. /**
  14590. * 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.
  14591. */
  14592. readonly areNormalsFrozen: boolean;
  14593. /**
  14594. * 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.
  14595. * @returns the current mesh
  14596. */
  14597. freezeNormals(): Mesh;
  14598. /**
  14599. * 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
  14600. * @returns the current mesh
  14601. */
  14602. unfreezeNormals(): Mesh;
  14603. /**
  14604. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  14605. */
  14606. overridenInstanceCount: number;
  14607. /** @hidden */
  14608. _preActivate(): Mesh;
  14609. /** @hidden */
  14610. _preActivateForIntermediateRendering(renderId: number): Mesh;
  14611. /** @hidden */
  14612. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  14613. /**
  14614. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  14615. * This means the mesh underlying bounding box and sphere are recomputed.
  14616. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  14617. * @returns the current mesh
  14618. */
  14619. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  14620. /** @hidden */
  14621. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  14622. /**
  14623. * This function will subdivide the mesh into multiple submeshes
  14624. * @param count defines the expected number of submeshes
  14625. */
  14626. subdivide(count: number): void;
  14627. /**
  14628. * Copy a FloatArray into a specific associated vertex buffer
  14629. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14630. * - VertexBuffer.PositionKind
  14631. * - VertexBuffer.UVKind
  14632. * - VertexBuffer.UV2Kind
  14633. * - VertexBuffer.UV3Kind
  14634. * - VertexBuffer.UV4Kind
  14635. * - VertexBuffer.UV5Kind
  14636. * - VertexBuffer.UV6Kind
  14637. * - VertexBuffer.ColorKind
  14638. * - VertexBuffer.MatricesIndicesKind
  14639. * - VertexBuffer.MatricesIndicesExtraKind
  14640. * - VertexBuffer.MatricesWeightsKind
  14641. * - VertexBuffer.MatricesWeightsExtraKind
  14642. * @param data defines the data source
  14643. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14644. * @param stride defines the data stride size (can be null)
  14645. * @returns the current mesh
  14646. */
  14647. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  14648. /**
  14649. * Flags an associated vertex buffer as updatable
  14650. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  14651. * - VertexBuffer.PositionKind
  14652. * - VertexBuffer.UVKind
  14653. * - VertexBuffer.UV2Kind
  14654. * - VertexBuffer.UV3Kind
  14655. * - VertexBuffer.UV4Kind
  14656. * - VertexBuffer.UV5Kind
  14657. * - VertexBuffer.UV6Kind
  14658. * - VertexBuffer.ColorKind
  14659. * - VertexBuffer.MatricesIndicesKind
  14660. * - VertexBuffer.MatricesIndicesExtraKind
  14661. * - VertexBuffer.MatricesWeightsKind
  14662. * - VertexBuffer.MatricesWeightsExtraKind
  14663. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  14664. */
  14665. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  14666. /**
  14667. * Sets the mesh global Vertex Buffer
  14668. * @param buffer defines the buffer to use
  14669. * @returns the current mesh
  14670. */
  14671. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  14672. /**
  14673. * Update a specific associated vertex buffer
  14674. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  14675. * - VertexBuffer.PositionKind
  14676. * - VertexBuffer.UVKind
  14677. * - VertexBuffer.UV2Kind
  14678. * - VertexBuffer.UV3Kind
  14679. * - VertexBuffer.UV4Kind
  14680. * - VertexBuffer.UV5Kind
  14681. * - VertexBuffer.UV6Kind
  14682. * - VertexBuffer.ColorKind
  14683. * - VertexBuffer.MatricesIndicesKind
  14684. * - VertexBuffer.MatricesIndicesExtraKind
  14685. * - VertexBuffer.MatricesWeightsKind
  14686. * - VertexBuffer.MatricesWeightsExtraKind
  14687. * @param data defines the data source
  14688. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  14689. * @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)
  14690. * @returns the current mesh
  14691. */
  14692. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  14693. /**
  14694. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  14695. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  14696. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  14697. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  14698. * @returns the current mesh
  14699. */
  14700. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  14701. /**
  14702. * Creates a un-shared specific occurence of the geometry for the mesh.
  14703. * @returns the current mesh
  14704. */
  14705. makeGeometryUnique(): Mesh;
  14706. /**
  14707. * Set the index buffer of this mesh
  14708. * @param indices defines the source data
  14709. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  14710. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  14711. * @returns the current mesh
  14712. */
  14713. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  14714. /**
  14715. * Update the current index buffer
  14716. * @param indices defines the source data
  14717. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  14718. * @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)
  14719. * @returns the current mesh
  14720. */
  14721. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  14722. /**
  14723. * Invert the geometry to move from a right handed system to a left handed one.
  14724. * @returns the current mesh
  14725. */
  14726. toLeftHanded(): Mesh;
  14727. /** @hidden */
  14728. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  14729. /** @hidden */
  14730. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  14731. /**
  14732. * Registers for this mesh a javascript function called just before the rendering process
  14733. * @param func defines the function to call before rendering this mesh
  14734. * @returns the current mesh
  14735. */
  14736. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14737. /**
  14738. * Disposes a previously registered javascript function called before the rendering
  14739. * @param func defines the function to remove
  14740. * @returns the current mesh
  14741. */
  14742. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  14743. /**
  14744. * Registers for this mesh a javascript function called just after the rendering is complete
  14745. * @param func defines the function to call after rendering this mesh
  14746. * @returns the current mesh
  14747. */
  14748. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14749. /**
  14750. * Disposes a previously registered javascript function called after the rendering.
  14751. * @param func defines the function to remove
  14752. * @returns the current mesh
  14753. */
  14754. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  14755. /** @hidden */
  14756. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  14757. /** @hidden */
  14758. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  14759. /** @hidden */
  14760. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  14761. /** @hidden */
  14762. _rebuild(): void;
  14763. /** @hidden */
  14764. _freeze(): void;
  14765. /** @hidden */
  14766. _unFreeze(): void;
  14767. /**
  14768. * 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
  14769. * @param subMesh defines the subMesh to render
  14770. * @param enableAlphaMode defines if alpha mode can be changed
  14771. * @returns the current mesh
  14772. */
  14773. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  14774. private _onBeforeDraw;
  14775. /**
  14776. * Renormalize the mesh and patch it up if there are no weights
  14777. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  14778. * However in the case of zero weights then we set just a single influence to 1.
  14779. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  14780. */
  14781. cleanMatrixWeights(): void;
  14782. private normalizeSkinFourWeights;
  14783. private normalizeSkinWeightsAndExtra;
  14784. /**
  14785. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  14786. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  14787. * the user know there was an issue with importing the mesh
  14788. * @returns a validation object with skinned, valid and report string
  14789. */
  14790. validateSkinning(): {
  14791. skinned: boolean;
  14792. valid: boolean;
  14793. report: string;
  14794. };
  14795. /** @hidden */
  14796. _checkDelayState(): Mesh;
  14797. private _queueLoad;
  14798. /**
  14799. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  14800. * A mesh is in the frustum if its bounding box intersects the frustum
  14801. * @param frustumPlanes defines the frustum to test
  14802. * @returns true if the mesh is in the frustum planes
  14803. */
  14804. isInFrustum(frustumPlanes: Plane[]): boolean;
  14805. /**
  14806. * Sets the mesh material by the material or multiMaterial `id` property
  14807. * @param id is a string identifying the material or the multiMaterial
  14808. * @returns the current mesh
  14809. */
  14810. setMaterialByID(id: string): Mesh;
  14811. /**
  14812. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  14813. * @returns an array of IAnimatable
  14814. */
  14815. getAnimatables(): IAnimatable[];
  14816. /**
  14817. * Modifies the mesh geometry according to the passed transformation matrix.
  14818. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  14819. * The mesh normals are modified using the same transformation.
  14820. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14821. * @param transform defines the transform matrix to use
  14822. * @see http://doc.babylonjs.com/resources/baking_transformations
  14823. * @returns the current mesh
  14824. */
  14825. bakeTransformIntoVertices(transform: Matrix): Mesh;
  14826. /**
  14827. * Modifies the mesh geometry according to its own current World Matrix.
  14828. * The mesh World Matrix is then reset.
  14829. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  14830. * Note that, under the hood, this method sets a new VertexBuffer each call.
  14831. * @see http://doc.babylonjs.com/resources/baking_transformations
  14832. * @returns the current mesh
  14833. */
  14834. bakeCurrentTransformIntoVertices(): Mesh;
  14835. /** @hidden */
  14836. readonly _positions: Nullable<Vector3[]>;
  14837. /** @hidden */
  14838. _resetPointsArrayCache(): Mesh;
  14839. /** @hidden */
  14840. _generatePointsArray(): boolean;
  14841. /**
  14842. * Returns a new Mesh object generated from the current mesh properties.
  14843. * This method must not get confused with createInstance()
  14844. * @param name is a string, the name given to the new mesh
  14845. * @param newParent can be any Node object (default `null`)
  14846. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  14847. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  14848. * @returns a new mesh
  14849. */
  14850. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  14851. /**
  14852. * Releases resources associated with this mesh.
  14853. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14854. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14855. */
  14856. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14857. /**
  14858. * Modifies the mesh geometry according to a displacement map.
  14859. * 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.
  14860. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14861. * @param url is a string, the URL from the image file is to be downloaded.
  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. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14871. /**
  14872. * Modifies the mesh geometry according to a displacementMap buffer.
  14873. * 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.
  14874. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  14875. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  14876. * @param heightMapWidth is the width of the buffer image.
  14877. * @param heightMapHeight is the height of the buffer image.
  14878. * @param minHeight is the lower limit of the displacement.
  14879. * @param maxHeight is the upper limit of the displacement.
  14880. * @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.
  14881. * @param uvOffset is an optional vector2 used to offset UV.
  14882. * @param uvScale is an optional vector2 used to scale UV.
  14883. * @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.
  14884. * @returns the Mesh.
  14885. */
  14886. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  14887. /**
  14888. * Modify the mesh to get a flat shading rendering.
  14889. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  14890. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  14891. * @returns current mesh
  14892. */
  14893. convertToFlatShadedMesh(): Mesh;
  14894. /**
  14895. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  14896. * In other words, more vertices, no more indices and a single bigger VBO.
  14897. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  14898. * @returns current mesh
  14899. */
  14900. convertToUnIndexedMesh(): Mesh;
  14901. /**
  14902. * Inverses facet orientations.
  14903. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14904. * @param flipNormals will also inverts the normals
  14905. * @returns current mesh
  14906. */
  14907. flipFaces(flipNormals?: boolean): Mesh;
  14908. /**
  14909. * Increase the number of facets and hence vertices in a mesh
  14910. * Vertex normals are interpolated from existing vertex normals
  14911. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14912. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  14913. */
  14914. increaseVertices(numberPerEdge: number): void;
  14915. /**
  14916. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  14917. * This will undo any application of covertToFlatShadedMesh
  14918. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  14919. */
  14920. forceSharedVertices(): void;
  14921. /** @hidden */
  14922. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  14923. /** @hidden */
  14924. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  14925. /**
  14926. * Creates a new InstancedMesh object from the mesh model.
  14927. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  14928. * @param name defines the name of the new instance
  14929. * @returns a new InstancedMesh
  14930. */
  14931. createInstance(name: string): InstancedMesh;
  14932. /**
  14933. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  14934. * After this call, all the mesh instances have the same submeshes than the current mesh.
  14935. * @returns the current mesh
  14936. */
  14937. synchronizeInstances(): Mesh;
  14938. /**
  14939. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  14940. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  14941. * This should be used together with the simplification to avoid disappearing triangles.
  14942. * @param successCallback an optional success callback to be called after the optimization finished.
  14943. * @returns the current mesh
  14944. */
  14945. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  14946. /**
  14947. * Serialize current mesh
  14948. * @param serializationObject defines the object which will receive the serialization data
  14949. */
  14950. serialize(serializationObject: any): void;
  14951. /** @hidden */
  14952. _syncGeometryWithMorphTargetManager(): void;
  14953. /** @hidden */
  14954. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  14955. /**
  14956. * Returns a new Mesh object parsed from the source provided.
  14957. * @param parsedMesh is the source
  14958. * @param scene defines the hosting scene
  14959. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  14960. * @returns a new Mesh
  14961. */
  14962. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  14963. /**
  14964. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  14965. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  14966. * @param name defines the name of the mesh to create
  14967. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  14968. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  14969. * @param closePath creates a seam between the first and the last points of each path of the path array
  14970. * @param offset is taken in account only if the `pathArray` is containing a single path
  14971. * @param scene defines the hosting scene
  14972. * @param updatable defines if the mesh must be flagged as updatable
  14973. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14974. * @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)
  14975. * @returns a new Mesh
  14976. */
  14977. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  14978. /**
  14979. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  14980. * @param name defines the name of the mesh to create
  14981. * @param radius sets the radius size (float) of the polygon (default 0.5)
  14982. * @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
  14983. * @param scene defines the hosting scene
  14984. * @param updatable defines if the mesh must be flagged as updatable
  14985. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14986. * @returns a new Mesh
  14987. */
  14988. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14989. /**
  14990. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  14991. * @param name defines the name of the mesh to create
  14992. * @param size sets the size (float) of each box side (default 1)
  14993. * @param scene defines the hosting scene
  14994. * @param updatable defines if the mesh must be flagged as updatable
  14995. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  14996. * @returns a new Mesh
  14997. */
  14998. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  14999. /**
  15000. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  15001. * @param name defines the name of the mesh to create
  15002. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  15003. * @param diameter sets the diameter size (float) of the sphere (default 1)
  15004. * @param scene defines the hosting scene
  15005. * @param updatable defines if the mesh must be flagged as updatable
  15006. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15007. * @returns a new Mesh
  15008. */
  15009. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15010. /**
  15011. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  15012. * @param name defines the name of the mesh to create
  15013. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  15014. * @param diameter sets the diameter size (float) of the sphere (default 1)
  15015. * @param scene defines the hosting scene
  15016. * @returns a new Mesh
  15017. */
  15018. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  15019. /**
  15020. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  15021. * @param name defines the name of the mesh to create
  15022. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  15023. * @param diameterTop set the top cap diameter (floats, default 1)
  15024. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  15025. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  15026. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  15027. * @param scene defines the hosting scene
  15028. * @param updatable defines if the mesh must be flagged as updatable
  15029. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15030. * @returns a new Mesh
  15031. */
  15032. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  15033. /**
  15034. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  15035. * @param name defines the name of the mesh to create
  15036. * @param diameter sets the diameter size (float) of the torus (default 1)
  15037. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  15038. * @param tessellation sets the number of torus sides (postive integer, default 16)
  15039. * @param scene defines the hosting scene
  15040. * @param updatable defines if the mesh must be flagged as updatable
  15041. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15042. * @returns a new Mesh
  15043. */
  15044. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15045. /**
  15046. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  15047. * @param name defines the name of the mesh to create
  15048. * @param radius sets the global radius size (float) of the torus knot (default 2)
  15049. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  15050. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  15051. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  15052. * @param p the number of windings on X axis (positive integers, default 2)
  15053. * @param q the number of windings on Y axis (positive integers, default 3)
  15054. * @param scene defines the hosting scene
  15055. * @param updatable defines if the mesh must be flagged as updatable
  15056. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15057. * @returns a new Mesh
  15058. */
  15059. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15060. /**
  15061. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  15062. * @param name defines the name of the mesh to create
  15063. * @param points is an array successive Vector3
  15064. * @param scene defines the hosting scene
  15065. * @param updatable defines if the mesh must be flagged as updatable
  15066. * @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).
  15067. * @returns a new Mesh
  15068. */
  15069. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  15070. /**
  15071. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  15072. * @param name defines the name of the mesh to create
  15073. * @param points is an array successive Vector3
  15074. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  15075. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  15076. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  15077. * @param scene defines the hosting scene
  15078. * @param updatable defines if the mesh must be flagged as updatable
  15079. * @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)
  15080. * @returns a new Mesh
  15081. */
  15082. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  15083. /**
  15084. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  15085. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  15086. * 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.
  15087. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  15088. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  15089. * Remember you can only change the shape positions, not their number when updating a polygon.
  15090. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  15091. * @param name defines the name of the mesh to create
  15092. * @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
  15093. * @param scene defines the hosting scene
  15094. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  15095. * @param updatable defines if the mesh must be flagged as updatable
  15096. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15097. * @param earcutInjection can be used to inject your own earcut reference
  15098. * @returns a new Mesh
  15099. */
  15100. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  15101. /**
  15102. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  15103. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  15104. * @param name defines the name of the mesh to create
  15105. * @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
  15106. * @param depth defines the height of extrusion
  15107. * @param scene defines the hosting scene
  15108. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  15109. * @param updatable defines if the mesh must be flagged as updatable
  15110. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15111. * @param earcutInjection can be used to inject your own earcut reference
  15112. * @returns a new Mesh
  15113. */
  15114. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  15115. /**
  15116. * Creates an extruded shape mesh.
  15117. * 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
  15118. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  15119. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  15120. * @param name defines the name of the mesh to create
  15121. * @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
  15122. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  15123. * @param scale is the value to scale the shape
  15124. * @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
  15125. * @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
  15126. * @param scene defines the hosting scene
  15127. * @param updatable defines if the mesh must be flagged as updatable
  15128. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15129. * @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)
  15130. * @returns a new Mesh
  15131. */
  15132. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  15133. /**
  15134. * Creates an custom extruded shape mesh.
  15135. * The custom extrusion is a parametric shape.
  15136. * It has no predefined shape. Its final shape will depend on the input parameters.
  15137. * Please consider using the same method from the MeshBuilder class instead
  15138. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  15139. * @param name defines the name of the mesh to create
  15140. * @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
  15141. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  15142. * @param scaleFunction is a custom Javascript function called on each path point
  15143. * @param rotationFunction is a custom Javascript function called on each path point
  15144. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  15145. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  15146. * @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
  15147. * @param scene defines the hosting scene
  15148. * @param updatable defines if the mesh must be flagged as updatable
  15149. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15150. * @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)
  15151. * @returns a new Mesh
  15152. */
  15153. 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;
  15154. /**
  15155. * Creates lathe mesh.
  15156. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  15157. * Please consider using the same method from the MeshBuilder class instead
  15158. * @param name defines the name of the mesh to create
  15159. * @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
  15160. * @param radius is the radius value of the lathe
  15161. * @param tessellation is the side number of the lathe.
  15162. * @param scene defines the hosting scene
  15163. * @param updatable defines if the mesh must be flagged as updatable
  15164. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15165. * @returns a new Mesh
  15166. */
  15167. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15168. /**
  15169. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  15170. * @param name defines the name of the mesh to create
  15171. * @param size sets the size (float) of both sides of the plane at once (default 1)
  15172. * @param scene defines the hosting scene
  15173. * @param updatable defines if the mesh must be flagged as updatable
  15174. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15175. * @returns a new Mesh
  15176. */
  15177. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  15178. /**
  15179. * Creates a ground mesh.
  15180. * Please consider using the same method from the MeshBuilder class instead
  15181. * @param name defines the name of the mesh to create
  15182. * @param width set the width of the ground
  15183. * @param height set the height of the ground
  15184. * @param subdivisions sets the number of subdivisions per side
  15185. * @param scene defines the hosting scene
  15186. * @param updatable defines if the mesh must be flagged as updatable
  15187. * @returns a new Mesh
  15188. */
  15189. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  15190. /**
  15191. * Creates a tiled ground mesh.
  15192. * Please consider using the same method from the MeshBuilder class instead
  15193. * @param name defines the name of the mesh to create
  15194. * @param xmin set the ground minimum X coordinate
  15195. * @param zmin set the ground minimum Y coordinate
  15196. * @param xmax set the ground maximum X coordinate
  15197. * @param zmax set the ground maximum Z coordinate
  15198. * @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
  15199. * @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
  15200. * @param scene defines the hosting scene
  15201. * @param updatable defines if the mesh must be flagged as updatable
  15202. * @returns a new Mesh
  15203. */
  15204. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  15205. w: number;
  15206. h: number;
  15207. }, precision: {
  15208. w: number;
  15209. h: number;
  15210. }, scene: Scene, updatable?: boolean): Mesh;
  15211. /**
  15212. * Creates a ground mesh from a height map.
  15213. * Please consider using the same method from the MeshBuilder class instead
  15214. * @see http://doc.babylonjs.com/babylon101/height_map
  15215. * @param name defines the name of the mesh to create
  15216. * @param url sets the URL of the height map image resource
  15217. * @param width set the ground width size
  15218. * @param height set the ground height size
  15219. * @param subdivisions sets the number of subdivision per side
  15220. * @param minHeight is the minimum altitude on the ground
  15221. * @param maxHeight is the maximum altitude on the ground
  15222. * @param scene defines the hosting scene
  15223. * @param updatable defines if the mesh must be flagged as updatable
  15224. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  15225. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  15226. * @returns a new Mesh
  15227. */
  15228. 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;
  15229. /**
  15230. * Creates a tube mesh.
  15231. * The tube is a parametric shape.
  15232. * It has no predefined shape. Its final shape will depend on the input parameters.
  15233. * Please consider using the same method from the MeshBuilder class instead
  15234. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  15235. * @param name defines the name of the mesh to create
  15236. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  15237. * @param radius sets the tube radius size
  15238. * @param tessellation is the number of sides on the tubular surface
  15239. * @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
  15240. * @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
  15241. * @param scene defines the hosting scene
  15242. * @param updatable defines if the mesh must be flagged as updatable
  15243. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  15244. * @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)
  15245. * @returns a new Mesh
  15246. */
  15247. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  15248. (i: number, distance: number): number;
  15249. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  15250. /**
  15251. * Creates a polyhedron mesh.
  15252. * Please consider using the same method from the MeshBuilder class instead.
  15253. * * 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
  15254. * * The parameter `size` (positive float, default 1) sets the polygon size
  15255. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  15256. * * 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`
  15257. * * 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
  15258. * * 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)`)
  15259. * * 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
  15260. * * 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
  15261. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  15262. * * If you create a double-sided mesh, you can choose what parts of 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
  15263. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  15264. * @param name defines the name of the mesh to create
  15265. * @param options defines the options used to create the mesh
  15266. * @param scene defines the hosting scene
  15267. * @returns a new Mesh
  15268. */
  15269. static CreatePolyhedron(name: string, options: {
  15270. type?: number;
  15271. size?: number;
  15272. sizeX?: number;
  15273. sizeY?: number;
  15274. sizeZ?: number;
  15275. custom?: any;
  15276. faceUV?: Vector4[];
  15277. faceColors?: Color4[];
  15278. updatable?: boolean;
  15279. sideOrientation?: number;
  15280. }, scene: Scene): Mesh;
  15281. /**
  15282. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  15283. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  15284. * * 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`)
  15285. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  15286. * * 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
  15287. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  15288. * * If you create a double-sided mesh, you can choose what parts of 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
  15289. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  15290. * @param name defines the name of the mesh
  15291. * @param options defines the options used to create the mesh
  15292. * @param scene defines the hosting scene
  15293. * @returns a new Mesh
  15294. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  15295. */
  15296. static CreateIcoSphere(name: string, options: {
  15297. radius?: number;
  15298. flat?: boolean;
  15299. subdivisions?: number;
  15300. sideOrientation?: number;
  15301. updatable?: boolean;
  15302. }, scene: Scene): Mesh;
  15303. /**
  15304. * Creates a decal mesh.
  15305. * Please consider using the same method from the MeshBuilder class instead.
  15306. * A decal is a mesh usually applied as a model onto the surface of another mesh
  15307. * @param name defines the name of the mesh
  15308. * @param sourceMesh defines the mesh receiving the decal
  15309. * @param position sets the position of the decal in world coordinates
  15310. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  15311. * @param size sets the decal scaling
  15312. * @param angle sets the angle to rotate the decal
  15313. * @returns a new Mesh
  15314. */
  15315. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  15316. /**
  15317. * Prepare internal position array for software CPU skinning
  15318. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  15319. */
  15320. setPositionsForCPUSkinning(): Float32Array;
  15321. /**
  15322. * Prepare internal normal array for software CPU skinning
  15323. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  15324. */
  15325. setNormalsForCPUSkinning(): Float32Array;
  15326. /**
  15327. * Updates the vertex buffer by applying transformation from the bones
  15328. * @param skeleton defines the skeleton to apply to current mesh
  15329. * @returns the current mesh
  15330. */
  15331. applySkeleton(skeleton: Skeleton): Mesh;
  15332. /**
  15333. * 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
  15334. * @param meshes defines the list of meshes to scan
  15335. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  15336. */
  15337. static MinMax(meshes: AbstractMesh[]): {
  15338. min: Vector3;
  15339. max: Vector3;
  15340. };
  15341. /**
  15342. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  15343. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  15344. * @returns a vector3
  15345. */
  15346. static Center(meshesOrMinMaxVector: {
  15347. min: Vector3;
  15348. max: Vector3;
  15349. } | AbstractMesh[]): Vector3;
  15350. /**
  15351. * Merge the array of meshes into a single mesh for performance reasons.
  15352. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  15353. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  15354. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  15355. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  15356. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  15357. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  15358. * @returns a new mesh
  15359. */
  15360. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  15361. /** @hidden */
  15362. addInstance(instance: InstancedMesh): void;
  15363. /** @hidden */
  15364. removeInstance(instance: InstancedMesh): void;
  15365. }
  15366. }
  15367. declare module "babylonjs/Actions/action" {
  15368. import { Observable } from "babylonjs/Misc/observable";
  15369. import { Condition } from "babylonjs/Actions/condition";
  15370. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  15371. import { ActionManager } from "babylonjs/Actions/actionManager";
  15372. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  15373. /**
  15374. * Interface used to define Action
  15375. */
  15376. export interface IAction {
  15377. /**
  15378. * Trigger for the action
  15379. */
  15380. trigger: number;
  15381. /** Options of the trigger */
  15382. triggerOptions: any;
  15383. /**
  15384. * Gets the trigger parameters
  15385. * @returns the trigger parameters
  15386. */
  15387. getTriggerParameter(): any;
  15388. /**
  15389. * Internal only - executes current action event
  15390. * @hidden
  15391. */
  15392. _executeCurrent(evt?: ActionEvent): void;
  15393. /**
  15394. * Serialize placeholder for child classes
  15395. * @param parent of child
  15396. * @returns the serialized object
  15397. */
  15398. serialize(parent: any): any;
  15399. /**
  15400. * Internal only
  15401. * @hidden
  15402. */
  15403. _prepare(): void;
  15404. /**
  15405. * Internal only - manager for action
  15406. * @hidden
  15407. */
  15408. _actionManager: AbstractActionManager;
  15409. /**
  15410. * Adds action to chain of actions, may be a DoNothingAction
  15411. * @param action defines the next action to execute
  15412. * @returns The action passed in
  15413. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15414. */
  15415. then(action: IAction): IAction;
  15416. }
  15417. /**
  15418. * The action to be carried out following a trigger
  15419. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  15420. */
  15421. export class Action implements IAction {
  15422. /** the trigger, with or without parameters, for the action */
  15423. triggerOptions: any;
  15424. /**
  15425. * Trigger for the action
  15426. */
  15427. trigger: number;
  15428. /**
  15429. * Internal only - manager for action
  15430. * @hidden
  15431. */
  15432. _actionManager: ActionManager;
  15433. private _nextActiveAction;
  15434. private _child;
  15435. private _condition?;
  15436. private _triggerParameter;
  15437. /**
  15438. * An event triggered prior to action being executed.
  15439. */
  15440. onBeforeExecuteObservable: Observable<Action>;
  15441. /**
  15442. * Creates a new Action
  15443. * @param triggerOptions the trigger, with or without parameters, for the action
  15444. * @param condition an optional determinant of action
  15445. */
  15446. constructor(
  15447. /** the trigger, with or without parameters, for the action */
  15448. triggerOptions: any, condition?: Condition);
  15449. /**
  15450. * Internal only
  15451. * @hidden
  15452. */
  15453. _prepare(): void;
  15454. /**
  15455. * Gets the trigger parameters
  15456. * @returns the trigger parameters
  15457. */
  15458. getTriggerParameter(): any;
  15459. /**
  15460. * Internal only - executes current action event
  15461. * @hidden
  15462. */
  15463. _executeCurrent(evt?: ActionEvent): void;
  15464. /**
  15465. * Execute placeholder for child classes
  15466. * @param evt optional action event
  15467. */
  15468. execute(evt?: ActionEvent): void;
  15469. /**
  15470. * Skips to next active action
  15471. */
  15472. skipToNextActiveAction(): void;
  15473. /**
  15474. * Adds action to chain of actions, may be a DoNothingAction
  15475. * @param action defines the next action to execute
  15476. * @returns The action passed in
  15477. * @see https://www.babylonjs-playground.com/#1T30HR#0
  15478. */
  15479. then(action: Action): Action;
  15480. /**
  15481. * Internal only
  15482. * @hidden
  15483. */
  15484. _getProperty(propertyPath: string): string;
  15485. /**
  15486. * Internal only
  15487. * @hidden
  15488. */
  15489. _getEffectiveTarget(target: any, propertyPath: string): any;
  15490. /**
  15491. * Serialize placeholder for child classes
  15492. * @param parent of child
  15493. * @returns the serialized object
  15494. */
  15495. serialize(parent: any): any;
  15496. /**
  15497. * Internal only called by serialize
  15498. * @hidden
  15499. */
  15500. protected _serialize(serializedAction: any, parent?: any): any;
  15501. /**
  15502. * Internal only
  15503. * @hidden
  15504. */
  15505. static _SerializeValueAsString: (value: any) => string;
  15506. /**
  15507. * Internal only
  15508. * @hidden
  15509. */
  15510. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  15511. name: string;
  15512. targetType: string;
  15513. value: string;
  15514. };
  15515. }
  15516. }
  15517. declare module "babylonjs/Actions/condition" {
  15518. import { ActionManager } from "babylonjs/Actions/actionManager";
  15519. /**
  15520. * A Condition applied to an Action
  15521. */
  15522. export class Condition {
  15523. /**
  15524. * Internal only - manager for action
  15525. * @hidden
  15526. */
  15527. _actionManager: ActionManager;
  15528. /**
  15529. * Internal only
  15530. * @hidden
  15531. */
  15532. _evaluationId: number;
  15533. /**
  15534. * Internal only
  15535. * @hidden
  15536. */
  15537. _currentResult: boolean;
  15538. /**
  15539. * Creates a new Condition
  15540. * @param actionManager the manager of the action the condition is applied to
  15541. */
  15542. constructor(actionManager: ActionManager);
  15543. /**
  15544. * Check if the current condition is valid
  15545. * @returns a boolean
  15546. */
  15547. isValid(): boolean;
  15548. /**
  15549. * Internal only
  15550. * @hidden
  15551. */
  15552. _getProperty(propertyPath: string): string;
  15553. /**
  15554. * Internal only
  15555. * @hidden
  15556. */
  15557. _getEffectiveTarget(target: any, propertyPath: string): any;
  15558. /**
  15559. * Serialize placeholder for child classes
  15560. * @returns the serialized object
  15561. */
  15562. serialize(): any;
  15563. /**
  15564. * Internal only
  15565. * @hidden
  15566. */
  15567. protected _serialize(serializedCondition: any): any;
  15568. }
  15569. /**
  15570. * Defines specific conditional operators as extensions of Condition
  15571. */
  15572. export class ValueCondition extends Condition {
  15573. /** path to specify the property of the target the conditional operator uses */
  15574. propertyPath: string;
  15575. /** the value compared by the conditional operator against the current value of the property */
  15576. value: any;
  15577. /** the conditional operator, default ValueCondition.IsEqual */
  15578. operator: number;
  15579. /**
  15580. * Internal only
  15581. * @hidden
  15582. */
  15583. private static _IsEqual;
  15584. /**
  15585. * Internal only
  15586. * @hidden
  15587. */
  15588. private static _IsDifferent;
  15589. /**
  15590. * Internal only
  15591. * @hidden
  15592. */
  15593. private static _IsGreater;
  15594. /**
  15595. * Internal only
  15596. * @hidden
  15597. */
  15598. private static _IsLesser;
  15599. /**
  15600. * returns the number for IsEqual
  15601. */
  15602. static readonly IsEqual: number;
  15603. /**
  15604. * Returns the number for IsDifferent
  15605. */
  15606. static readonly IsDifferent: number;
  15607. /**
  15608. * Returns the number for IsGreater
  15609. */
  15610. static readonly IsGreater: number;
  15611. /**
  15612. * Returns the number for IsLesser
  15613. */
  15614. static readonly IsLesser: number;
  15615. /**
  15616. * Internal only The action manager for the condition
  15617. * @hidden
  15618. */
  15619. _actionManager: ActionManager;
  15620. /**
  15621. * Internal only
  15622. * @hidden
  15623. */
  15624. private _target;
  15625. /**
  15626. * Internal only
  15627. * @hidden
  15628. */
  15629. private _effectiveTarget;
  15630. /**
  15631. * Internal only
  15632. * @hidden
  15633. */
  15634. private _property;
  15635. /**
  15636. * Creates a new ValueCondition
  15637. * @param actionManager manager for the action the condition applies to
  15638. * @param target for the action
  15639. * @param propertyPath path to specify the property of the target the conditional operator uses
  15640. * @param value the value compared by the conditional operator against the current value of the property
  15641. * @param operator the conditional operator, default ValueCondition.IsEqual
  15642. */
  15643. constructor(actionManager: ActionManager, target: any,
  15644. /** path to specify the property of the target the conditional operator uses */
  15645. propertyPath: string,
  15646. /** the value compared by the conditional operator against the current value of the property */
  15647. value: any,
  15648. /** the conditional operator, default ValueCondition.IsEqual */
  15649. operator?: number);
  15650. /**
  15651. * Compares the given value with the property value for the specified conditional operator
  15652. * @returns the result of the comparison
  15653. */
  15654. isValid(): boolean;
  15655. /**
  15656. * Serialize the ValueCondition into a JSON compatible object
  15657. * @returns serialization object
  15658. */
  15659. serialize(): any;
  15660. /**
  15661. * Gets the name of the conditional operator for the ValueCondition
  15662. * @param operator the conditional operator
  15663. * @returns the name
  15664. */
  15665. static GetOperatorName(operator: number): string;
  15666. }
  15667. /**
  15668. * Defines a predicate condition as an extension of Condition
  15669. */
  15670. export class PredicateCondition extends Condition {
  15671. /** defines the predicate function used to validate the condition */
  15672. predicate: () => boolean;
  15673. /**
  15674. * Internal only - manager for action
  15675. * @hidden
  15676. */
  15677. _actionManager: ActionManager;
  15678. /**
  15679. * Creates a new PredicateCondition
  15680. * @param actionManager manager for the action the condition applies to
  15681. * @param predicate defines the predicate function used to validate the condition
  15682. */
  15683. constructor(actionManager: ActionManager,
  15684. /** defines the predicate function used to validate the condition */
  15685. predicate: () => boolean);
  15686. /**
  15687. * @returns the validity of the predicate condition
  15688. */
  15689. isValid(): boolean;
  15690. }
  15691. /**
  15692. * Defines a state condition as an extension of Condition
  15693. */
  15694. export class StateCondition extends Condition {
  15695. /** Value to compare with target state */
  15696. value: string;
  15697. /**
  15698. * Internal only - manager for action
  15699. * @hidden
  15700. */
  15701. _actionManager: ActionManager;
  15702. /**
  15703. * Internal only
  15704. * @hidden
  15705. */
  15706. private _target;
  15707. /**
  15708. * Creates a new StateCondition
  15709. * @param actionManager manager for the action the condition applies to
  15710. * @param target of the condition
  15711. * @param value to compare with target state
  15712. */
  15713. constructor(actionManager: ActionManager, target: any,
  15714. /** Value to compare with target state */
  15715. value: string);
  15716. /**
  15717. * Gets a boolean indicating if the current condition is met
  15718. * @returns the validity of the state
  15719. */
  15720. isValid(): boolean;
  15721. /**
  15722. * Serialize the StateCondition into a JSON compatible object
  15723. * @returns serialization object
  15724. */
  15725. serialize(): any;
  15726. }
  15727. }
  15728. declare module "babylonjs/Actions/directActions" {
  15729. import { Action } from "babylonjs/Actions/action";
  15730. import { Condition } from "babylonjs/Actions/condition";
  15731. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  15732. /**
  15733. * This defines an action responsible to toggle a boolean once triggered.
  15734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15735. */
  15736. export class SwitchBooleanAction extends Action {
  15737. /**
  15738. * The path to the boolean property in the target object
  15739. */
  15740. propertyPath: string;
  15741. private _target;
  15742. private _effectiveTarget;
  15743. private _property;
  15744. /**
  15745. * Instantiate the action
  15746. * @param triggerOptions defines the trigger options
  15747. * @param target defines the object containing the boolean
  15748. * @param propertyPath defines the path to the boolean property in the target object
  15749. * @param condition defines the trigger related conditions
  15750. */
  15751. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  15752. /** @hidden */
  15753. _prepare(): void;
  15754. /**
  15755. * Execute the action toggle the boolean value.
  15756. */
  15757. execute(): void;
  15758. /**
  15759. * Serializes the actions and its related information.
  15760. * @param parent defines the object to serialize in
  15761. * @returns the serialized object
  15762. */
  15763. serialize(parent: any): any;
  15764. }
  15765. /**
  15766. * This defines an action responsible to set a the state field of the target
  15767. * to a desired value once triggered.
  15768. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15769. */
  15770. export class SetStateAction extends Action {
  15771. /**
  15772. * The value to store in the state field.
  15773. */
  15774. value: string;
  15775. private _target;
  15776. /**
  15777. * Instantiate the action
  15778. * @param triggerOptions defines the trigger options
  15779. * @param target defines the object containing the state property
  15780. * @param value defines the value to store in the state field
  15781. * @param condition defines the trigger related conditions
  15782. */
  15783. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  15784. /**
  15785. * Execute the action and store the value on the target state property.
  15786. */
  15787. execute(): void;
  15788. /**
  15789. * Serializes the actions and its related information.
  15790. * @param parent defines the object to serialize in
  15791. * @returns the serialized object
  15792. */
  15793. serialize(parent: any): any;
  15794. }
  15795. /**
  15796. * This defines an action responsible to set a property of the target
  15797. * to a desired value once triggered.
  15798. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15799. */
  15800. export class SetValueAction extends Action {
  15801. /**
  15802. * The path of the property to set in the target.
  15803. */
  15804. propertyPath: string;
  15805. /**
  15806. * The value to set in the property
  15807. */
  15808. value: any;
  15809. private _target;
  15810. private _effectiveTarget;
  15811. private _property;
  15812. /**
  15813. * Instantiate the action
  15814. * @param triggerOptions defines the trigger options
  15815. * @param target defines the object containing the property
  15816. * @param propertyPath defines the path of the property to set in the target
  15817. * @param value defines the value to set in the property
  15818. * @param condition defines the trigger related conditions
  15819. */
  15820. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15821. /** @hidden */
  15822. _prepare(): void;
  15823. /**
  15824. * Execute the action and set the targetted property to the desired value.
  15825. */
  15826. execute(): void;
  15827. /**
  15828. * Serializes the actions and its related information.
  15829. * @param parent defines the object to serialize in
  15830. * @returns the serialized object
  15831. */
  15832. serialize(parent: any): any;
  15833. }
  15834. /**
  15835. * This defines an action responsible to increment the target value
  15836. * to a desired value once triggered.
  15837. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15838. */
  15839. export class IncrementValueAction extends Action {
  15840. /**
  15841. * The path of the property to increment in the target.
  15842. */
  15843. propertyPath: string;
  15844. /**
  15845. * The value we should increment the property by.
  15846. */
  15847. value: any;
  15848. private _target;
  15849. private _effectiveTarget;
  15850. private _property;
  15851. /**
  15852. * Instantiate the action
  15853. * @param triggerOptions defines the trigger options
  15854. * @param target defines the object containing the property
  15855. * @param propertyPath defines the path of the property to increment in the target
  15856. * @param value defines the value value we should increment the property by
  15857. * @param condition defines the trigger related conditions
  15858. */
  15859. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  15860. /** @hidden */
  15861. _prepare(): void;
  15862. /**
  15863. * Execute the action and increment the target of the value amount.
  15864. */
  15865. execute(): void;
  15866. /**
  15867. * Serializes the actions and its related information.
  15868. * @param parent defines the object to serialize in
  15869. * @returns the serialized object
  15870. */
  15871. serialize(parent: any): any;
  15872. }
  15873. /**
  15874. * This defines an action responsible to start an animation once triggered.
  15875. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15876. */
  15877. export class PlayAnimationAction extends Action {
  15878. /**
  15879. * Where the animation should start (animation frame)
  15880. */
  15881. from: number;
  15882. /**
  15883. * Where the animation should stop (animation frame)
  15884. */
  15885. to: number;
  15886. /**
  15887. * Define if the animation should loop or stop after the first play.
  15888. */
  15889. loop?: boolean;
  15890. private _target;
  15891. /**
  15892. * Instantiate the action
  15893. * @param triggerOptions defines the trigger options
  15894. * @param target defines the target animation or animation name
  15895. * @param from defines from where the animation should start (animation frame)
  15896. * @param end defines where the animation should stop (animation frame)
  15897. * @param loop defines if the animation should loop or stop after the first play
  15898. * @param condition defines the trigger related conditions
  15899. */
  15900. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  15901. /** @hidden */
  15902. _prepare(): void;
  15903. /**
  15904. * Execute the action and play the animation.
  15905. */
  15906. execute(): void;
  15907. /**
  15908. * Serializes the actions and its related information.
  15909. * @param parent defines the object to serialize in
  15910. * @returns the serialized object
  15911. */
  15912. serialize(parent: any): any;
  15913. }
  15914. /**
  15915. * This defines an action responsible to stop an animation once triggered.
  15916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15917. */
  15918. export class StopAnimationAction extends Action {
  15919. private _target;
  15920. /**
  15921. * Instantiate the action
  15922. * @param triggerOptions defines the trigger options
  15923. * @param target defines the target animation or animation name
  15924. * @param condition defines the trigger related conditions
  15925. */
  15926. constructor(triggerOptions: any, target: any, condition?: Condition);
  15927. /** @hidden */
  15928. _prepare(): void;
  15929. /**
  15930. * Execute the action and stop the animation.
  15931. */
  15932. execute(): void;
  15933. /**
  15934. * Serializes the actions and its related information.
  15935. * @param parent defines the object to serialize in
  15936. * @returns the serialized object
  15937. */
  15938. serialize(parent: any): any;
  15939. }
  15940. /**
  15941. * This defines an action responsible that does nothing once triggered.
  15942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15943. */
  15944. export class DoNothingAction extends Action {
  15945. /**
  15946. * Instantiate the action
  15947. * @param triggerOptions defines the trigger options
  15948. * @param condition defines the trigger related conditions
  15949. */
  15950. constructor(triggerOptions?: any, condition?: Condition);
  15951. /**
  15952. * Execute the action and do nothing.
  15953. */
  15954. execute(): void;
  15955. /**
  15956. * Serializes the actions and its related information.
  15957. * @param parent defines the object to serialize in
  15958. * @returns the serialized object
  15959. */
  15960. serialize(parent: any): any;
  15961. }
  15962. /**
  15963. * This defines an action responsible to trigger several actions once triggered.
  15964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15965. */
  15966. export class CombineAction extends Action {
  15967. /**
  15968. * The list of aggregated animations to run.
  15969. */
  15970. children: Action[];
  15971. /**
  15972. * Instantiate the action
  15973. * @param triggerOptions defines the trigger options
  15974. * @param children defines the list of aggregated animations to run
  15975. * @param condition defines the trigger related conditions
  15976. */
  15977. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  15978. /** @hidden */
  15979. _prepare(): void;
  15980. /**
  15981. * Execute the action and executes all the aggregated actions.
  15982. */
  15983. execute(evt: ActionEvent): void;
  15984. /**
  15985. * Serializes the actions and its related information.
  15986. * @param parent defines the object to serialize in
  15987. * @returns the serialized object
  15988. */
  15989. serialize(parent: any): any;
  15990. }
  15991. /**
  15992. * This defines an action responsible to run code (external event) once triggered.
  15993. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  15994. */
  15995. export class ExecuteCodeAction extends Action {
  15996. /**
  15997. * The callback function to run.
  15998. */
  15999. func: (evt: ActionEvent) => void;
  16000. /**
  16001. * Instantiate the action
  16002. * @param triggerOptions defines the trigger options
  16003. * @param func defines the callback function to run
  16004. * @param condition defines the trigger related conditions
  16005. */
  16006. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  16007. /**
  16008. * Execute the action and run the attached code.
  16009. */
  16010. execute(evt: ActionEvent): void;
  16011. }
  16012. /**
  16013. * This defines an action responsible to set the parent property of the target once triggered.
  16014. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  16015. */
  16016. export class SetParentAction extends Action {
  16017. private _parent;
  16018. private _target;
  16019. /**
  16020. * Instantiate the action
  16021. * @param triggerOptions defines the trigger options
  16022. * @param target defines the target containing the parent property
  16023. * @param parent defines from where the animation should start (animation frame)
  16024. * @param condition defines the trigger related conditions
  16025. */
  16026. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  16027. /** @hidden */
  16028. _prepare(): void;
  16029. /**
  16030. * Execute the action and set the parent property.
  16031. */
  16032. execute(): void;
  16033. /**
  16034. * Serializes the actions and its related information.
  16035. * @param parent defines the object to serialize in
  16036. * @returns the serialized object
  16037. */
  16038. serialize(parent: any): any;
  16039. }
  16040. }
  16041. declare module "babylonjs/Actions/actionManager" {
  16042. import { Nullable } from "babylonjs/types";
  16043. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16044. import { Scene } from "babylonjs/scene";
  16045. import { IAction } from "babylonjs/Actions/action";
  16046. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  16047. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  16048. /**
  16049. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  16050. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  16051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  16052. */
  16053. export class ActionManager extends AbstractActionManager {
  16054. /**
  16055. * Nothing
  16056. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16057. */
  16058. static readonly NothingTrigger: number;
  16059. /**
  16060. * On pick
  16061. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16062. */
  16063. static readonly OnPickTrigger: number;
  16064. /**
  16065. * On left pick
  16066. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16067. */
  16068. static readonly OnLeftPickTrigger: number;
  16069. /**
  16070. * On right pick
  16071. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16072. */
  16073. static readonly OnRightPickTrigger: number;
  16074. /**
  16075. * On center pick
  16076. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16077. */
  16078. static readonly OnCenterPickTrigger: number;
  16079. /**
  16080. * On pick down
  16081. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16082. */
  16083. static readonly OnPickDownTrigger: number;
  16084. /**
  16085. * On double pick
  16086. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16087. */
  16088. static readonly OnDoublePickTrigger: number;
  16089. /**
  16090. * On pick up
  16091. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16092. */
  16093. static readonly OnPickUpTrigger: number;
  16094. /**
  16095. * On pick out.
  16096. * This trigger will only be raised if you also declared a OnPickDown
  16097. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16098. */
  16099. static readonly OnPickOutTrigger: number;
  16100. /**
  16101. * On long press
  16102. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16103. */
  16104. static readonly OnLongPressTrigger: number;
  16105. /**
  16106. * On pointer over
  16107. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16108. */
  16109. static readonly OnPointerOverTrigger: number;
  16110. /**
  16111. * On pointer out
  16112. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16113. */
  16114. static readonly OnPointerOutTrigger: number;
  16115. /**
  16116. * On every frame
  16117. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16118. */
  16119. static readonly OnEveryFrameTrigger: number;
  16120. /**
  16121. * On intersection enter
  16122. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16123. */
  16124. static readonly OnIntersectionEnterTrigger: number;
  16125. /**
  16126. * On intersection exit
  16127. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16128. */
  16129. static readonly OnIntersectionExitTrigger: number;
  16130. /**
  16131. * On key down
  16132. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16133. */
  16134. static readonly OnKeyDownTrigger: number;
  16135. /**
  16136. * On key up
  16137. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  16138. */
  16139. static readonly OnKeyUpTrigger: number;
  16140. private _scene;
  16141. /**
  16142. * Creates a new action manager
  16143. * @param scene defines the hosting scene
  16144. */
  16145. constructor(scene: Scene);
  16146. /**
  16147. * Releases all associated resources
  16148. */
  16149. dispose(): void;
  16150. /**
  16151. * Gets hosting scene
  16152. * @returns the hosting scene
  16153. */
  16154. getScene(): Scene;
  16155. /**
  16156. * Does this action manager handles actions of any of the given triggers
  16157. * @param triggers defines the triggers to be tested
  16158. * @return a boolean indicating whether one (or more) of the triggers is handled
  16159. */
  16160. hasSpecificTriggers(triggers: number[]): boolean;
  16161. /**
  16162. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  16163. * speed.
  16164. * @param triggerA defines the trigger to be tested
  16165. * @param triggerB defines the trigger to be tested
  16166. * @return a boolean indicating whether one (or more) of the triggers is handled
  16167. */
  16168. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  16169. /**
  16170. * Does this action manager handles actions of a given trigger
  16171. * @param trigger defines the trigger to be tested
  16172. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  16173. * @return whether the trigger is handled
  16174. */
  16175. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  16176. /**
  16177. * Does this action manager has pointer triggers
  16178. */
  16179. readonly hasPointerTriggers: boolean;
  16180. /**
  16181. * Does this action manager has pick triggers
  16182. */
  16183. readonly hasPickTriggers: boolean;
  16184. /**
  16185. * Registers an action to this action manager
  16186. * @param action defines the action to be registered
  16187. * @return the action amended (prepared) after registration
  16188. */
  16189. registerAction(action: IAction): Nullable<IAction>;
  16190. /**
  16191. * Unregisters an action to this action manager
  16192. * @param action defines the action to be unregistered
  16193. * @return a boolean indicating whether the action has been unregistered
  16194. */
  16195. unregisterAction(action: IAction): Boolean;
  16196. /**
  16197. * Process a specific trigger
  16198. * @param trigger defines the trigger to process
  16199. * @param evt defines the event details to be processed
  16200. */
  16201. processTrigger(trigger: number, evt?: IActionEvent): void;
  16202. /** @hidden */
  16203. _getEffectiveTarget(target: any, propertyPath: string): any;
  16204. /** @hidden */
  16205. _getProperty(propertyPath: string): string;
  16206. /**
  16207. * Serialize this manager to a JSON object
  16208. * @param name defines the property name to store this manager
  16209. * @returns a JSON representation of this manager
  16210. */
  16211. serialize(name: string): any;
  16212. /**
  16213. * Creates a new ActionManager from a JSON data
  16214. * @param parsedActions defines the JSON data to read from
  16215. * @param object defines the hosting mesh
  16216. * @param scene defines the hosting scene
  16217. */
  16218. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  16219. /**
  16220. * Get a trigger name by index
  16221. * @param trigger defines the trigger index
  16222. * @returns a trigger name
  16223. */
  16224. static GetTriggerName(trigger: number): string;
  16225. }
  16226. }
  16227. declare module "babylonjs/Culling/ray" {
  16228. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  16229. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  16230. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16231. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16232. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  16233. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  16234. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  16235. /**
  16236. * Class representing a ray with position and direction
  16237. */
  16238. export class Ray {
  16239. /** origin point */
  16240. origin: Vector3;
  16241. /** direction */
  16242. direction: Vector3;
  16243. /** length of the ray */
  16244. length: number;
  16245. private static readonly TmpVector3;
  16246. private _tmpRay;
  16247. /**
  16248. * Creates a new ray
  16249. * @param origin origin point
  16250. * @param direction direction
  16251. * @param length length of the ray
  16252. */
  16253. constructor(
  16254. /** origin point */
  16255. origin: Vector3,
  16256. /** direction */
  16257. direction: Vector3,
  16258. /** length of the ray */
  16259. length?: number);
  16260. /**
  16261. * Checks if the ray intersects a box
  16262. * @param minimum bound of the box
  16263. * @param maximum bound of the box
  16264. * @param intersectionTreshold extra extend to be added to the box in all direction
  16265. * @returns if the box was hit
  16266. */
  16267. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  16268. /**
  16269. * Checks if the ray intersects a box
  16270. * @param box the bounding box to check
  16271. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  16272. * @returns if the box was hit
  16273. */
  16274. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  16275. /**
  16276. * If the ray hits a sphere
  16277. * @param sphere the bounding sphere to check
  16278. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  16279. * @returns true if it hits the sphere
  16280. */
  16281. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  16282. /**
  16283. * If the ray hits a triange
  16284. * @param vertex0 triangle vertex
  16285. * @param vertex1 triangle vertex
  16286. * @param vertex2 triangle vertex
  16287. * @returns intersection information if hit
  16288. */
  16289. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  16290. /**
  16291. * Checks if ray intersects a plane
  16292. * @param plane the plane to check
  16293. * @returns the distance away it was hit
  16294. */
  16295. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  16296. /**
  16297. * Checks if ray intersects a mesh
  16298. * @param mesh the mesh to check
  16299. * @param fastCheck if only the bounding box should checked
  16300. * @returns picking info of the intersecton
  16301. */
  16302. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  16303. /**
  16304. * Checks if ray intersects a mesh
  16305. * @param meshes the meshes to check
  16306. * @param fastCheck if only the bounding box should checked
  16307. * @param results array to store result in
  16308. * @returns Array of picking infos
  16309. */
  16310. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  16311. private _comparePickingInfo;
  16312. private static smallnum;
  16313. private static rayl;
  16314. /**
  16315. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  16316. * @param sega the first point of the segment to test the intersection against
  16317. * @param segb the second point of the segment to test the intersection against
  16318. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  16319. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  16320. */
  16321. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  16322. /**
  16323. * Update the ray from viewport position
  16324. * @param x position
  16325. * @param y y position
  16326. * @param viewportWidth viewport width
  16327. * @param viewportHeight viewport height
  16328. * @param world world matrix
  16329. * @param view view matrix
  16330. * @param projection projection matrix
  16331. * @returns this ray updated
  16332. */
  16333. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  16334. /**
  16335. * Creates a ray with origin and direction of 0,0,0
  16336. * @returns the new ray
  16337. */
  16338. static Zero(): Ray;
  16339. /**
  16340. * Creates a new ray from screen space and viewport
  16341. * @param x position
  16342. * @param y y position
  16343. * @param viewportWidth viewport width
  16344. * @param viewportHeight viewport height
  16345. * @param world world matrix
  16346. * @param view view matrix
  16347. * @param projection projection matrix
  16348. * @returns new ray
  16349. */
  16350. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  16351. /**
  16352. * 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
  16353. * transformed to the given world matrix.
  16354. * @param origin The origin point
  16355. * @param end The end point
  16356. * @param world a matrix to transform the ray to. Default is the identity matrix.
  16357. * @returns the new ray
  16358. */
  16359. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  16360. /**
  16361. * Transforms a ray by a matrix
  16362. * @param ray ray to transform
  16363. * @param matrix matrix to apply
  16364. * @returns the resulting new ray
  16365. */
  16366. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  16367. /**
  16368. * Transforms a ray by a matrix
  16369. * @param ray ray to transform
  16370. * @param matrix matrix to apply
  16371. * @param result ray to store result in
  16372. */
  16373. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  16374. /**
  16375. * Unproject a ray from screen space to object space
  16376. * @param sourceX defines the screen space x coordinate to use
  16377. * @param sourceY defines the screen space y coordinate to use
  16378. * @param viewportWidth defines the current width of the viewport
  16379. * @param viewportHeight defines the current height of the viewport
  16380. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  16381. * @param view defines the view matrix to use
  16382. * @param projection defines the projection matrix to use
  16383. */
  16384. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  16385. }
  16386. /**
  16387. * Type used to define predicate used to select faces when a mesh intersection is detected
  16388. */
  16389. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  16390. module "babylonjs/scene" {
  16391. interface Scene {
  16392. /** @hidden */
  16393. _tempPickingRay: Nullable<Ray>;
  16394. /** @hidden */
  16395. _cachedRayForTransform: Ray;
  16396. /** @hidden */
  16397. _pickWithRayInverseMatrix: Matrix;
  16398. /** @hidden */
  16399. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  16400. /** @hidden */
  16401. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  16402. }
  16403. }
  16404. }
  16405. declare module "babylonjs/Sprites/spriteSceneComponent" {
  16406. import { Nullable } from "babylonjs/types";
  16407. import { Observable } from "babylonjs/Misc/observable";
  16408. import { Scene } from "babylonjs/scene";
  16409. import { Sprite } from "babylonjs/Sprites/sprite";
  16410. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16411. import { Ray } from "babylonjs/Culling/ray";
  16412. import { Camera } from "babylonjs/Cameras/camera";
  16413. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16414. import { ISceneComponent } from "babylonjs/sceneComponent";
  16415. module "babylonjs/scene" {
  16416. interface Scene {
  16417. /** @hidden */
  16418. _pointerOverSprite: Nullable<Sprite>;
  16419. /** @hidden */
  16420. _pickedDownSprite: Nullable<Sprite>;
  16421. /** @hidden */
  16422. _tempSpritePickingRay: Nullable<Ray>;
  16423. /**
  16424. * All of the sprite managers added to this scene
  16425. * @see http://doc.babylonjs.com/babylon101/sprites
  16426. */
  16427. spriteManagers: Array<ISpriteManager>;
  16428. /**
  16429. * An event triggered when sprites rendering is about to start
  16430. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16431. */
  16432. onBeforeSpritesRenderingObservable: Observable<Scene>;
  16433. /**
  16434. * An event triggered when sprites rendering is done
  16435. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  16436. */
  16437. onAfterSpritesRenderingObservable: Observable<Scene>;
  16438. /** @hidden */
  16439. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16440. /** Launch a ray to try to pick a sprite in the scene
  16441. * @param x position on screen
  16442. * @param y position on screen
  16443. * @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
  16444. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16445. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  16446. * @returns a PickingInfo
  16447. */
  16448. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16449. /** Use the given ray to pick a sprite in the scene
  16450. * @param ray The ray (in world space) to use to pick meshes
  16451. * @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
  16452. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  16453. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  16454. * @returns a PickingInfo
  16455. */
  16456. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  16457. /**
  16458. * Force the sprite under the pointer
  16459. * @param sprite defines the sprite to use
  16460. */
  16461. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  16462. /**
  16463. * Gets the sprite under the pointer
  16464. * @returns a Sprite or null if no sprite is under the pointer
  16465. */
  16466. getPointerOverSprite(): Nullable<Sprite>;
  16467. }
  16468. }
  16469. /**
  16470. * Defines the sprite scene component responsible to manage sprites
  16471. * in a given scene.
  16472. */
  16473. export class SpriteSceneComponent implements ISceneComponent {
  16474. /**
  16475. * The component name helpfull to identify the component in the list of scene components.
  16476. */
  16477. readonly name: string;
  16478. /**
  16479. * The scene the component belongs to.
  16480. */
  16481. scene: Scene;
  16482. /** @hidden */
  16483. private _spritePredicate;
  16484. /**
  16485. * Creates a new instance of the component for the given scene
  16486. * @param scene Defines the scene to register the component in
  16487. */
  16488. constructor(scene: Scene);
  16489. /**
  16490. * Registers the component in a given scene
  16491. */
  16492. register(): void;
  16493. /**
  16494. * Rebuilds the elements related to this component in case of
  16495. * context lost for instance.
  16496. */
  16497. rebuild(): void;
  16498. /**
  16499. * Disposes the component and the associated ressources.
  16500. */
  16501. dispose(): void;
  16502. private _pickSpriteButKeepRay;
  16503. private _pointerMove;
  16504. private _pointerDown;
  16505. private _pointerUp;
  16506. }
  16507. }
  16508. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  16509. /** @hidden */
  16510. export var fogFragmentDeclaration: {
  16511. name: string;
  16512. shader: string;
  16513. };
  16514. }
  16515. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  16516. /** @hidden */
  16517. export var fogFragment: {
  16518. name: string;
  16519. shader: string;
  16520. };
  16521. }
  16522. declare module "babylonjs/Shaders/sprites.fragment" {
  16523. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  16524. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  16525. /** @hidden */
  16526. export var spritesPixelShader: {
  16527. name: string;
  16528. shader: string;
  16529. };
  16530. }
  16531. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  16532. /** @hidden */
  16533. export var fogVertexDeclaration: {
  16534. name: string;
  16535. shader: string;
  16536. };
  16537. }
  16538. declare module "babylonjs/Shaders/sprites.vertex" {
  16539. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  16540. /** @hidden */
  16541. export var spritesVertexShader: {
  16542. name: string;
  16543. shader: string;
  16544. };
  16545. }
  16546. declare module "babylonjs/Sprites/spriteManager" {
  16547. import { IDisposable, Scene } from "babylonjs/scene";
  16548. import { Nullable } from "babylonjs/types";
  16549. import { Observable } from "babylonjs/Misc/observable";
  16550. import { Sprite } from "babylonjs/Sprites/sprite";
  16551. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16552. import { Camera } from "babylonjs/Cameras/camera";
  16553. import { Texture } from "babylonjs/Materials/Textures/texture";
  16554. import "babylonjs/Shaders/sprites.fragment";
  16555. import "babylonjs/Shaders/sprites.vertex";
  16556. import { Ray } from "babylonjs/Culling/ray";
  16557. /**
  16558. * Defines the minimum interface to fullfil in order to be a sprite manager.
  16559. */
  16560. export interface ISpriteManager extends IDisposable {
  16561. /**
  16562. * Restricts the camera to viewing objects with the same layerMask.
  16563. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  16564. */
  16565. layerMask: number;
  16566. /**
  16567. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  16568. */
  16569. isPickable: boolean;
  16570. /**
  16571. * Specifies the rendering group id for this mesh (0 by default)
  16572. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  16573. */
  16574. renderingGroupId: number;
  16575. /**
  16576. * Defines the list of sprites managed by the manager.
  16577. */
  16578. sprites: Array<Sprite>;
  16579. /**
  16580. * Tests the intersection of a sprite with a specific ray.
  16581. * @param ray The ray we are sending to test the collision
  16582. * @param camera The camera space we are sending rays in
  16583. * @param predicate A predicate allowing excluding sprites from the list of object to test
  16584. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  16585. * @returns picking info or null.
  16586. */
  16587. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16588. /**
  16589. * Renders the list of sprites on screen.
  16590. */
  16591. render(): void;
  16592. }
  16593. /**
  16594. * Class used to manage multiple sprites on the same spritesheet
  16595. * @see http://doc.babylonjs.com/babylon101/sprites
  16596. */
  16597. export class SpriteManager implements ISpriteManager {
  16598. /** defines the manager's name */
  16599. name: string;
  16600. /** Gets the list of sprites */
  16601. sprites: Sprite[];
  16602. /** Gets or sets the rendering group id (0 by default) */
  16603. renderingGroupId: number;
  16604. /** Gets or sets camera layer mask */
  16605. layerMask: number;
  16606. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  16607. fogEnabled: boolean;
  16608. /** Gets or sets a boolean indicating if the sprites are pickable */
  16609. isPickable: boolean;
  16610. /** Defines the default width of a cell in the spritesheet */
  16611. cellWidth: number;
  16612. /** Defines the default height of a cell in the spritesheet */
  16613. cellHeight: number;
  16614. /**
  16615. * An event triggered when the manager is disposed.
  16616. */
  16617. onDisposeObservable: Observable<SpriteManager>;
  16618. private _onDisposeObserver;
  16619. /**
  16620. * Callback called when the manager is disposed
  16621. */
  16622. onDispose: () => void;
  16623. private _capacity;
  16624. private _spriteTexture;
  16625. private _epsilon;
  16626. private _scene;
  16627. private _vertexData;
  16628. private _buffer;
  16629. private _vertexBuffers;
  16630. private _indexBuffer;
  16631. private _effectBase;
  16632. private _effectFog;
  16633. /**
  16634. * Gets or sets the spritesheet texture
  16635. */
  16636. texture: Texture;
  16637. /**
  16638. * Creates a new sprite manager
  16639. * @param name defines the manager's name
  16640. * @param imgUrl defines the sprite sheet url
  16641. * @param capacity defines the maximum allowed number of sprites
  16642. * @param cellSize defines the size of a sprite cell
  16643. * @param scene defines the hosting scene
  16644. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  16645. * @param samplingMode defines the smapling mode to use with spritesheet
  16646. */
  16647. constructor(
  16648. /** defines the manager's name */
  16649. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  16650. private _appendSpriteVertex;
  16651. /**
  16652. * Intersects the sprites with a ray
  16653. * @param ray defines the ray to intersect with
  16654. * @param camera defines the current active camera
  16655. * @param predicate defines a predicate used to select candidate sprites
  16656. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  16657. * @returns null if no hit or a PickingInfo
  16658. */
  16659. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16660. /**
  16661. * Render all child sprites
  16662. */
  16663. render(): void;
  16664. /**
  16665. * Release associated resources
  16666. */
  16667. dispose(): void;
  16668. }
  16669. }
  16670. declare module "babylonjs/Sprites/sprite" {
  16671. import { Vector3, Color4 } from "babylonjs/Maths/math";
  16672. import { Nullable } from "babylonjs/types";
  16673. import { ActionManager } from "babylonjs/Actions/actionManager";
  16674. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16675. /**
  16676. * Class used to represent a sprite
  16677. * @see http://doc.babylonjs.com/babylon101/sprites
  16678. */
  16679. export class Sprite {
  16680. /** defines the name */
  16681. name: string;
  16682. /** Gets or sets the current world position */
  16683. position: Vector3;
  16684. /** Gets or sets the main color */
  16685. color: Color4;
  16686. /** Gets or sets the width */
  16687. width: number;
  16688. /** Gets or sets the height */
  16689. height: number;
  16690. /** Gets or sets rotation angle */
  16691. angle: number;
  16692. /** Gets or sets the cell index in the sprite sheet */
  16693. cellIndex: number;
  16694. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  16695. invertU: number;
  16696. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  16697. invertV: number;
  16698. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  16699. disposeWhenFinishedAnimating: boolean;
  16700. /** Gets the list of attached animations */
  16701. animations: Animation[];
  16702. /** Gets or sets a boolean indicating if the sprite can be picked */
  16703. isPickable: boolean;
  16704. /**
  16705. * Gets or sets the associated action manager
  16706. */
  16707. actionManager: Nullable<ActionManager>;
  16708. private _animationStarted;
  16709. private _loopAnimation;
  16710. private _fromIndex;
  16711. private _toIndex;
  16712. private _delay;
  16713. private _direction;
  16714. private _manager;
  16715. private _time;
  16716. private _onAnimationEnd;
  16717. /**
  16718. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  16719. */
  16720. isVisible: boolean;
  16721. /**
  16722. * Gets or sets the sprite size
  16723. */
  16724. size: number;
  16725. /**
  16726. * Creates a new Sprite
  16727. * @param name defines the name
  16728. * @param manager defines the manager
  16729. */
  16730. constructor(
  16731. /** defines the name */
  16732. name: string, manager: ISpriteManager);
  16733. /**
  16734. * Starts an animation
  16735. * @param from defines the initial key
  16736. * @param to defines the end key
  16737. * @param loop defines if the animation must loop
  16738. * @param delay defines the start delay (in ms)
  16739. * @param onAnimationEnd defines a callback to call when animation ends
  16740. */
  16741. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  16742. /** Stops current animation (if any) */
  16743. stopAnimation(): void;
  16744. /** @hidden */
  16745. _animate(deltaTime: number): void;
  16746. /** Release associated resources */
  16747. dispose(): void;
  16748. }
  16749. }
  16750. declare module "babylonjs/Collisions/pickingInfo" {
  16751. import { Nullable } from "babylonjs/types";
  16752. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  16753. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16754. import { Sprite } from "babylonjs/Sprites/sprite";
  16755. import { Ray } from "babylonjs/Culling/ray";
  16756. /**
  16757. * Information about the result of picking within a scene
  16758. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  16759. */
  16760. export class PickingInfo {
  16761. /** @hidden */
  16762. _pickingUnavailable: boolean;
  16763. /**
  16764. * If the pick collided with an object
  16765. */
  16766. hit: boolean;
  16767. /**
  16768. * Distance away where the pick collided
  16769. */
  16770. distance: number;
  16771. /**
  16772. * The location of pick collision
  16773. */
  16774. pickedPoint: Nullable<Vector3>;
  16775. /**
  16776. * The mesh corresponding the the pick collision
  16777. */
  16778. pickedMesh: Nullable<AbstractMesh>;
  16779. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  16780. bu: number;
  16781. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  16782. bv: number;
  16783. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  16784. faceId: number;
  16785. /** Id of the the submesh that was picked */
  16786. subMeshId: number;
  16787. /** If a sprite was picked, this will be the sprite the pick collided with */
  16788. pickedSprite: Nullable<Sprite>;
  16789. /**
  16790. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  16791. */
  16792. originMesh: Nullable<AbstractMesh>;
  16793. /**
  16794. * The ray that was used to perform the picking.
  16795. */
  16796. ray: Nullable<Ray>;
  16797. /**
  16798. * Gets the normal correspodning to the face the pick collided with
  16799. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  16800. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  16801. * @returns The normal correspodning to the face the pick collided with
  16802. */
  16803. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  16804. /**
  16805. * Gets the texture coordinates of where the pick occured
  16806. * @returns the vector containing the coordnates of the texture
  16807. */
  16808. getTextureCoordinates(): Nullable<Vector2>;
  16809. }
  16810. }
  16811. declare module "babylonjs/Events/pointerEvents" {
  16812. import { Nullable } from "babylonjs/types";
  16813. import { Vector2 } from "babylonjs/Maths/math";
  16814. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  16815. import { Ray } from "babylonjs/Culling/ray";
  16816. /**
  16817. * Gather the list of pointer event types as constants.
  16818. */
  16819. export class PointerEventTypes {
  16820. /**
  16821. * 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.
  16822. */
  16823. static readonly POINTERDOWN: number;
  16824. /**
  16825. * The pointerup event is fired when a pointer is no longer active.
  16826. */
  16827. static readonly POINTERUP: number;
  16828. /**
  16829. * The pointermove event is fired when a pointer changes coordinates.
  16830. */
  16831. static readonly POINTERMOVE: number;
  16832. /**
  16833. * The pointerwheel event is fired when a mouse wheel has been rotated.
  16834. */
  16835. static readonly POINTERWHEEL: number;
  16836. /**
  16837. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  16838. */
  16839. static readonly POINTERPICK: number;
  16840. /**
  16841. * The pointertap event is fired when a the object has been touched and released without drag.
  16842. */
  16843. static readonly POINTERTAP: number;
  16844. /**
  16845. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  16846. */
  16847. static readonly POINTERDOUBLETAP: number;
  16848. }
  16849. /**
  16850. * Base class of pointer info types.
  16851. */
  16852. export class PointerInfoBase {
  16853. /**
  16854. * Defines the type of event (PointerEventTypes)
  16855. */
  16856. type: number;
  16857. /**
  16858. * Defines the related dom event
  16859. */
  16860. event: PointerEvent | MouseWheelEvent;
  16861. /**
  16862. * Instantiates the base class of pointers info.
  16863. * @param type Defines the type of event (PointerEventTypes)
  16864. * @param event Defines the related dom event
  16865. */
  16866. constructor(
  16867. /**
  16868. * Defines the type of event (PointerEventTypes)
  16869. */
  16870. type: number,
  16871. /**
  16872. * Defines the related dom event
  16873. */
  16874. event: PointerEvent | MouseWheelEvent);
  16875. }
  16876. /**
  16877. * This class is used to store pointer related info for the onPrePointerObservable event.
  16878. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  16879. */
  16880. export class PointerInfoPre extends PointerInfoBase {
  16881. /**
  16882. * Ray from a pointer if availible (eg. 6dof controller)
  16883. */
  16884. ray: Nullable<Ray>;
  16885. /**
  16886. * Defines the local position of the pointer on the canvas.
  16887. */
  16888. localPosition: Vector2;
  16889. /**
  16890. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  16891. */
  16892. skipOnPointerObservable: boolean;
  16893. /**
  16894. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  16895. * @param type Defines the type of event (PointerEventTypes)
  16896. * @param event Defines the related dom event
  16897. * @param localX Defines the local x coordinates of the pointer when the event occured
  16898. * @param localY Defines the local y coordinates of the pointer when the event occured
  16899. */
  16900. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  16901. }
  16902. /**
  16903. * This type contains all the data related to a pointer event in Babylon.js.
  16904. * 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.
  16905. */
  16906. export class PointerInfo extends PointerInfoBase {
  16907. /**
  16908. * Defines the picking info associated to the info (if any)\
  16909. */
  16910. pickInfo: Nullable<PickingInfo>;
  16911. /**
  16912. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  16913. * @param type Defines the type of event (PointerEventTypes)
  16914. * @param event Defines the related dom event
  16915. * @param pickInfo Defines the picking info associated to the info (if any)\
  16916. */
  16917. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  16918. /**
  16919. * Defines the picking info associated to the info (if any)\
  16920. */
  16921. pickInfo: Nullable<PickingInfo>);
  16922. }
  16923. /**
  16924. * Data relating to a touch event on the screen.
  16925. */
  16926. export interface PointerTouch {
  16927. /**
  16928. * X coordinate of touch.
  16929. */
  16930. x: number;
  16931. /**
  16932. * Y coordinate of touch.
  16933. */
  16934. y: number;
  16935. /**
  16936. * Id of touch. Unique for each finger.
  16937. */
  16938. pointerId: number;
  16939. /**
  16940. * Event type passed from DOM.
  16941. */
  16942. type: any;
  16943. }
  16944. }
  16945. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  16946. import { Observable } from "babylonjs/Misc/observable";
  16947. import { Nullable } from "babylonjs/types";
  16948. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  16949. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  16950. /**
  16951. * Manage the mouse inputs to control the movement of a free camera.
  16952. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16953. */
  16954. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  16955. /**
  16956. * Define if touch is enabled in the mouse input
  16957. */
  16958. touchEnabled: boolean;
  16959. /**
  16960. * Defines the camera the input is attached to.
  16961. */
  16962. camera: FreeCamera;
  16963. /**
  16964. * Defines the buttons associated with the input to handle camera move.
  16965. */
  16966. buttons: number[];
  16967. /**
  16968. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  16969. */
  16970. angularSensibility: number;
  16971. private _pointerInput;
  16972. private _onMouseMove;
  16973. private _observer;
  16974. private previousPosition;
  16975. /**
  16976. * Observable for when a pointer move event occurs containing the move offset
  16977. */
  16978. onPointerMovedObservable: Observable<{
  16979. offsetX: number;
  16980. offsetY: number;
  16981. }>;
  16982. /**
  16983. * @hidden
  16984. * If the camera should be rotated automatically based on pointer movement
  16985. */
  16986. _allowCameraRotation: boolean;
  16987. /**
  16988. * Manage the mouse inputs to control the movement of a free camera.
  16989. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  16990. * @param touchEnabled Defines if touch is enabled or not
  16991. */
  16992. constructor(
  16993. /**
  16994. * Define if touch is enabled in the mouse input
  16995. */
  16996. touchEnabled?: boolean);
  16997. /**
  16998. * Attach the input controls to a specific dom element to get the input from.
  16999. * @param element Defines the element the controls should be listened from
  17000. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  17001. */
  17002. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  17003. /**
  17004. * Called on JS contextmenu event.
  17005. * Override this method to provide functionality.
  17006. */
  17007. protected onContextMenu(evt: PointerEvent): void;
  17008. /**
  17009. * Detach the current controls from the specified dom element.
  17010. * @param element Defines the element to stop listening the inputs from
  17011. */
  17012. detachControl(element: Nullable<HTMLElement>): void;
  17013. /**
  17014. * Gets the class name of the current intput.
  17015. * @returns the class name
  17016. */
  17017. getClassName(): string;
  17018. /**
  17019. * Get the friendly name associated with the input class.
  17020. * @returns the input friendly name
  17021. */
  17022. getSimpleName(): string;
  17023. }
  17024. }
  17025. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  17026. import { Nullable } from "babylonjs/types";
  17027. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  17028. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  17029. /**
  17030. * Manage the touch inputs to control the movement of a free camera.
  17031. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  17032. */
  17033. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  17034. /**
  17035. * Defines the camera the input is attached to.
  17036. */
  17037. camera: FreeCamera;
  17038. /**
  17039. * Defines the touch sensibility for rotation.
  17040. * The higher the faster.
  17041. */
  17042. touchAngularSensibility: number;
  17043. /**
  17044. * Defines the touch sensibility for move.
  17045. * The higher the faster.
  17046. */
  17047. touchMoveSensibility: number;
  17048. private _offsetX;
  17049. private _offsetY;
  17050. private _pointerPressed;
  17051. private _pointerInput;
  17052. private _observer;
  17053. private _onLostFocus;
  17054. /**
  17055. * Attach the input controls to a specific dom element to get the input from.
  17056. * @param element Defines the element the controls should be listened from
  17057. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  17058. */
  17059. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  17060. /**
  17061. * Detach the current controls from the specified dom element.
  17062. * @param element Defines the element to stop listening the inputs from
  17063. */
  17064. detachControl(element: Nullable<HTMLElement>): void;
  17065. /**
  17066. * Update the current camera state depending on the inputs that have been used this frame.
  17067. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  17068. */
  17069. checkInputs(): void;
  17070. /**
  17071. * Gets the class name of the current intput.
  17072. * @returns the class name
  17073. */
  17074. getClassName(): string;
  17075. /**
  17076. * Get the friendly name associated with the input class.
  17077. * @returns the input friendly name
  17078. */
  17079. getSimpleName(): string;
  17080. }
  17081. }
  17082. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  17083. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  17084. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  17085. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  17086. import { Nullable } from "babylonjs/types";
  17087. /**
  17088. * Default Inputs manager for the FreeCamera.
  17089. * It groups all the default supported inputs for ease of use.
  17090. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  17091. */
  17092. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  17093. /**
  17094. * @hidden
  17095. */
  17096. _mouseInput: Nullable<FreeCameraMouseInput>;
  17097. /**
  17098. * Instantiates a new FreeCameraInputsManager.
  17099. * @param camera Defines the camera the inputs belong to
  17100. */
  17101. constructor(camera: FreeCamera);
  17102. /**
  17103. * Add keyboard input support to the input manager.
  17104. * @returns the current input manager
  17105. */
  17106. addKeyboard(): FreeCameraInputsManager;
  17107. /**
  17108. * Add mouse input support to the input manager.
  17109. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  17110. * @returns the current input manager
  17111. */
  17112. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  17113. /**
  17114. * Removes the mouse input support from the manager
  17115. * @returns the current input manager
  17116. */
  17117. removeMouse(): FreeCameraInputsManager;
  17118. /**
  17119. * Add touch input support to the input manager.
  17120. * @returns the current input manager
  17121. */
  17122. addTouch(): FreeCameraInputsManager;
  17123. /**
  17124. * Remove all attached input methods from a camera
  17125. */
  17126. clear(): void;
  17127. }
  17128. }
  17129. declare module "babylonjs/Cameras/freeCamera" {
  17130. import { Vector3 } from "babylonjs/Maths/math";
  17131. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17132. import { Scene } from "babylonjs/scene";
  17133. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  17134. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  17135. /**
  17136. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  17137. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  17138. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  17139. */
  17140. export class FreeCamera extends TargetCamera {
  17141. /**
  17142. * Define the collision ellipsoid of the camera.
  17143. * This is helpful to simulate a camera body like the player body around the camera
  17144. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  17145. */
  17146. ellipsoid: Vector3;
  17147. /**
  17148. * Define an offset for the position of the ellipsoid around the camera.
  17149. * This can be helpful to determine the center of the body near the gravity center of the body
  17150. * instead of its head.
  17151. */
  17152. ellipsoidOffset: Vector3;
  17153. /**
  17154. * Enable or disable collisions of the camera with the rest of the scene objects.
  17155. */
  17156. checkCollisions: boolean;
  17157. /**
  17158. * Enable or disable gravity on the camera.
  17159. */
  17160. applyGravity: boolean;
  17161. /**
  17162. * Define the input manager associated to the camera.
  17163. */
  17164. inputs: FreeCameraInputsManager;
  17165. /**
  17166. * Gets the input sensibility for a mouse input. (default is 2000.0)
  17167. * Higher values reduce sensitivity.
  17168. */
  17169. /**
  17170. * Sets the input sensibility for a mouse input. (default is 2000.0)
  17171. * Higher values reduce sensitivity.
  17172. */
  17173. angularSensibility: number;
  17174. /**
  17175. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  17176. */
  17177. keysUp: number[];
  17178. /**
  17179. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  17180. */
  17181. keysDown: number[];
  17182. /**
  17183. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  17184. */
  17185. keysLeft: number[];
  17186. /**
  17187. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  17188. */
  17189. keysRight: number[];
  17190. /**
  17191. * Event raised when the camera collide with a mesh in the scene.
  17192. */
  17193. onCollide: (collidedMesh: AbstractMesh) => void;
  17194. private _collider;
  17195. private _needMoveForGravity;
  17196. private _oldPosition;
  17197. private _diffPosition;
  17198. private _newPosition;
  17199. /** @hidden */
  17200. _localDirection: Vector3;
  17201. /** @hidden */
  17202. _transformedDirection: Vector3;
  17203. /**
  17204. * Instantiates a Free Camera.
  17205. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  17206. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  17207. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  17208. * @param name Define the name of the camera in the scene
  17209. * @param position Define the start position of the camera in the scene
  17210. * @param scene Define the scene the camera belongs to
  17211. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  17212. */
  17213. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  17214. /**
  17215. * Attached controls to the current camera.
  17216. * @param element Defines the element the controls should be listened from
  17217. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  17218. */
  17219. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  17220. /**
  17221. * Detach the current controls from the camera.
  17222. * The camera will stop reacting to inputs.
  17223. * @param element Defines the element to stop listening the inputs from
  17224. */
  17225. detachControl(element: HTMLElement): void;
  17226. private _collisionMask;
  17227. /**
  17228. * Define a collision mask to limit the list of object the camera can collide with
  17229. */
  17230. collisionMask: number;
  17231. /** @hidden */
  17232. _collideWithWorld(displacement: Vector3): void;
  17233. private _onCollisionPositionChange;
  17234. /** @hidden */
  17235. _checkInputs(): void;
  17236. /** @hidden */
  17237. _decideIfNeedsToMove(): boolean;
  17238. /** @hidden */
  17239. _updatePosition(): void;
  17240. /**
  17241. * Destroy the camera and release the current resources hold by it.
  17242. */
  17243. dispose(): void;
  17244. /**
  17245. * Gets the current object class name.
  17246. * @return the class name
  17247. */
  17248. getClassName(): string;
  17249. }
  17250. }
  17251. declare module "babylonjs/Gamepads/gamepad" {
  17252. import { Observable } from "babylonjs/Misc/observable";
  17253. /**
  17254. * Represents a gamepad control stick position
  17255. */
  17256. export class StickValues {
  17257. /**
  17258. * The x component of the control stick
  17259. */
  17260. x: number;
  17261. /**
  17262. * The y component of the control stick
  17263. */
  17264. y: number;
  17265. /**
  17266. * Initializes the gamepad x and y control stick values
  17267. * @param x The x component of the gamepad control stick value
  17268. * @param y The y component of the gamepad control stick value
  17269. */
  17270. constructor(
  17271. /**
  17272. * The x component of the control stick
  17273. */
  17274. x: number,
  17275. /**
  17276. * The y component of the control stick
  17277. */
  17278. y: number);
  17279. }
  17280. /**
  17281. * An interface which manages callbacks for gamepad button changes
  17282. */
  17283. export interface GamepadButtonChanges {
  17284. /**
  17285. * Called when a gamepad has been changed
  17286. */
  17287. changed: boolean;
  17288. /**
  17289. * Called when a gamepad press event has been triggered
  17290. */
  17291. pressChanged: boolean;
  17292. /**
  17293. * Called when a touch event has been triggered
  17294. */
  17295. touchChanged: boolean;
  17296. /**
  17297. * Called when a value has changed
  17298. */
  17299. valueChanged: boolean;
  17300. }
  17301. /**
  17302. * Represents a gamepad
  17303. */
  17304. export class Gamepad {
  17305. /**
  17306. * The id of the gamepad
  17307. */
  17308. id: string;
  17309. /**
  17310. * The index of the gamepad
  17311. */
  17312. index: number;
  17313. /**
  17314. * The browser gamepad
  17315. */
  17316. browserGamepad: any;
  17317. /**
  17318. * Specifies what type of gamepad this represents
  17319. */
  17320. type: number;
  17321. private _leftStick;
  17322. private _rightStick;
  17323. /** @hidden */
  17324. _isConnected: boolean;
  17325. private _leftStickAxisX;
  17326. private _leftStickAxisY;
  17327. private _rightStickAxisX;
  17328. private _rightStickAxisY;
  17329. /**
  17330. * Triggered when the left control stick has been changed
  17331. */
  17332. private _onleftstickchanged;
  17333. /**
  17334. * Triggered when the right control stick has been changed
  17335. */
  17336. private _onrightstickchanged;
  17337. /**
  17338. * Represents a gamepad controller
  17339. */
  17340. static GAMEPAD: number;
  17341. /**
  17342. * Represents a generic controller
  17343. */
  17344. static GENERIC: number;
  17345. /**
  17346. * Represents an XBox controller
  17347. */
  17348. static XBOX: number;
  17349. /**
  17350. * Represents a pose-enabled controller
  17351. */
  17352. static POSE_ENABLED: number;
  17353. /**
  17354. * Specifies whether the left control stick should be Y-inverted
  17355. */
  17356. protected _invertLeftStickY: boolean;
  17357. /**
  17358. * Specifies if the gamepad has been connected
  17359. */
  17360. readonly isConnected: boolean;
  17361. /**
  17362. * Initializes the gamepad
  17363. * @param id The id of the gamepad
  17364. * @param index The index of the gamepad
  17365. * @param browserGamepad The browser gamepad
  17366. * @param leftStickX The x component of the left joystick
  17367. * @param leftStickY The y component of the left joystick
  17368. * @param rightStickX The x component of the right joystick
  17369. * @param rightStickY The y component of the right joystick
  17370. */
  17371. constructor(
  17372. /**
  17373. * The id of the gamepad
  17374. */
  17375. id: string,
  17376. /**
  17377. * The index of the gamepad
  17378. */
  17379. index: number,
  17380. /**
  17381. * The browser gamepad
  17382. */
  17383. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  17384. /**
  17385. * Callback triggered when the left joystick has changed
  17386. * @param callback
  17387. */
  17388. onleftstickchanged(callback: (values: StickValues) => void): void;
  17389. /**
  17390. * Callback triggered when the right joystick has changed
  17391. * @param callback
  17392. */
  17393. onrightstickchanged(callback: (values: StickValues) => void): void;
  17394. /**
  17395. * Gets the left joystick
  17396. */
  17397. /**
  17398. * Sets the left joystick values
  17399. */
  17400. leftStick: StickValues;
  17401. /**
  17402. * Gets the right joystick
  17403. */
  17404. /**
  17405. * Sets the right joystick value
  17406. */
  17407. rightStick: StickValues;
  17408. /**
  17409. * Updates the gamepad joystick positions
  17410. */
  17411. update(): void;
  17412. /**
  17413. * Disposes the gamepad
  17414. */
  17415. dispose(): void;
  17416. }
  17417. /**
  17418. * Represents a generic gamepad
  17419. */
  17420. export class GenericPad extends Gamepad {
  17421. private _buttons;
  17422. private _onbuttondown;
  17423. private _onbuttonup;
  17424. /**
  17425. * Observable triggered when a button has been pressed
  17426. */
  17427. onButtonDownObservable: Observable<number>;
  17428. /**
  17429. * Observable triggered when a button has been released
  17430. */
  17431. onButtonUpObservable: Observable<number>;
  17432. /**
  17433. * Callback triggered when a button has been pressed
  17434. * @param callback Called when a button has been pressed
  17435. */
  17436. onbuttondown(callback: (buttonPressed: number) => void): void;
  17437. /**
  17438. * Callback triggered when a button has been released
  17439. * @param callback Called when a button has been released
  17440. */
  17441. onbuttonup(callback: (buttonReleased: number) => void): void;
  17442. /**
  17443. * Initializes the generic gamepad
  17444. * @param id The id of the generic gamepad
  17445. * @param index The index of the generic gamepad
  17446. * @param browserGamepad The browser gamepad
  17447. */
  17448. constructor(id: string, index: number, browserGamepad: any);
  17449. private _setButtonValue;
  17450. /**
  17451. * Updates the generic gamepad
  17452. */
  17453. update(): void;
  17454. /**
  17455. * Disposes the generic gamepad
  17456. */
  17457. dispose(): void;
  17458. }
  17459. }
  17460. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  17461. import { Observable } from "babylonjs/Misc/observable";
  17462. import { Nullable } from "babylonjs/types";
  17463. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  17464. import { TransformNode } from "babylonjs/Meshes/transformNode";
  17465. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17466. import { Ray } from "babylonjs/Culling/ray";
  17467. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  17468. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  17469. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  17470. /**
  17471. * Defines the types of pose enabled controllers that are supported
  17472. */
  17473. export enum PoseEnabledControllerType {
  17474. /**
  17475. * HTC Vive
  17476. */
  17477. VIVE = 0,
  17478. /**
  17479. * Oculus Rift
  17480. */
  17481. OCULUS = 1,
  17482. /**
  17483. * Windows mixed reality
  17484. */
  17485. WINDOWS = 2,
  17486. /**
  17487. * Samsung gear VR
  17488. */
  17489. GEAR_VR = 3,
  17490. /**
  17491. * Google Daydream
  17492. */
  17493. DAYDREAM = 4,
  17494. /**
  17495. * Generic
  17496. */
  17497. GENERIC = 5
  17498. }
  17499. /**
  17500. * Defines the MutableGamepadButton interface for the state of a gamepad button
  17501. */
  17502. export interface MutableGamepadButton {
  17503. /**
  17504. * Value of the button/trigger
  17505. */
  17506. value: number;
  17507. /**
  17508. * If the button/trigger is currently touched
  17509. */
  17510. touched: boolean;
  17511. /**
  17512. * If the button/trigger is currently pressed
  17513. */
  17514. pressed: boolean;
  17515. }
  17516. /**
  17517. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  17518. * @hidden
  17519. */
  17520. export interface ExtendedGamepadButton extends GamepadButton {
  17521. /**
  17522. * If the button/trigger is currently pressed
  17523. */
  17524. readonly pressed: boolean;
  17525. /**
  17526. * If the button/trigger is currently touched
  17527. */
  17528. readonly touched: boolean;
  17529. /**
  17530. * Value of the button/trigger
  17531. */
  17532. readonly value: number;
  17533. }
  17534. /** @hidden */
  17535. export interface _GamePadFactory {
  17536. /**
  17537. * Returns wether or not the current gamepad can be created for this type of controller.
  17538. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17539. * @returns true if it can be created, otherwise false
  17540. */
  17541. canCreate(gamepadInfo: any): boolean;
  17542. /**
  17543. * Creates a new instance of the Gamepad.
  17544. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  17545. * @returns the new gamepad instance
  17546. */
  17547. create(gamepadInfo: any): Gamepad;
  17548. }
  17549. /**
  17550. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17551. */
  17552. export class PoseEnabledControllerHelper {
  17553. /** @hidden */
  17554. static _ControllerFactories: _GamePadFactory[];
  17555. /** @hidden */
  17556. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  17557. /**
  17558. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  17559. * @param vrGamepad the gamepad to initialized
  17560. * @returns a vr controller of the type the gamepad identified as
  17561. */
  17562. static InitiateController(vrGamepad: any): Gamepad;
  17563. }
  17564. /**
  17565. * Defines the PoseEnabledController object that contains state of a vr capable controller
  17566. */
  17567. export class PoseEnabledController extends Gamepad implements PoseControlled {
  17568. private _deviceRoomPosition;
  17569. private _deviceRoomRotationQuaternion;
  17570. /**
  17571. * The device position in babylon space
  17572. */
  17573. devicePosition: Vector3;
  17574. /**
  17575. * The device rotation in babylon space
  17576. */
  17577. deviceRotationQuaternion: Quaternion;
  17578. /**
  17579. * The scale factor of the device in babylon space
  17580. */
  17581. deviceScaleFactor: number;
  17582. /**
  17583. * (Likely devicePosition should be used instead) The device position in its room space
  17584. */
  17585. position: Vector3;
  17586. /**
  17587. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  17588. */
  17589. rotationQuaternion: Quaternion;
  17590. /**
  17591. * The type of controller (Eg. Windows mixed reality)
  17592. */
  17593. controllerType: PoseEnabledControllerType;
  17594. protected _calculatedPosition: Vector3;
  17595. private _calculatedRotation;
  17596. /**
  17597. * The raw pose from the device
  17598. */
  17599. rawPose: DevicePose;
  17600. private _trackPosition;
  17601. private _maxRotationDistFromHeadset;
  17602. private _draggedRoomRotation;
  17603. /**
  17604. * @hidden
  17605. */
  17606. _disableTrackPosition(fixedPosition: Vector3): void;
  17607. /**
  17608. * Internal, the mesh attached to the controller
  17609. * @hidden
  17610. */
  17611. _mesh: Nullable<AbstractMesh>;
  17612. private _poseControlledCamera;
  17613. private _leftHandSystemQuaternion;
  17614. /**
  17615. * Internal, matrix used to convert room space to babylon space
  17616. * @hidden
  17617. */
  17618. _deviceToWorld: Matrix;
  17619. /**
  17620. * Node to be used when casting a ray from the controller
  17621. * @hidden
  17622. */
  17623. _pointingPoseNode: Nullable<TransformNode>;
  17624. /**
  17625. * Name of the child mesh that can be used to cast a ray from the controller
  17626. */
  17627. static readonly POINTING_POSE: string;
  17628. /**
  17629. * Creates a new PoseEnabledController from a gamepad
  17630. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  17631. */
  17632. constructor(browserGamepad: any);
  17633. private _workingMatrix;
  17634. /**
  17635. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  17636. */
  17637. update(): void;
  17638. /**
  17639. * Updates only the pose device and mesh without doing any button event checking
  17640. */
  17641. protected _updatePoseAndMesh(): void;
  17642. /**
  17643. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  17644. * @param poseData raw pose fromthe device
  17645. */
  17646. updateFromDevice(poseData: DevicePose): void;
  17647. /**
  17648. * @hidden
  17649. */
  17650. _meshAttachedObservable: Observable<AbstractMesh>;
  17651. /**
  17652. * Attaches a mesh to the controller
  17653. * @param mesh the mesh to be attached
  17654. */
  17655. attachToMesh(mesh: AbstractMesh): void;
  17656. /**
  17657. * Attaches the controllers mesh to a camera
  17658. * @param camera the camera the mesh should be attached to
  17659. */
  17660. attachToPoseControlledCamera(camera: TargetCamera): void;
  17661. /**
  17662. * Disposes of the controller
  17663. */
  17664. dispose(): void;
  17665. /**
  17666. * The mesh that is attached to the controller
  17667. */
  17668. readonly mesh: Nullable<AbstractMesh>;
  17669. /**
  17670. * Gets the ray of the controller in the direction the controller is pointing
  17671. * @param length the length the resulting ray should be
  17672. * @returns a ray in the direction the controller is pointing
  17673. */
  17674. getForwardRay(length?: number): Ray;
  17675. }
  17676. }
  17677. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  17678. import { Observable } from "babylonjs/Misc/observable";
  17679. import { Scene } from "babylonjs/scene";
  17680. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17681. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  17682. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  17683. /**
  17684. * Defines the WebVRController object that represents controllers tracked in 3D space
  17685. */
  17686. export abstract class WebVRController extends PoseEnabledController {
  17687. /**
  17688. * Internal, the default controller model for the controller
  17689. */
  17690. protected _defaultModel: AbstractMesh;
  17691. /**
  17692. * Fired when the trigger state has changed
  17693. */
  17694. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  17695. /**
  17696. * Fired when the main button state has changed
  17697. */
  17698. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17699. /**
  17700. * Fired when the secondary button state has changed
  17701. */
  17702. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  17703. /**
  17704. * Fired when the pad state has changed
  17705. */
  17706. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  17707. /**
  17708. * Fired when controllers stick values have changed
  17709. */
  17710. onPadValuesChangedObservable: Observable<StickValues>;
  17711. /**
  17712. * Array of button availible on the controller
  17713. */
  17714. protected _buttons: Array<MutableGamepadButton>;
  17715. private _onButtonStateChange;
  17716. /**
  17717. * Fired when a controller button's state has changed
  17718. * @param callback the callback containing the button that was modified
  17719. */
  17720. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  17721. /**
  17722. * X and Y axis corresponding to the controllers joystick
  17723. */
  17724. pad: StickValues;
  17725. /**
  17726. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  17727. */
  17728. hand: string;
  17729. /**
  17730. * The default controller model for the controller
  17731. */
  17732. readonly defaultModel: AbstractMesh;
  17733. /**
  17734. * Creates a new WebVRController from a gamepad
  17735. * @param vrGamepad the gamepad that the WebVRController should be created from
  17736. */
  17737. constructor(vrGamepad: any);
  17738. /**
  17739. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  17740. */
  17741. update(): void;
  17742. /**
  17743. * Function to be called when a button is modified
  17744. */
  17745. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  17746. /**
  17747. * Loads a mesh and attaches it to the controller
  17748. * @param scene the scene the mesh should be added to
  17749. * @param meshLoaded callback for when the mesh has been loaded
  17750. */
  17751. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  17752. private _setButtonValue;
  17753. private _changes;
  17754. private _checkChanges;
  17755. /**
  17756. * Disposes of th webVRCOntroller
  17757. */
  17758. dispose(): void;
  17759. }
  17760. }
  17761. declare module "babylonjs/Lights/hemisphericLight" {
  17762. import { Nullable } from "babylonjs/types";
  17763. import { Scene } from "babylonjs/scene";
  17764. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  17765. import { Effect } from "babylonjs/Materials/effect";
  17766. import { Light } from "babylonjs/Lights/light";
  17767. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17768. /**
  17769. * The HemisphericLight simulates the ambient environment light,
  17770. * so the passed direction is the light reflection direction, not the incoming direction.
  17771. */
  17772. export class HemisphericLight extends Light {
  17773. /**
  17774. * The groundColor is the light in the opposite direction to the one specified during creation.
  17775. * 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.
  17776. */
  17777. groundColor: Color3;
  17778. /**
  17779. * The light reflection direction, not the incoming direction.
  17780. */
  17781. direction: Vector3;
  17782. /**
  17783. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  17784. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  17785. * The HemisphericLight can't cast shadows.
  17786. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17787. * @param name The friendly name of the light
  17788. * @param direction The direction of the light reflection
  17789. * @param scene The scene the light belongs to
  17790. */
  17791. constructor(name: string, direction: Vector3, scene: Scene);
  17792. protected _buildUniformLayout(): void;
  17793. /**
  17794. * Returns the string "HemisphericLight".
  17795. * @return The class name
  17796. */
  17797. getClassName(): string;
  17798. /**
  17799. * Sets the HemisphericLight direction towards the passed target (Vector3).
  17800. * Returns the updated direction.
  17801. * @param target The target the direction should point to
  17802. * @return The computed direction
  17803. */
  17804. setDirectionToTarget(target: Vector3): Vector3;
  17805. /**
  17806. * Returns the shadow generator associated to the light.
  17807. * @returns Always null for hemispheric lights because it does not support shadows.
  17808. */
  17809. getShadowGenerator(): Nullable<IShadowGenerator>;
  17810. /**
  17811. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  17812. * @param effect The effect to update
  17813. * @param lightIndex The index of the light in the effect to update
  17814. * @returns The hemispheric light
  17815. */
  17816. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  17817. /**
  17818. * Computes the world matrix of the node
  17819. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  17820. * @param useWasUpdatedFlag defines a reserved property
  17821. * @returns the world matrix
  17822. */
  17823. computeWorldMatrix(): Matrix;
  17824. /**
  17825. * Returns the integer 3.
  17826. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17827. */
  17828. getTypeID(): number;
  17829. /**
  17830. * Prepares the list of defines specific to the light type.
  17831. * @param defines the list of defines
  17832. * @param lightIndex defines the index of the light for the effect
  17833. */
  17834. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17835. }
  17836. }
  17837. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  17838. /** @hidden */
  17839. export var vrMultiviewToSingleviewPixelShader: {
  17840. name: string;
  17841. shader: string;
  17842. };
  17843. }
  17844. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  17845. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17846. import { Scene } from "babylonjs/scene";
  17847. /**
  17848. * Renders to multiple views with a single draw call
  17849. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  17850. */
  17851. export class MultiviewRenderTarget extends RenderTargetTexture {
  17852. /**
  17853. * Creates a multiview render target
  17854. * @param scene scene used with the render target
  17855. * @param size the size of the render target (used for each view)
  17856. */
  17857. constructor(scene: Scene, size?: number | {
  17858. width: number;
  17859. height: number;
  17860. } | {
  17861. ratio: number;
  17862. });
  17863. /**
  17864. * @hidden
  17865. * @param faceIndex the face index, if its a cube texture
  17866. */
  17867. _bindFrameBuffer(faceIndex?: number): void;
  17868. /**
  17869. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17870. * @returns the view count
  17871. */
  17872. getViewCount(): number;
  17873. }
  17874. }
  17875. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  17876. import { Camera } from "babylonjs/Cameras/camera";
  17877. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17878. import { Nullable } from "babylonjs/types";
  17879. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17880. import { Matrix } from "babylonjs/Maths/math";
  17881. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17882. module "babylonjs/Engines/engine" {
  17883. interface Engine {
  17884. /**
  17885. * Creates a new multiview render target
  17886. * @param width defines the width of the texture
  17887. * @param height defines the height of the texture
  17888. * @returns the created multiview texture
  17889. */
  17890. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  17891. /**
  17892. * Binds a multiview framebuffer to be drawn to
  17893. * @param multiviewTexture texture to bind
  17894. */
  17895. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  17896. }
  17897. }
  17898. module "babylonjs/Cameras/camera" {
  17899. interface Camera {
  17900. /**
  17901. * @hidden
  17902. * 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)
  17903. */
  17904. _useMultiviewToSingleView: boolean;
  17905. /**
  17906. * @hidden
  17907. * 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)
  17908. */
  17909. _multiviewTexture: Nullable<RenderTargetTexture>;
  17910. /**
  17911. * @hidden
  17912. * ensures the multiview texture of the camera exists and has the specified width/height
  17913. * @param width height to set on the multiview texture
  17914. * @param height width to set on the multiview texture
  17915. */
  17916. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  17917. }
  17918. }
  17919. module "babylonjs/scene" {
  17920. interface Scene {
  17921. /** @hidden */
  17922. _transformMatrixR: Matrix;
  17923. /** @hidden */
  17924. _multiviewSceneUbo: Nullable<UniformBuffer>;
  17925. /** @hidden */
  17926. _createMultiviewUbo(): void;
  17927. /** @hidden */
  17928. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  17929. /** @hidden */
  17930. _renderMultiviewToSingleView(camera: Camera): void;
  17931. }
  17932. }
  17933. }
  17934. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  17935. import { Camera } from "babylonjs/Cameras/camera";
  17936. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17937. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  17938. import "babylonjs/Engines/Extensions/engine.multiview";
  17939. /**
  17940. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  17941. * This will not be used for webXR as it supports displaying texture arrays directly
  17942. */
  17943. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  17944. /**
  17945. * Initializes a VRMultiviewToSingleview
  17946. * @param name name of the post process
  17947. * @param camera camera to be applied to
  17948. * @param scaleFactor scaling factor to the size of the output texture
  17949. */
  17950. constructor(name: string, camera: Camera, scaleFactor: number);
  17951. }
  17952. }
  17953. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  17954. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  17955. import { Nullable } from "babylonjs/types";
  17956. import { Size } from "babylonjs/Maths/math";
  17957. import { Observable } from "babylonjs/Misc/observable";
  17958. module "babylonjs/Engines/engine" {
  17959. interface Engine {
  17960. /** @hidden */
  17961. _vrDisplay: any;
  17962. /** @hidden */
  17963. _vrSupported: boolean;
  17964. /** @hidden */
  17965. _oldSize: Size;
  17966. /** @hidden */
  17967. _oldHardwareScaleFactor: number;
  17968. /** @hidden */
  17969. _vrExclusivePointerMode: boolean;
  17970. /** @hidden */
  17971. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  17972. /** @hidden */
  17973. _onVRDisplayPointerRestricted: () => void;
  17974. /** @hidden */
  17975. _onVRDisplayPointerUnrestricted: () => void;
  17976. /** @hidden */
  17977. _onVrDisplayConnect: Nullable<(display: any) => void>;
  17978. /** @hidden */
  17979. _onVrDisplayDisconnect: Nullable<() => void>;
  17980. /** @hidden */
  17981. _onVrDisplayPresentChange: Nullable<() => void>;
  17982. /**
  17983. * Observable signaled when VR display mode changes
  17984. */
  17985. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  17986. /**
  17987. * Observable signaled when VR request present is complete
  17988. */
  17989. onVRRequestPresentComplete: Observable<boolean>;
  17990. /**
  17991. * Observable signaled when VR request present starts
  17992. */
  17993. onVRRequestPresentStart: Observable<Engine>;
  17994. /**
  17995. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  17996. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  17997. */
  17998. isInVRExclusivePointerMode: boolean;
  17999. /**
  18000. * Gets a boolean indicating if a webVR device was detected
  18001. * @returns true if a webVR device was detected
  18002. */
  18003. isVRDevicePresent(): boolean;
  18004. /**
  18005. * Gets the current webVR device
  18006. * @returns the current webVR device (or null)
  18007. */
  18008. getVRDevice(): any;
  18009. /**
  18010. * Initializes a webVR display and starts listening to display change events
  18011. * The onVRDisplayChangedObservable will be notified upon these changes
  18012. * @returns A promise containing a VRDisplay and if vr is supported
  18013. */
  18014. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  18015. /** @hidden */
  18016. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  18017. /**
  18018. * Call this function to switch to webVR mode
  18019. * Will do nothing if webVR is not supported or if there is no webVR device
  18020. * @see http://doc.babylonjs.com/how_to/webvr_camera
  18021. */
  18022. enableVR(): void;
  18023. /** @hidden */
  18024. _onVRFullScreenTriggered(): void;
  18025. }
  18026. }
  18027. }
  18028. declare module "babylonjs/Cameras/VR/webVRCamera" {
  18029. import { Nullable } from "babylonjs/types";
  18030. import { Observable } from "babylonjs/Misc/observable";
  18031. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18032. import { Scene } from "babylonjs/scene";
  18033. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  18034. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  18035. import { Node } from "babylonjs/node";
  18036. import { Ray } from "babylonjs/Culling/ray";
  18037. import "babylonjs/Cameras/RigModes/webVRRigMode";
  18038. import "babylonjs/Engines/Extensions/engine.webVR";
  18039. /**
  18040. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  18041. * IMPORTANT!! The data is right-hand data.
  18042. * @export
  18043. * @interface DevicePose
  18044. */
  18045. export interface DevicePose {
  18046. /**
  18047. * The position of the device, values in array are [x,y,z].
  18048. */
  18049. readonly position: Nullable<Float32Array>;
  18050. /**
  18051. * The linearVelocity of the device, values in array are [x,y,z].
  18052. */
  18053. readonly linearVelocity: Nullable<Float32Array>;
  18054. /**
  18055. * The linearAcceleration of the device, values in array are [x,y,z].
  18056. */
  18057. readonly linearAcceleration: Nullable<Float32Array>;
  18058. /**
  18059. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  18060. */
  18061. readonly orientation: Nullable<Float32Array>;
  18062. /**
  18063. * The angularVelocity of the device, values in array are [x,y,z].
  18064. */
  18065. readonly angularVelocity: Nullable<Float32Array>;
  18066. /**
  18067. * The angularAcceleration of the device, values in array are [x,y,z].
  18068. */
  18069. readonly angularAcceleration: Nullable<Float32Array>;
  18070. }
  18071. /**
  18072. * Interface representing a pose controlled object in Babylon.
  18073. * A pose controlled object has both regular pose values as well as pose values
  18074. * from an external device such as a VR head mounted display
  18075. */
  18076. export interface PoseControlled {
  18077. /**
  18078. * The position of the object in babylon space.
  18079. */
  18080. position: Vector3;
  18081. /**
  18082. * The rotation quaternion of the object in babylon space.
  18083. */
  18084. rotationQuaternion: Quaternion;
  18085. /**
  18086. * The position of the device in babylon space.
  18087. */
  18088. devicePosition?: Vector3;
  18089. /**
  18090. * The rotation quaternion of the device in babylon space.
  18091. */
  18092. deviceRotationQuaternion: Quaternion;
  18093. /**
  18094. * The raw pose coming from the device.
  18095. */
  18096. rawPose: Nullable<DevicePose>;
  18097. /**
  18098. * The scale of the device to be used when translating from device space to babylon space.
  18099. */
  18100. deviceScaleFactor: number;
  18101. /**
  18102. * Updates the poseControlled values based on the input device pose.
  18103. * @param poseData the pose data to update the object with
  18104. */
  18105. updateFromDevice(poseData: DevicePose): void;
  18106. }
  18107. /**
  18108. * Set of options to customize the webVRCamera
  18109. */
  18110. export interface WebVROptions {
  18111. /**
  18112. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  18113. */
  18114. trackPosition?: boolean;
  18115. /**
  18116. * Sets the scale of the vrDevice in babylon space. (default: 1)
  18117. */
  18118. positionScale?: number;
  18119. /**
  18120. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  18121. */
  18122. displayName?: string;
  18123. /**
  18124. * Should the native controller meshes be initialized. (default: true)
  18125. */
  18126. controllerMeshes?: boolean;
  18127. /**
  18128. * Creating a default HemiLight only on controllers. (default: true)
  18129. */
  18130. defaultLightingOnControllers?: boolean;
  18131. /**
  18132. * If you don't want to use the default VR button of the helper. (default: false)
  18133. */
  18134. useCustomVRButton?: boolean;
  18135. /**
  18136. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  18137. */
  18138. customVRButton?: HTMLButtonElement;
  18139. /**
  18140. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  18141. */
  18142. rayLength?: number;
  18143. /**
  18144. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  18145. */
  18146. defaultHeight?: number;
  18147. /**
  18148. * If multiview should be used if availible (default: false)
  18149. */
  18150. useMultiview?: boolean;
  18151. }
  18152. /**
  18153. * This represents a WebVR camera.
  18154. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  18155. * @example http://doc.babylonjs.com/how_to/webvr_camera
  18156. */
  18157. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  18158. private webVROptions;
  18159. /**
  18160. * @hidden
  18161. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  18162. */
  18163. _vrDevice: any;
  18164. /**
  18165. * The rawPose of the vrDevice.
  18166. */
  18167. rawPose: Nullable<DevicePose>;
  18168. private _onVREnabled;
  18169. private _specsVersion;
  18170. private _attached;
  18171. private _frameData;
  18172. protected _descendants: Array<Node>;
  18173. private _deviceRoomPosition;
  18174. /** @hidden */
  18175. _deviceRoomRotationQuaternion: Quaternion;
  18176. private _standingMatrix;
  18177. /**
  18178. * Represents device position in babylon space.
  18179. */
  18180. devicePosition: Vector3;
  18181. /**
  18182. * Represents device rotation in babylon space.
  18183. */
  18184. deviceRotationQuaternion: Quaternion;
  18185. /**
  18186. * The scale of the device to be used when translating from device space to babylon space.
  18187. */
  18188. deviceScaleFactor: number;
  18189. private _deviceToWorld;
  18190. private _worldToDevice;
  18191. /**
  18192. * References to the webVR controllers for the vrDevice.
  18193. */
  18194. controllers: Array<WebVRController>;
  18195. /**
  18196. * Emits an event when a controller is attached.
  18197. */
  18198. onControllersAttachedObservable: Observable<WebVRController[]>;
  18199. /**
  18200. * Emits an event when a controller's mesh has been loaded;
  18201. */
  18202. onControllerMeshLoadedObservable: Observable<WebVRController>;
  18203. /**
  18204. * Emits an event when the HMD's pose has been updated.
  18205. */
  18206. onPoseUpdatedFromDeviceObservable: Observable<any>;
  18207. private _poseSet;
  18208. /**
  18209. * If the rig cameras be used as parent instead of this camera.
  18210. */
  18211. rigParenting: boolean;
  18212. private _lightOnControllers;
  18213. private _defaultHeight?;
  18214. /**
  18215. * Instantiates a WebVRFreeCamera.
  18216. * @param name The name of the WebVRFreeCamera
  18217. * @param position The starting anchor position for the camera
  18218. * @param scene The scene the camera belongs to
  18219. * @param webVROptions a set of customizable options for the webVRCamera
  18220. */
  18221. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  18222. /**
  18223. * Gets the device distance from the ground in meters.
  18224. * @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.
  18225. */
  18226. deviceDistanceToRoomGround(): number;
  18227. /**
  18228. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18229. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  18230. */
  18231. useStandingMatrix(callback?: (bool: boolean) => void): void;
  18232. /**
  18233. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  18234. * @returns A promise with a boolean set to if the standing matrix is supported.
  18235. */
  18236. useStandingMatrixAsync(): Promise<boolean>;
  18237. /**
  18238. * Disposes the camera
  18239. */
  18240. dispose(): void;
  18241. /**
  18242. * Gets a vrController by name.
  18243. * @param name The name of the controller to retreive
  18244. * @returns the controller matching the name specified or null if not found
  18245. */
  18246. getControllerByName(name: string): Nullable<WebVRController>;
  18247. private _leftController;
  18248. /**
  18249. * The controller corresponding to the users left hand.
  18250. */
  18251. readonly leftController: Nullable<WebVRController>;
  18252. private _rightController;
  18253. /**
  18254. * The controller corresponding to the users right hand.
  18255. */
  18256. readonly rightController: Nullable<WebVRController>;
  18257. /**
  18258. * Casts a ray forward from the vrCamera's gaze.
  18259. * @param length Length of the ray (default: 100)
  18260. * @returns the ray corresponding to the gaze
  18261. */
  18262. getForwardRay(length?: number): Ray;
  18263. /**
  18264. * @hidden
  18265. * Updates the camera based on device's frame data
  18266. */
  18267. _checkInputs(): void;
  18268. /**
  18269. * Updates the poseControlled values based on the input device pose.
  18270. * @param poseData Pose coming from the device
  18271. */
  18272. updateFromDevice(poseData: DevicePose): void;
  18273. private _htmlElementAttached;
  18274. private _detachIfAttached;
  18275. /**
  18276. * WebVR's attach control will start broadcasting frames to the device.
  18277. * Note that in certain browsers (chrome for example) this function must be called
  18278. * within a user-interaction callback. Example:
  18279. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  18280. *
  18281. * @param element html element to attach the vrDevice to
  18282. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  18283. */
  18284. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18285. /**
  18286. * Detaches the camera from the html element and disables VR
  18287. *
  18288. * @param element html element to detach from
  18289. */
  18290. detachControl(element: HTMLElement): void;
  18291. /**
  18292. * @returns the name of this class
  18293. */
  18294. getClassName(): string;
  18295. /**
  18296. * Calls resetPose on the vrDisplay
  18297. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  18298. */
  18299. resetToCurrentRotation(): void;
  18300. /**
  18301. * @hidden
  18302. * Updates the rig cameras (left and right eye)
  18303. */
  18304. _updateRigCameras(): void;
  18305. private _workingVector;
  18306. private _oneVector;
  18307. private _workingMatrix;
  18308. private updateCacheCalled;
  18309. private _correctPositionIfNotTrackPosition;
  18310. /**
  18311. * @hidden
  18312. * Updates the cached values of the camera
  18313. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  18314. */
  18315. _updateCache(ignoreParentClass?: boolean): void;
  18316. /**
  18317. * @hidden
  18318. * Get current device position in babylon world
  18319. */
  18320. _computeDevicePosition(): void;
  18321. /**
  18322. * Updates the current device position and rotation in the babylon world
  18323. */
  18324. update(): void;
  18325. /**
  18326. * @hidden
  18327. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  18328. * @returns an identity matrix
  18329. */
  18330. _getViewMatrix(): Matrix;
  18331. private _tmpMatrix;
  18332. /**
  18333. * This function is called by the two RIG cameras.
  18334. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  18335. * @hidden
  18336. */
  18337. _getWebVRViewMatrix(): Matrix;
  18338. /** @hidden */
  18339. _getWebVRProjectionMatrix(): Matrix;
  18340. private _onGamepadConnectedObserver;
  18341. private _onGamepadDisconnectedObserver;
  18342. private _updateCacheWhenTrackingDisabledObserver;
  18343. /**
  18344. * Initializes the controllers and their meshes
  18345. */
  18346. initControllers(): void;
  18347. }
  18348. }
  18349. declare module "babylonjs/PostProcesses/postProcess" {
  18350. import { Nullable } from "babylonjs/types";
  18351. import { SmartArray } from "babylonjs/Misc/smartArray";
  18352. import { Observable } from "babylonjs/Misc/observable";
  18353. import { Color4, Vector2 } from "babylonjs/Maths/math";
  18354. import { Camera } from "babylonjs/Cameras/camera";
  18355. import { Effect } from "babylonjs/Materials/effect";
  18356. import "babylonjs/Shaders/postprocess.vertex";
  18357. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18358. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18359. import { Engine } from "babylonjs/Engines/engine";
  18360. /**
  18361. * Size options for a post process
  18362. */
  18363. export type PostProcessOptions = {
  18364. width: number;
  18365. height: number;
  18366. };
  18367. /**
  18368. * PostProcess can be used to apply a shader to a texture after it has been rendered
  18369. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  18370. */
  18371. export class PostProcess {
  18372. /** Name of the PostProcess. */
  18373. name: string;
  18374. /**
  18375. * Gets or sets the unique id of the post process
  18376. */
  18377. uniqueId: number;
  18378. /**
  18379. * Width of the texture to apply the post process on
  18380. */
  18381. width: number;
  18382. /**
  18383. * Height of the texture to apply the post process on
  18384. */
  18385. height: number;
  18386. /**
  18387. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  18388. * @hidden
  18389. */
  18390. _outputTexture: Nullable<InternalTexture>;
  18391. /**
  18392. * Sampling mode used by the shader
  18393. * See https://doc.babylonjs.com/classes/3.1/texture
  18394. */
  18395. renderTargetSamplingMode: number;
  18396. /**
  18397. * Clear color to use when screen clearing
  18398. */
  18399. clearColor: Color4;
  18400. /**
  18401. * If the buffer needs to be cleared before applying the post process. (default: true)
  18402. * Should be set to false if shader will overwrite all previous pixels.
  18403. */
  18404. autoClear: boolean;
  18405. /**
  18406. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  18407. */
  18408. alphaMode: number;
  18409. /**
  18410. * Sets the setAlphaBlendConstants of the babylon engine
  18411. */
  18412. alphaConstants: Color4;
  18413. /**
  18414. * Animations to be used for the post processing
  18415. */
  18416. animations: import("babylonjs/Animations/animation").Animation[];
  18417. /**
  18418. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  18419. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  18420. */
  18421. enablePixelPerfectMode: boolean;
  18422. /**
  18423. * Force the postprocess to be applied without taking in account viewport
  18424. */
  18425. forceFullscreenViewport: boolean;
  18426. /**
  18427. * List of inspectable custom properties (used by the Inspector)
  18428. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18429. */
  18430. inspectableCustomProperties: IInspectable[];
  18431. /**
  18432. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  18433. *
  18434. * | Value | Type | Description |
  18435. * | ----- | ----------------------------------- | ----------- |
  18436. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  18437. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  18438. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  18439. *
  18440. */
  18441. scaleMode: number;
  18442. /**
  18443. * Force textures to be a power of two (default: false)
  18444. */
  18445. alwaysForcePOT: boolean;
  18446. private _samples;
  18447. /**
  18448. * Number of sample textures (default: 1)
  18449. */
  18450. samples: number;
  18451. /**
  18452. * Modify the scale of the post process to be the same as the viewport (default: false)
  18453. */
  18454. adaptScaleToCurrentViewport: boolean;
  18455. private _camera;
  18456. private _scene;
  18457. private _engine;
  18458. private _options;
  18459. private _reusable;
  18460. private _textureType;
  18461. /**
  18462. * Smart array of input and output textures for the post process.
  18463. * @hidden
  18464. */
  18465. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  18466. /**
  18467. * The index in _textures that corresponds to the output texture.
  18468. * @hidden
  18469. */
  18470. _currentRenderTextureInd: number;
  18471. private _effect;
  18472. private _samplers;
  18473. private _fragmentUrl;
  18474. private _vertexUrl;
  18475. private _parameters;
  18476. private _scaleRatio;
  18477. protected _indexParameters: any;
  18478. private _shareOutputWithPostProcess;
  18479. private _texelSize;
  18480. private _forcedOutputTexture;
  18481. /**
  18482. * Returns the fragment url or shader name used in the post process.
  18483. * @returns the fragment url or name in the shader store.
  18484. */
  18485. getEffectName(): string;
  18486. /**
  18487. * An event triggered when the postprocess is activated.
  18488. */
  18489. onActivateObservable: Observable<Camera>;
  18490. private _onActivateObserver;
  18491. /**
  18492. * A function that is added to the onActivateObservable
  18493. */
  18494. onActivate: Nullable<(camera: Camera) => void>;
  18495. /**
  18496. * An event triggered when the postprocess changes its size.
  18497. */
  18498. onSizeChangedObservable: Observable<PostProcess>;
  18499. private _onSizeChangedObserver;
  18500. /**
  18501. * A function that is added to the onSizeChangedObservable
  18502. */
  18503. onSizeChanged: (postProcess: PostProcess) => void;
  18504. /**
  18505. * An event triggered when the postprocess applies its effect.
  18506. */
  18507. onApplyObservable: Observable<Effect>;
  18508. private _onApplyObserver;
  18509. /**
  18510. * A function that is added to the onApplyObservable
  18511. */
  18512. onApply: (effect: Effect) => void;
  18513. /**
  18514. * An event triggered before rendering the postprocess
  18515. */
  18516. onBeforeRenderObservable: Observable<Effect>;
  18517. private _onBeforeRenderObserver;
  18518. /**
  18519. * A function that is added to the onBeforeRenderObservable
  18520. */
  18521. onBeforeRender: (effect: Effect) => void;
  18522. /**
  18523. * An event triggered after rendering the postprocess
  18524. */
  18525. onAfterRenderObservable: Observable<Effect>;
  18526. private _onAfterRenderObserver;
  18527. /**
  18528. * A function that is added to the onAfterRenderObservable
  18529. */
  18530. onAfterRender: (efect: Effect) => void;
  18531. /**
  18532. * 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
  18533. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  18534. */
  18535. inputTexture: InternalTexture;
  18536. /**
  18537. * Gets the camera which post process is applied to.
  18538. * @returns The camera the post process is applied to.
  18539. */
  18540. getCamera(): Camera;
  18541. /**
  18542. * Gets the texel size of the postprocess.
  18543. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  18544. */
  18545. readonly texelSize: Vector2;
  18546. /**
  18547. * Creates a new instance PostProcess
  18548. * @param name The name of the PostProcess.
  18549. * @param fragmentUrl The url of the fragment shader to be used.
  18550. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  18551. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  18552. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18553. * @param camera The camera to apply the render pass to.
  18554. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18555. * @param engine The engine which the post process will be applied. (default: current engine)
  18556. * @param reusable If the post process can be reused on the same frame. (default: false)
  18557. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  18558. * @param textureType Type of textures used when performing the post process. (default: 0)
  18559. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  18560. * @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
  18561. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  18562. */
  18563. constructor(
  18564. /** Name of the PostProcess. */
  18565. 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);
  18566. /**
  18567. * Gets a string idenfifying the name of the class
  18568. * @returns "PostProcess" string
  18569. */
  18570. getClassName(): string;
  18571. /**
  18572. * Gets the engine which this post process belongs to.
  18573. * @returns The engine the post process was enabled with.
  18574. */
  18575. getEngine(): Engine;
  18576. /**
  18577. * The effect that is created when initializing the post process.
  18578. * @returns The created effect corresponding the the postprocess.
  18579. */
  18580. getEffect(): Effect;
  18581. /**
  18582. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  18583. * @param postProcess The post process to share the output with.
  18584. * @returns This post process.
  18585. */
  18586. shareOutputWith(postProcess: PostProcess): PostProcess;
  18587. /**
  18588. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  18589. * This should be called if the post process that shares output with this post process is disabled/disposed.
  18590. */
  18591. useOwnOutput(): void;
  18592. /**
  18593. * Updates the effect with the current post process compile time values and recompiles the shader.
  18594. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18595. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18596. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18597. * @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
  18598. * @param onCompiled Called when the shader has been compiled.
  18599. * @param onError Called if there is an error when compiling a shader.
  18600. */
  18601. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18602. /**
  18603. * The post process is reusable if it can be used multiple times within one frame.
  18604. * @returns If the post process is reusable
  18605. */
  18606. isReusable(): boolean;
  18607. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  18608. markTextureDirty(): void;
  18609. /**
  18610. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  18611. * 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.
  18612. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  18613. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  18614. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  18615. * @returns The target texture that was bound to be written to.
  18616. */
  18617. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  18618. /**
  18619. * If the post process is supported.
  18620. */
  18621. readonly isSupported: boolean;
  18622. /**
  18623. * The aspect ratio of the output texture.
  18624. */
  18625. readonly aspectRatio: number;
  18626. /**
  18627. * Get a value indicating if the post-process is ready to be used
  18628. * @returns true if the post-process is ready (shader is compiled)
  18629. */
  18630. isReady(): boolean;
  18631. /**
  18632. * Binds all textures and uniforms to the shader, this will be run on every pass.
  18633. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  18634. */
  18635. apply(): Nullable<Effect>;
  18636. private _disposeTextures;
  18637. /**
  18638. * Disposes the post process.
  18639. * @param camera The camera to dispose the post process on.
  18640. */
  18641. dispose(camera?: Camera): void;
  18642. }
  18643. }
  18644. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  18645. /** @hidden */
  18646. export var kernelBlurVaryingDeclaration: {
  18647. name: string;
  18648. shader: string;
  18649. };
  18650. }
  18651. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  18652. /** @hidden */
  18653. export var kernelBlurFragment: {
  18654. name: string;
  18655. shader: string;
  18656. };
  18657. }
  18658. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  18659. /** @hidden */
  18660. export var kernelBlurFragment2: {
  18661. name: string;
  18662. shader: string;
  18663. };
  18664. }
  18665. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  18666. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  18667. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  18668. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  18669. /** @hidden */
  18670. export var kernelBlurPixelShader: {
  18671. name: string;
  18672. shader: string;
  18673. };
  18674. }
  18675. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  18676. /** @hidden */
  18677. export var kernelBlurVertex: {
  18678. name: string;
  18679. shader: string;
  18680. };
  18681. }
  18682. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  18683. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  18684. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  18685. /** @hidden */
  18686. export var kernelBlurVertexShader: {
  18687. name: string;
  18688. shader: string;
  18689. };
  18690. }
  18691. declare module "babylonjs/PostProcesses/blurPostProcess" {
  18692. import { Vector2 } from "babylonjs/Maths/math";
  18693. import { Nullable } from "babylonjs/types";
  18694. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  18695. import { Camera } from "babylonjs/Cameras/camera";
  18696. import { Effect } from "babylonjs/Materials/effect";
  18697. import { Engine } from "babylonjs/Engines/engine";
  18698. import "babylonjs/Shaders/kernelBlur.fragment";
  18699. import "babylonjs/Shaders/kernelBlur.vertex";
  18700. /**
  18701. * The Blur Post Process which blurs an image based on a kernel and direction.
  18702. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  18703. */
  18704. export class BlurPostProcess extends PostProcess {
  18705. /** The direction in which to blur the image. */
  18706. direction: Vector2;
  18707. private blockCompilation;
  18708. protected _kernel: number;
  18709. protected _idealKernel: number;
  18710. protected _packedFloat: boolean;
  18711. private _staticDefines;
  18712. /**
  18713. * Sets the length in pixels of the blur sample region
  18714. */
  18715. /**
  18716. * Gets the length in pixels of the blur sample region
  18717. */
  18718. kernel: number;
  18719. /**
  18720. * Sets wether or not the blur needs to unpack/repack floats
  18721. */
  18722. /**
  18723. * Gets wether or not the blur is unpacking/repacking floats
  18724. */
  18725. packedFloat: boolean;
  18726. /**
  18727. * Creates a new instance BlurPostProcess
  18728. * @param name The name of the effect.
  18729. * @param direction The direction in which to blur the image.
  18730. * @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.
  18731. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18732. * @param camera The camera to apply the render pass to.
  18733. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18734. * @param engine The engine which the post process will be applied. (default: current engine)
  18735. * @param reusable If the post process can be reused on the same frame. (default: false)
  18736. * @param textureType Type of textures used when performing the post process. (default: 0)
  18737. * @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)
  18738. */
  18739. constructor(name: string,
  18740. /** The direction in which to blur the image. */
  18741. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  18742. /**
  18743. * Updates the effect with the current post process compile time values and recompiles the shader.
  18744. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  18745. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  18746. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  18747. * @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
  18748. * @param onCompiled Called when the shader has been compiled.
  18749. * @param onError Called if there is an error when compiling a shader.
  18750. */
  18751. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18752. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18753. /**
  18754. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  18755. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  18756. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  18757. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  18758. * The gaps between physical kernels are compensated for in the weighting of the samples
  18759. * @param idealKernel Ideal blur kernel.
  18760. * @return Nearest best kernel.
  18761. */
  18762. protected _nearestBestKernel(idealKernel: number): number;
  18763. /**
  18764. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  18765. * @param x The point on the Gaussian distribution to sample.
  18766. * @return the value of the Gaussian function at x.
  18767. */
  18768. protected _gaussianWeight(x: number): number;
  18769. /**
  18770. * Generates a string that can be used as a floating point number in GLSL.
  18771. * @param x Value to print.
  18772. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  18773. * @return GLSL float string.
  18774. */
  18775. protected _glslFloat(x: number, decimalFigures?: number): string;
  18776. }
  18777. }
  18778. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18779. import { Scene } from "babylonjs/scene";
  18780. import { Plane } from "babylonjs/Maths/math";
  18781. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18782. /**
  18783. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18784. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18785. * You can then easily use it as a reflectionTexture on a flat surface.
  18786. * In case the surface is not a plane, please consider relying on reflection probes.
  18787. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18788. */
  18789. export class MirrorTexture extends RenderTargetTexture {
  18790. private scene;
  18791. /**
  18792. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18793. * 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.
  18794. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18795. */
  18796. mirrorPlane: Plane;
  18797. /**
  18798. * Define the blur ratio used to blur the reflection if needed.
  18799. */
  18800. blurRatio: number;
  18801. /**
  18802. * Define the adaptive blur kernel used to blur the reflection if needed.
  18803. * This will autocompute the closest best match for the `blurKernel`
  18804. */
  18805. adaptiveBlurKernel: number;
  18806. /**
  18807. * Define the blur kernel used to blur the reflection if needed.
  18808. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18809. */
  18810. blurKernel: number;
  18811. /**
  18812. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18813. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18814. */
  18815. blurKernelX: number;
  18816. /**
  18817. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18818. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18819. */
  18820. blurKernelY: number;
  18821. private _autoComputeBlurKernel;
  18822. protected _onRatioRescale(): void;
  18823. private _updateGammaSpace;
  18824. private _imageProcessingConfigChangeObserver;
  18825. private _transformMatrix;
  18826. private _mirrorMatrix;
  18827. private _savedViewMatrix;
  18828. private _blurX;
  18829. private _blurY;
  18830. private _adaptiveBlurKernel;
  18831. private _blurKernelX;
  18832. private _blurKernelY;
  18833. private _blurRatio;
  18834. /**
  18835. * Instantiates a Mirror Texture.
  18836. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18837. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18838. * You can then easily use it as a reflectionTexture on a flat surface.
  18839. * In case the surface is not a plane, please consider relying on reflection probes.
  18840. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18841. * @param name
  18842. * @param size
  18843. * @param scene
  18844. * @param generateMipMaps
  18845. * @param type
  18846. * @param samplingMode
  18847. * @param generateDepthBuffer
  18848. */
  18849. constructor(name: string, size: number | {
  18850. width: number;
  18851. height: number;
  18852. } | {
  18853. ratio: number;
  18854. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18855. private _preparePostProcesses;
  18856. /**
  18857. * Clone the mirror texture.
  18858. * @returns the cloned texture
  18859. */
  18860. clone(): MirrorTexture;
  18861. /**
  18862. * Serialize the texture to a JSON representation you could use in Parse later on
  18863. * @returns the serialized JSON representation
  18864. */
  18865. serialize(): any;
  18866. /**
  18867. * Dispose the texture and release its associated resources.
  18868. */
  18869. dispose(): void;
  18870. }
  18871. }
  18872. declare module "babylonjs/Materials/Textures/texture" {
  18873. import { Observable } from "babylonjs/Misc/observable";
  18874. import { Nullable } from "babylonjs/types";
  18875. import { Scene } from "babylonjs/scene";
  18876. import { Matrix } from "babylonjs/Maths/math";
  18877. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18878. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18879. import { Engine } from "babylonjs/Engines/engine";
  18880. /**
  18881. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18882. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18883. */
  18884. export class Texture extends BaseTexture {
  18885. /** @hidden */
  18886. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18887. /** @hidden */
  18888. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18889. /** @hidden */
  18890. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18891. /** nearest is mag = nearest and min = nearest and mip = linear */
  18892. static readonly NEAREST_SAMPLINGMODE: number;
  18893. /** nearest is mag = nearest and min = nearest and mip = linear */
  18894. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18895. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18896. static readonly BILINEAR_SAMPLINGMODE: number;
  18897. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18898. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18899. /** Trilinear is mag = linear and min = linear and mip = linear */
  18900. static readonly TRILINEAR_SAMPLINGMODE: number;
  18901. /** Trilinear is mag = linear and min = linear and mip = linear */
  18902. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18903. /** mag = nearest and min = nearest and mip = nearest */
  18904. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18905. /** mag = nearest and min = linear and mip = nearest */
  18906. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18907. /** mag = nearest and min = linear and mip = linear */
  18908. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18909. /** mag = nearest and min = linear and mip = none */
  18910. static readonly NEAREST_LINEAR: number;
  18911. /** mag = nearest and min = nearest and mip = none */
  18912. static readonly NEAREST_NEAREST: number;
  18913. /** mag = linear and min = nearest and mip = nearest */
  18914. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18915. /** mag = linear and min = nearest and mip = linear */
  18916. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18917. /** mag = linear and min = linear and mip = none */
  18918. static readonly LINEAR_LINEAR: number;
  18919. /** mag = linear and min = nearest and mip = none */
  18920. static readonly LINEAR_NEAREST: number;
  18921. /** Explicit coordinates mode */
  18922. static readonly EXPLICIT_MODE: number;
  18923. /** Spherical coordinates mode */
  18924. static readonly SPHERICAL_MODE: number;
  18925. /** Planar coordinates mode */
  18926. static readonly PLANAR_MODE: number;
  18927. /** Cubic coordinates mode */
  18928. static readonly CUBIC_MODE: number;
  18929. /** Projection coordinates mode */
  18930. static readonly PROJECTION_MODE: number;
  18931. /** Inverse Cubic coordinates mode */
  18932. static readonly SKYBOX_MODE: number;
  18933. /** Inverse Cubic coordinates mode */
  18934. static readonly INVCUBIC_MODE: number;
  18935. /** Equirectangular coordinates mode */
  18936. static readonly EQUIRECTANGULAR_MODE: number;
  18937. /** Equirectangular Fixed coordinates mode */
  18938. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18939. /** Equirectangular Fixed Mirrored coordinates mode */
  18940. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18941. /** Texture is not repeating outside of 0..1 UVs */
  18942. static readonly CLAMP_ADDRESSMODE: number;
  18943. /** Texture is repeating outside of 0..1 UVs */
  18944. static readonly WRAP_ADDRESSMODE: number;
  18945. /** Texture is repeating and mirrored */
  18946. static readonly MIRROR_ADDRESSMODE: number;
  18947. /**
  18948. * 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
  18949. */
  18950. static UseSerializedUrlIfAny: boolean;
  18951. /**
  18952. * Define the url of the texture.
  18953. */
  18954. url: Nullable<string>;
  18955. /**
  18956. * Define an offset on the texture to offset the u coordinates of the UVs
  18957. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18958. */
  18959. uOffset: number;
  18960. /**
  18961. * Define an offset on the texture to offset the v coordinates of the UVs
  18962. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18963. */
  18964. vOffset: number;
  18965. /**
  18966. * Define an offset on the texture to scale the u coordinates of the UVs
  18967. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18968. */
  18969. uScale: number;
  18970. /**
  18971. * Define an offset on the texture to scale the v coordinates of the UVs
  18972. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18973. */
  18974. vScale: number;
  18975. /**
  18976. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18977. * @see http://doc.babylonjs.com/how_to/more_materials
  18978. */
  18979. uAng: number;
  18980. /**
  18981. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18982. * @see http://doc.babylonjs.com/how_to/more_materials
  18983. */
  18984. vAng: number;
  18985. /**
  18986. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18987. * @see http://doc.babylonjs.com/how_to/more_materials
  18988. */
  18989. wAng: number;
  18990. /**
  18991. * Defines the center of rotation (U)
  18992. */
  18993. uRotationCenter: number;
  18994. /**
  18995. * Defines the center of rotation (V)
  18996. */
  18997. vRotationCenter: number;
  18998. /**
  18999. * Defines the center of rotation (W)
  19000. */
  19001. wRotationCenter: number;
  19002. /**
  19003. * Are mip maps generated for this texture or not.
  19004. */
  19005. readonly noMipmap: boolean;
  19006. /**
  19007. * List of inspectable custom properties (used by the Inspector)
  19008. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19009. */
  19010. inspectableCustomProperties: Nullable<IInspectable[]>;
  19011. private _noMipmap;
  19012. /** @hidden */
  19013. _invertY: boolean;
  19014. private _rowGenerationMatrix;
  19015. private _cachedTextureMatrix;
  19016. private _projectionModeMatrix;
  19017. private _t0;
  19018. private _t1;
  19019. private _t2;
  19020. private _cachedUOffset;
  19021. private _cachedVOffset;
  19022. private _cachedUScale;
  19023. private _cachedVScale;
  19024. private _cachedUAng;
  19025. private _cachedVAng;
  19026. private _cachedWAng;
  19027. private _cachedProjectionMatrixId;
  19028. private _cachedCoordinatesMode;
  19029. /** @hidden */
  19030. protected _initialSamplingMode: number;
  19031. /** @hidden */
  19032. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  19033. private _deleteBuffer;
  19034. protected _format: Nullable<number>;
  19035. private _delayedOnLoad;
  19036. private _delayedOnError;
  19037. /**
  19038. * Observable triggered once the texture has been loaded.
  19039. */
  19040. onLoadObservable: Observable<Texture>;
  19041. protected _isBlocking: boolean;
  19042. /**
  19043. * Is the texture preventing material to render while loading.
  19044. * If false, a default texture will be used instead of the loading one during the preparation step.
  19045. */
  19046. isBlocking: boolean;
  19047. /**
  19048. * Get the current sampling mode associated with the texture.
  19049. */
  19050. readonly samplingMode: number;
  19051. /**
  19052. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  19053. */
  19054. readonly invertY: boolean;
  19055. /**
  19056. * Instantiates a new texture.
  19057. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  19058. * @see http://doc.babylonjs.com/babylon101/materials#texture
  19059. * @param url define the url of the picture to load as a texture
  19060. * @param scene define the scene or engine the texture will belong to
  19061. * @param noMipmap define if the texture will require mip maps or not
  19062. * @param invertY define if the texture needs to be inverted on the y axis during loading
  19063. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  19064. * @param onLoad define a callback triggered when the texture has been loaded
  19065. * @param onError define a callback triggered when an error occurred during the loading session
  19066. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  19067. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  19068. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  19069. */
  19070. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  19071. /**
  19072. * Update the url (and optional buffer) of this texture if url was null during construction.
  19073. * @param url the url of the texture
  19074. * @param buffer the buffer of the texture (defaults to null)
  19075. * @param onLoad callback called when the texture is loaded (defaults to null)
  19076. */
  19077. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  19078. /**
  19079. * Finish the loading sequence of a texture flagged as delayed load.
  19080. * @hidden
  19081. */
  19082. delayLoad(): void;
  19083. private _prepareRowForTextureGeneration;
  19084. /**
  19085. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  19086. * @returns the transform matrix of the texture.
  19087. */
  19088. getTextureMatrix(): Matrix;
  19089. /**
  19090. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  19091. * @returns The reflection texture transform
  19092. */
  19093. getReflectionTextureMatrix(): Matrix;
  19094. /**
  19095. * Clones the texture.
  19096. * @returns the cloned texture
  19097. */
  19098. clone(): Texture;
  19099. /**
  19100. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19101. * @returns The JSON representation of the texture
  19102. */
  19103. serialize(): any;
  19104. /**
  19105. * Get the current class name of the texture useful for serialization or dynamic coding.
  19106. * @returns "Texture"
  19107. */
  19108. getClassName(): string;
  19109. /**
  19110. * Dispose the texture and release its associated resources.
  19111. */
  19112. dispose(): void;
  19113. /**
  19114. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  19115. * @param parsedTexture Define the JSON representation of the texture
  19116. * @param scene Define the scene the parsed texture should be instantiated in
  19117. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  19118. * @returns The parsed texture if successful
  19119. */
  19120. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  19121. /**
  19122. * Creates a texture from its base 64 representation.
  19123. * @param data Define the base64 payload without the data: prefix
  19124. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  19125. * @param scene Define the scene the texture should belong to
  19126. * @param noMipmap Forces the texture to not create mip map information if true
  19127. * @param invertY define if the texture needs to be inverted on the y axis during loading
  19128. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  19129. * @param onLoad define a callback triggered when the texture has been loaded
  19130. * @param onError define a callback triggered when an error occurred during the loading session
  19131. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  19132. * @returns the created texture
  19133. */
  19134. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  19135. /**
  19136. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  19137. * @param data Define the base64 payload without the data: prefix
  19138. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  19139. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  19140. * @param scene Define the scene the texture should belong to
  19141. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  19142. * @param noMipmap Forces the texture to not create mip map information if true
  19143. * @param invertY define if the texture needs to be inverted on the y axis during loading
  19144. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  19145. * @param onLoad define a callback triggered when the texture has been loaded
  19146. * @param onError define a callback triggered when an error occurred during the loading session
  19147. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  19148. * @returns the created texture
  19149. */
  19150. 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;
  19151. }
  19152. }
  19153. declare module "babylonjs/PostProcesses/postProcessManager" {
  19154. import { Nullable } from "babylonjs/types";
  19155. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19156. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19157. import { Scene } from "babylonjs/scene";
  19158. /**
  19159. * PostProcessManager is used to manage one or more post processes or post process pipelines
  19160. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19161. */
  19162. export class PostProcessManager {
  19163. private _scene;
  19164. private _indexBuffer;
  19165. private _vertexBuffers;
  19166. /**
  19167. * Creates a new instance PostProcess
  19168. * @param scene The scene that the post process is associated with.
  19169. */
  19170. constructor(scene: Scene);
  19171. private _prepareBuffers;
  19172. private _buildIndexBuffer;
  19173. /**
  19174. * Rebuilds the vertex buffers of the manager.
  19175. * @hidden
  19176. */
  19177. _rebuild(): void;
  19178. /**
  19179. * Prepares a frame to be run through a post process.
  19180. * @param sourceTexture The input texture to the post procesess. (default: null)
  19181. * @param postProcesses An array of post processes to be run. (default: null)
  19182. * @returns True if the post processes were able to be run.
  19183. * @hidden
  19184. */
  19185. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  19186. /**
  19187. * Manually render a set of post processes to a texture.
  19188. * @param postProcesses An array of post processes to be run.
  19189. * @param targetTexture The target texture to render to.
  19190. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  19191. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  19192. * @param lodLevel defines which lod of the texture to render to
  19193. */
  19194. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  19195. /**
  19196. * Finalize the result of the output of the postprocesses.
  19197. * @param doNotPresent If true the result will not be displayed to the screen.
  19198. * @param targetTexture The target texture to render to.
  19199. * @param faceIndex The index of the face to bind the target texture to.
  19200. * @param postProcesses The array of post processes to render.
  19201. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  19202. * @hidden
  19203. */
  19204. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  19205. /**
  19206. * Disposes of the post process manager.
  19207. */
  19208. dispose(): void;
  19209. }
  19210. }
  19211. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  19212. import { Scene } from "babylonjs/scene";
  19213. import { ISceneComponent } from "babylonjs/sceneComponent";
  19214. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  19215. module "babylonjs/abstractScene" {
  19216. interface AbstractScene {
  19217. /**
  19218. * The list of procedural textures added to the scene
  19219. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19220. */
  19221. proceduralTextures: Array<ProceduralTexture>;
  19222. }
  19223. }
  19224. /**
  19225. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  19226. * in a given scene.
  19227. */
  19228. export class ProceduralTextureSceneComponent implements ISceneComponent {
  19229. /**
  19230. * The component name helpfull to identify the component in the list of scene components.
  19231. */
  19232. readonly name: string;
  19233. /**
  19234. * The scene the component belongs to.
  19235. */
  19236. scene: Scene;
  19237. /**
  19238. * Creates a new instance of the component for the given scene
  19239. * @param scene Defines the scene to register the component in
  19240. */
  19241. constructor(scene: Scene);
  19242. /**
  19243. * Registers the component in a given scene
  19244. */
  19245. register(): void;
  19246. /**
  19247. * Rebuilds the elements related to this component in case of
  19248. * context lost for instance.
  19249. */
  19250. rebuild(): void;
  19251. /**
  19252. * Disposes the component and the associated ressources.
  19253. */
  19254. dispose(): void;
  19255. private _beforeClear;
  19256. }
  19257. }
  19258. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  19259. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19260. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  19261. module "babylonjs/Engines/engine" {
  19262. interface Engine {
  19263. /**
  19264. * Creates a new render target cube texture
  19265. * @param size defines the size of the texture
  19266. * @param options defines the options used to create the texture
  19267. * @returns a new render target cube texture stored in an InternalTexture
  19268. */
  19269. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  19270. }
  19271. }
  19272. }
  19273. declare module "babylonjs/Shaders/procedural.vertex" {
  19274. /** @hidden */
  19275. export var proceduralVertexShader: {
  19276. name: string;
  19277. shader: string;
  19278. };
  19279. }
  19280. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  19281. import { Observable } from "babylonjs/Misc/observable";
  19282. import { Nullable } from "babylonjs/types";
  19283. import { Scene } from "babylonjs/scene";
  19284. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  19285. import { Effect } from "babylonjs/Materials/effect";
  19286. import { Texture } from "babylonjs/Materials/Textures/texture";
  19287. import "babylonjs/Engines/Extensions/engine.renderTarget";
  19288. import "babylonjs/Shaders/procedural.vertex";
  19289. /**
  19290. * 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.
  19291. * This is the base class of any Procedural texture and contains most of the shareable code.
  19292. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19293. */
  19294. export class ProceduralTexture extends Texture {
  19295. isCube: boolean;
  19296. /**
  19297. * Define if the texture is enabled or not (disabled texture will not render)
  19298. */
  19299. isEnabled: boolean;
  19300. /**
  19301. * Define if the texture must be cleared before rendering (default is true)
  19302. */
  19303. autoClear: boolean;
  19304. /**
  19305. * Callback called when the texture is generated
  19306. */
  19307. onGenerated: () => void;
  19308. /**
  19309. * Event raised when the texture is generated
  19310. */
  19311. onGeneratedObservable: Observable<ProceduralTexture>;
  19312. /** @hidden */
  19313. _generateMipMaps: boolean;
  19314. /** @hidden **/
  19315. _effect: Effect;
  19316. /** @hidden */
  19317. _textures: {
  19318. [key: string]: Texture;
  19319. };
  19320. private _size;
  19321. private _currentRefreshId;
  19322. private _refreshRate;
  19323. private _vertexBuffers;
  19324. private _indexBuffer;
  19325. private _uniforms;
  19326. private _samplers;
  19327. private _fragment;
  19328. private _floats;
  19329. private _ints;
  19330. private _floatsArrays;
  19331. private _colors3;
  19332. private _colors4;
  19333. private _vectors2;
  19334. private _vectors3;
  19335. private _matrices;
  19336. private _fallbackTexture;
  19337. private _fallbackTextureUsed;
  19338. private _engine;
  19339. private _cachedDefines;
  19340. private _contentUpdateId;
  19341. private _contentData;
  19342. /**
  19343. * Instantiates a new procedural texture.
  19344. * 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.
  19345. * This is the base class of any Procedural texture and contains most of the shareable code.
  19346. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  19347. * @param name Define the name of the texture
  19348. * @param size Define the size of the texture to create
  19349. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  19350. * @param scene Define the scene the texture belongs to
  19351. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  19352. * @param generateMipMaps Define if the texture should creates mip maps or not
  19353. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  19354. */
  19355. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  19356. /**
  19357. * The effect that is created when initializing the post process.
  19358. * @returns The created effect corresponding the the postprocess.
  19359. */
  19360. getEffect(): Effect;
  19361. /**
  19362. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  19363. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  19364. */
  19365. getContent(): Nullable<ArrayBufferView>;
  19366. private _createIndexBuffer;
  19367. /** @hidden */
  19368. _rebuild(): void;
  19369. /**
  19370. * Resets the texture in order to recreate its associated resources.
  19371. * This can be called in case of context loss
  19372. */
  19373. reset(): void;
  19374. protected _getDefines(): string;
  19375. /**
  19376. * Is the texture ready to be used ? (rendered at least once)
  19377. * @returns true if ready, otherwise, false.
  19378. */
  19379. isReady(): boolean;
  19380. /**
  19381. * Resets the refresh counter of the texture and start bak from scratch.
  19382. * Could be useful to regenerate the texture if it is setup to render only once.
  19383. */
  19384. resetRefreshCounter(): void;
  19385. /**
  19386. * Set the fragment shader to use in order to render the texture.
  19387. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  19388. */
  19389. setFragment(fragment: any): void;
  19390. /**
  19391. * Define the refresh rate of the texture or the rendering frequency.
  19392. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19393. */
  19394. refreshRate: number;
  19395. /** @hidden */
  19396. _shouldRender(): boolean;
  19397. /**
  19398. * Get the size the texture is rendering at.
  19399. * @returns the size (texture is always squared)
  19400. */
  19401. getRenderSize(): number;
  19402. /**
  19403. * Resize the texture to new value.
  19404. * @param size Define the new size the texture should have
  19405. * @param generateMipMaps Define whether the new texture should create mip maps
  19406. */
  19407. resize(size: number, generateMipMaps: boolean): void;
  19408. private _checkUniform;
  19409. /**
  19410. * Set a texture in the shader program used to render.
  19411. * @param name Define the name of the uniform samplers as defined in the shader
  19412. * @param texture Define the texture to bind to this sampler
  19413. * @return the texture itself allowing "fluent" like uniform updates
  19414. */
  19415. setTexture(name: string, texture: Texture): ProceduralTexture;
  19416. /**
  19417. * Set a float in the shader.
  19418. * @param name Define the name of the uniform as defined in the shader
  19419. * @param value Define the value to give to the uniform
  19420. * @return the texture itself allowing "fluent" like uniform updates
  19421. */
  19422. setFloat(name: string, value: number): ProceduralTexture;
  19423. /**
  19424. * Set a int in the shader.
  19425. * @param name Define the name of the uniform as defined in the shader
  19426. * @param value Define the value to give to the uniform
  19427. * @return the texture itself allowing "fluent" like uniform updates
  19428. */
  19429. setInt(name: string, value: number): ProceduralTexture;
  19430. /**
  19431. * Set an array of floats in the shader.
  19432. * @param name Define the name of the uniform as defined in the shader
  19433. * @param value Define the value to give to the uniform
  19434. * @return the texture itself allowing "fluent" like uniform updates
  19435. */
  19436. setFloats(name: string, value: number[]): ProceduralTexture;
  19437. /**
  19438. * Set a vec3 in the shader from a Color3.
  19439. * @param name Define the name of the uniform as defined in the shader
  19440. * @param value Define the value to give to the uniform
  19441. * @return the texture itself allowing "fluent" like uniform updates
  19442. */
  19443. setColor3(name: string, value: Color3): ProceduralTexture;
  19444. /**
  19445. * Set a vec4 in the shader from a Color4.
  19446. * @param name Define the name of the uniform as defined in the shader
  19447. * @param value Define the value to give to the uniform
  19448. * @return the texture itself allowing "fluent" like uniform updates
  19449. */
  19450. setColor4(name: string, value: Color4): ProceduralTexture;
  19451. /**
  19452. * Set a vec2 in the shader from a Vector2.
  19453. * @param name Define the name of the uniform as defined in the shader
  19454. * @param value Define the value to give to the uniform
  19455. * @return the texture itself allowing "fluent" like uniform updates
  19456. */
  19457. setVector2(name: string, value: Vector2): ProceduralTexture;
  19458. /**
  19459. * Set a vec3 in the shader from a Vector3.
  19460. * @param name Define the name of the uniform as defined in the shader
  19461. * @param value Define the value to give to the uniform
  19462. * @return the texture itself allowing "fluent" like uniform updates
  19463. */
  19464. setVector3(name: string, value: Vector3): ProceduralTexture;
  19465. /**
  19466. * Set a mat4 in the shader from a MAtrix.
  19467. * @param name Define the name of the uniform as defined in the shader
  19468. * @param value Define the value to give to the uniform
  19469. * @return the texture itself allowing "fluent" like uniform updates
  19470. */
  19471. setMatrix(name: string, value: Matrix): ProceduralTexture;
  19472. /**
  19473. * Render the texture to its associated render target.
  19474. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  19475. */
  19476. render(useCameraPostProcess?: boolean): void;
  19477. /**
  19478. * Clone the texture.
  19479. * @returns the cloned texture
  19480. */
  19481. clone(): ProceduralTexture;
  19482. /**
  19483. * Dispose the texture and release its asoociated resources.
  19484. */
  19485. dispose(): void;
  19486. }
  19487. }
  19488. declare module "babylonjs/Particles/baseParticleSystem" {
  19489. import { Nullable } from "babylonjs/types";
  19490. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  19491. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19492. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  19493. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  19494. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19495. import { Scene } from "babylonjs/scene";
  19496. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  19497. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  19498. import { Texture } from "babylonjs/Materials/Textures/texture";
  19499. import { Animation } from "babylonjs/Animations/animation";
  19500. /**
  19501. * This represents the base class for particle system in Babylon.
  19502. * 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.
  19503. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  19504. * @example https://doc.babylonjs.com/babylon101/particles
  19505. */
  19506. export class BaseParticleSystem {
  19507. /**
  19508. * Source color is added to the destination color without alpha affecting the result
  19509. */
  19510. static BLENDMODE_ONEONE: number;
  19511. /**
  19512. * Blend current color and particle color using particle’s alpha
  19513. */
  19514. static BLENDMODE_STANDARD: number;
  19515. /**
  19516. * Add current color and particle color multiplied by particle’s alpha
  19517. */
  19518. static BLENDMODE_ADD: number;
  19519. /**
  19520. * Multiply current color with particle color
  19521. */
  19522. static BLENDMODE_MULTIPLY: number;
  19523. /**
  19524. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  19525. */
  19526. static BLENDMODE_MULTIPLYADD: number;
  19527. /**
  19528. * List of animations used by the particle system.
  19529. */
  19530. animations: Animation[];
  19531. /**
  19532. * The id of the Particle system.
  19533. */
  19534. id: string;
  19535. /**
  19536. * The friendly name of the Particle system.
  19537. */
  19538. name: string;
  19539. /**
  19540. * The rendering group used by the Particle system to chose when to render.
  19541. */
  19542. renderingGroupId: number;
  19543. /**
  19544. * The emitter represents the Mesh or position we are attaching the particle system to.
  19545. */
  19546. emitter: Nullable<AbstractMesh | Vector3>;
  19547. /**
  19548. * The maximum number of particles to emit per frame
  19549. */
  19550. emitRate: number;
  19551. /**
  19552. * If you want to launch only a few particles at once, that can be done, as well.
  19553. */
  19554. manualEmitCount: number;
  19555. /**
  19556. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  19557. */
  19558. updateSpeed: number;
  19559. /**
  19560. * The amount of time the particle system is running (depends of the overall update speed).
  19561. */
  19562. targetStopDuration: number;
  19563. /**
  19564. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19565. */
  19566. disposeOnStop: boolean;
  19567. /**
  19568. * Minimum power of emitting particles.
  19569. */
  19570. minEmitPower: number;
  19571. /**
  19572. * Maximum power of emitting particles.
  19573. */
  19574. maxEmitPower: number;
  19575. /**
  19576. * Minimum life time of emitting particles.
  19577. */
  19578. minLifeTime: number;
  19579. /**
  19580. * Maximum life time of emitting particles.
  19581. */
  19582. maxLifeTime: number;
  19583. /**
  19584. * Minimum Size of emitting particles.
  19585. */
  19586. minSize: number;
  19587. /**
  19588. * Maximum Size of emitting particles.
  19589. */
  19590. maxSize: number;
  19591. /**
  19592. * Minimum scale of emitting particles on X axis.
  19593. */
  19594. minScaleX: number;
  19595. /**
  19596. * Maximum scale of emitting particles on X axis.
  19597. */
  19598. maxScaleX: number;
  19599. /**
  19600. * Minimum scale of emitting particles on Y axis.
  19601. */
  19602. minScaleY: number;
  19603. /**
  19604. * Maximum scale of emitting particles on Y axis.
  19605. */
  19606. maxScaleY: number;
  19607. /**
  19608. * Gets or sets the minimal initial rotation in radians.
  19609. */
  19610. minInitialRotation: number;
  19611. /**
  19612. * Gets or sets the maximal initial rotation in radians.
  19613. */
  19614. maxInitialRotation: number;
  19615. /**
  19616. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  19617. */
  19618. minAngularSpeed: number;
  19619. /**
  19620. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  19621. */
  19622. maxAngularSpeed: number;
  19623. /**
  19624. * The texture used to render each particle. (this can be a spritesheet)
  19625. */
  19626. particleTexture: Nullable<Texture>;
  19627. /**
  19628. * The layer mask we are rendering the particles through.
  19629. */
  19630. layerMask: number;
  19631. /**
  19632. * This can help using your own shader to render the particle system.
  19633. * The according effect will be created
  19634. */
  19635. customShader: any;
  19636. /**
  19637. * By default particle system starts as soon as they are created. This prevents the
  19638. * automatic start to happen and let you decide when to start emitting particles.
  19639. */
  19640. preventAutoStart: boolean;
  19641. private _noiseTexture;
  19642. /**
  19643. * Gets or sets a texture used to add random noise to particle positions
  19644. */
  19645. noiseTexture: Nullable<ProceduralTexture>;
  19646. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19647. noiseStrength: Vector3;
  19648. /**
  19649. * Callback triggered when the particle animation is ending.
  19650. */
  19651. onAnimationEnd: Nullable<() => void>;
  19652. /**
  19653. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  19654. */
  19655. blendMode: number;
  19656. /**
  19657. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  19658. * to override the particles.
  19659. */
  19660. forceDepthWrite: boolean;
  19661. /** 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 */
  19662. preWarmCycles: number;
  19663. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  19664. preWarmStepOffset: number;
  19665. /**
  19666. * 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)
  19667. */
  19668. spriteCellChangeSpeed: number;
  19669. /**
  19670. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  19671. */
  19672. startSpriteCellID: number;
  19673. /**
  19674. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  19675. */
  19676. endSpriteCellID: number;
  19677. /**
  19678. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  19679. */
  19680. spriteCellWidth: number;
  19681. /**
  19682. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  19683. */
  19684. spriteCellHeight: number;
  19685. /**
  19686. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  19687. */
  19688. spriteRandomStartCell: boolean;
  19689. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  19690. translationPivot: Vector2;
  19691. /** @hidden */
  19692. protected _isAnimationSheetEnabled: boolean;
  19693. /**
  19694. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19695. */
  19696. beginAnimationOnStart: boolean;
  19697. /**
  19698. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19699. */
  19700. beginAnimationFrom: number;
  19701. /**
  19702. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19703. */
  19704. beginAnimationTo: number;
  19705. /**
  19706. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19707. */
  19708. beginAnimationLoop: boolean;
  19709. /**
  19710. * Gets or sets a world offset applied to all particles
  19711. */
  19712. worldOffset: Vector3;
  19713. /**
  19714. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  19715. */
  19716. isAnimationSheetEnabled: boolean;
  19717. /**
  19718. * Get hosting scene
  19719. * @returns the scene
  19720. */
  19721. getScene(): Scene;
  19722. /**
  19723. * You can use gravity if you want to give an orientation to your particles.
  19724. */
  19725. gravity: Vector3;
  19726. protected _colorGradients: Nullable<Array<ColorGradient>>;
  19727. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  19728. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  19729. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  19730. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  19731. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  19732. protected _dragGradients: Nullable<Array<FactorGradient>>;
  19733. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  19734. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  19735. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  19736. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  19737. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  19738. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  19739. /**
  19740. * Defines the delay in milliseconds before starting the system (0 by default)
  19741. */
  19742. startDelay: number;
  19743. /**
  19744. * Gets the current list of drag gradients.
  19745. * You must use addDragGradient and removeDragGradient to udpate this list
  19746. * @returns the list of drag gradients
  19747. */
  19748. getDragGradients(): Nullable<Array<FactorGradient>>;
  19749. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19750. limitVelocityDamping: number;
  19751. /**
  19752. * Gets the current list of limit velocity gradients.
  19753. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19754. * @returns the list of limit velocity gradients
  19755. */
  19756. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19757. /**
  19758. * Gets the current list of color gradients.
  19759. * You must use addColorGradient and removeColorGradient to udpate this list
  19760. * @returns the list of color gradients
  19761. */
  19762. getColorGradients(): Nullable<Array<ColorGradient>>;
  19763. /**
  19764. * Gets the current list of size gradients.
  19765. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19766. * @returns the list of size gradients
  19767. */
  19768. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19769. /**
  19770. * Gets the current list of color remap gradients.
  19771. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19772. * @returns the list of color remap gradients
  19773. */
  19774. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19775. /**
  19776. * Gets the current list of alpha remap gradients.
  19777. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19778. * @returns the list of alpha remap gradients
  19779. */
  19780. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19781. /**
  19782. * Gets the current list of life time gradients.
  19783. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19784. * @returns the list of life time gradients
  19785. */
  19786. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19787. /**
  19788. * Gets the current list of angular speed gradients.
  19789. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19790. * @returns the list of angular speed gradients
  19791. */
  19792. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19793. /**
  19794. * Gets the current list of velocity gradients.
  19795. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19796. * @returns the list of velocity gradients
  19797. */
  19798. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19799. /**
  19800. * Gets the current list of start size gradients.
  19801. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19802. * @returns the list of start size gradients
  19803. */
  19804. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19805. /**
  19806. * Gets the current list of emit rate gradients.
  19807. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19808. * @returns the list of emit rate gradients
  19809. */
  19810. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19811. /**
  19812. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19813. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19814. */
  19815. direction1: Vector3;
  19816. /**
  19817. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  19818. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19819. */
  19820. direction2: Vector3;
  19821. /**
  19822. * 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.
  19823. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19824. */
  19825. minEmitBox: Vector3;
  19826. /**
  19827. * 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.
  19828. * This only works when particleEmitterTyps is a BoxParticleEmitter
  19829. */
  19830. maxEmitBox: Vector3;
  19831. /**
  19832. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19833. */
  19834. color1: Color4;
  19835. /**
  19836. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  19837. */
  19838. color2: Color4;
  19839. /**
  19840. * Color the particle will have at the end of its lifetime
  19841. */
  19842. colorDead: Color4;
  19843. /**
  19844. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  19845. */
  19846. textureMask: Color4;
  19847. /**
  19848. * The particle emitter type defines the emitter used by the particle system.
  19849. * It can be for example box, sphere, or cone...
  19850. */
  19851. particleEmitterType: IParticleEmitterType;
  19852. /** @hidden */
  19853. _isSubEmitter: boolean;
  19854. /**
  19855. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19856. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19857. */
  19858. billboardMode: number;
  19859. protected _isBillboardBased: boolean;
  19860. /**
  19861. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  19862. */
  19863. isBillboardBased: boolean;
  19864. /**
  19865. * The scene the particle system belongs to.
  19866. */
  19867. protected _scene: Scene;
  19868. /**
  19869. * Local cache of defines for image processing.
  19870. */
  19871. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  19872. /**
  19873. * Default configuration related to image processing available in the standard Material.
  19874. */
  19875. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19876. /**
  19877. * Gets the image processing configuration used either in this material.
  19878. */
  19879. /**
  19880. * Sets the Default image processing configuration used either in the this material.
  19881. *
  19882. * If sets to null, the scene one is in use.
  19883. */
  19884. imageProcessingConfiguration: ImageProcessingConfiguration;
  19885. /**
  19886. * Attaches a new image processing configuration to the Standard Material.
  19887. * @param configuration
  19888. */
  19889. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19890. /** @hidden */
  19891. protected _reset(): void;
  19892. /** @hidden */
  19893. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  19894. /**
  19895. * Instantiates a particle system.
  19896. * 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.
  19897. * @param name The name of the particle system
  19898. */
  19899. constructor(name: string);
  19900. /**
  19901. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19902. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19903. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19904. * @returns the emitter
  19905. */
  19906. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19907. /**
  19908. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19909. * @param radius The radius of the hemisphere to emit from
  19910. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19911. * @returns the emitter
  19912. */
  19913. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  19914. /**
  19915. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19916. * @param radius The radius of the sphere to emit from
  19917. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19918. * @returns the emitter
  19919. */
  19920. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  19921. /**
  19922. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19923. * @param radius The radius of the sphere to emit from
  19924. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19925. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19926. * @returns the emitter
  19927. */
  19928. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  19929. /**
  19930. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19931. * @param radius The radius of the emission cylinder
  19932. * @param height The height of the emission cylinder
  19933. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19934. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19935. * @returns the emitter
  19936. */
  19937. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  19938. /**
  19939. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19940. * @param radius The radius of the cylinder to emit from
  19941. * @param height The height of the emission cylinder
  19942. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19943. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19944. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19945. * @returns the emitter
  19946. */
  19947. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  19948. /**
  19949. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19950. * @param radius The radius of the cone to emit from
  19951. * @param angle The base angle of the cone
  19952. * @returns the emitter
  19953. */
  19954. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  19955. /**
  19956. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19957. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19958. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19959. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19960. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19961. * @returns the emitter
  19962. */
  19963. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19964. }
  19965. }
  19966. declare module "babylonjs/Particles/subEmitter" {
  19967. import { Scene } from "babylonjs/scene";
  19968. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  19969. /**
  19970. * Type of sub emitter
  19971. */
  19972. export enum SubEmitterType {
  19973. /**
  19974. * Attached to the particle over it's lifetime
  19975. */
  19976. ATTACHED = 0,
  19977. /**
  19978. * Created when the particle dies
  19979. */
  19980. END = 1
  19981. }
  19982. /**
  19983. * Sub emitter class used to emit particles from an existing particle
  19984. */
  19985. export class SubEmitter {
  19986. /**
  19987. * the particle system to be used by the sub emitter
  19988. */
  19989. particleSystem: ParticleSystem;
  19990. /**
  19991. * Type of the submitter (Default: END)
  19992. */
  19993. type: SubEmitterType;
  19994. /**
  19995. * 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)
  19996. * Note: This only is supported when using an emitter of type Mesh
  19997. */
  19998. inheritDirection: boolean;
  19999. /**
  20000. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  20001. */
  20002. inheritedVelocityAmount: number;
  20003. /**
  20004. * Creates a sub emitter
  20005. * @param particleSystem the particle system to be used by the sub emitter
  20006. */
  20007. constructor(
  20008. /**
  20009. * the particle system to be used by the sub emitter
  20010. */
  20011. particleSystem: ParticleSystem);
  20012. /**
  20013. * Clones the sub emitter
  20014. * @returns the cloned sub emitter
  20015. */
  20016. clone(): SubEmitter;
  20017. /**
  20018. * Serialize current object to a JSON object
  20019. * @returns the serialized object
  20020. */
  20021. serialize(): any;
  20022. /** @hidden */
  20023. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  20024. /**
  20025. * Creates a new SubEmitter from a serialized JSON version
  20026. * @param serializationObject defines the JSON object to read from
  20027. * @param scene defines the hosting scene
  20028. * @param rootUrl defines the rootUrl for data loading
  20029. * @returns a new SubEmitter
  20030. */
  20031. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  20032. /** Release associated resources */
  20033. dispose(): void;
  20034. }
  20035. }
  20036. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  20037. /** @hidden */
  20038. export var imageProcessingDeclaration: {
  20039. name: string;
  20040. shader: string;
  20041. };
  20042. }
  20043. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  20044. /** @hidden */
  20045. export var imageProcessingFunctions: {
  20046. name: string;
  20047. shader: string;
  20048. };
  20049. }
  20050. declare module "babylonjs/Shaders/particles.fragment" {
  20051. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  20052. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  20053. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  20054. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  20055. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  20056. /** @hidden */
  20057. export var particlesPixelShader: {
  20058. name: string;
  20059. shader: string;
  20060. };
  20061. }
  20062. declare module "babylonjs/Shaders/particles.vertex" {
  20063. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  20064. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  20065. /** @hidden */
  20066. export var particlesVertexShader: {
  20067. name: string;
  20068. shader: string;
  20069. };
  20070. }
  20071. declare module "babylonjs/Particles/particleSystem" {
  20072. import { Nullable } from "babylonjs/types";
  20073. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  20074. import { Observable } from "babylonjs/Misc/observable";
  20075. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  20076. import { Effect } from "babylonjs/Materials/effect";
  20077. import { Scene, IDisposable } from "babylonjs/scene";
  20078. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20079. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  20080. import { Particle } from "babylonjs/Particles/particle";
  20081. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  20082. import "babylonjs/Shaders/particles.fragment";
  20083. import "babylonjs/Shaders/particles.vertex";
  20084. /**
  20085. * This represents a particle system in Babylon.
  20086. * 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.
  20087. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  20088. * @example https://doc.babylonjs.com/babylon101/particles
  20089. */
  20090. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  20091. /**
  20092. * Billboard mode will only apply to Y axis
  20093. */
  20094. static readonly BILLBOARDMODE_Y: number;
  20095. /**
  20096. * Billboard mode will apply to all axes
  20097. */
  20098. static readonly BILLBOARDMODE_ALL: number;
  20099. /**
  20100. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  20101. */
  20102. static readonly BILLBOARDMODE_STRETCHED: number;
  20103. /**
  20104. * This function can be defined to provide custom update for active particles.
  20105. * This function will be called instead of regular update (age, position, color, etc.).
  20106. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  20107. */
  20108. updateFunction: (particles: Particle[]) => void;
  20109. private _emitterWorldMatrix;
  20110. /**
  20111. * This function can be defined to specify initial direction for every new particle.
  20112. * It by default use the emitterType defined function
  20113. */
  20114. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  20115. /**
  20116. * This function can be defined to specify initial position for every new particle.
  20117. * It by default use the emitterType defined function
  20118. */
  20119. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  20120. /**
  20121. * @hidden
  20122. */
  20123. _inheritedVelocityOffset: Vector3;
  20124. /**
  20125. * An event triggered when the system is disposed
  20126. */
  20127. onDisposeObservable: Observable<ParticleSystem>;
  20128. private _onDisposeObserver;
  20129. /**
  20130. * Sets a callback that will be triggered when the system is disposed
  20131. */
  20132. onDispose: () => void;
  20133. private _particles;
  20134. private _epsilon;
  20135. private _capacity;
  20136. private _stockParticles;
  20137. private _newPartsExcess;
  20138. private _vertexData;
  20139. private _vertexBuffer;
  20140. private _vertexBuffers;
  20141. private _spriteBuffer;
  20142. private _indexBuffer;
  20143. private _effect;
  20144. private _customEffect;
  20145. private _cachedDefines;
  20146. private _scaledColorStep;
  20147. private _colorDiff;
  20148. private _scaledDirection;
  20149. private _scaledGravity;
  20150. private _currentRenderId;
  20151. private _alive;
  20152. private _useInstancing;
  20153. private _started;
  20154. private _stopped;
  20155. private _actualFrame;
  20156. private _scaledUpdateSpeed;
  20157. private _vertexBufferSize;
  20158. /** @hidden */
  20159. _currentEmitRateGradient: Nullable<FactorGradient>;
  20160. /** @hidden */
  20161. _currentEmitRate1: number;
  20162. /** @hidden */
  20163. _currentEmitRate2: number;
  20164. /** @hidden */
  20165. _currentStartSizeGradient: Nullable<FactorGradient>;
  20166. /** @hidden */
  20167. _currentStartSize1: number;
  20168. /** @hidden */
  20169. _currentStartSize2: number;
  20170. private readonly _rawTextureWidth;
  20171. private _rampGradientsTexture;
  20172. private _useRampGradients;
  20173. /** Gets or sets a boolean indicating that ramp gradients must be used
  20174. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  20175. */
  20176. useRampGradients: boolean;
  20177. /**
  20178. * 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.
  20179. * 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: [])
  20180. */
  20181. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  20182. private _subEmitters;
  20183. /**
  20184. * @hidden
  20185. * If the particle systems emitter should be disposed when the particle system is disposed
  20186. */
  20187. _disposeEmitterOnDispose: boolean;
  20188. /**
  20189. * The current active Sub-systems, this property is used by the root particle system only.
  20190. */
  20191. activeSubSystems: Array<ParticleSystem>;
  20192. private _rootParticleSystem;
  20193. /**
  20194. * Gets the current list of active particles
  20195. */
  20196. readonly particles: Particle[];
  20197. /**
  20198. * Returns the string "ParticleSystem"
  20199. * @returns a string containing the class name
  20200. */
  20201. getClassName(): string;
  20202. /**
  20203. * Instantiates a particle system.
  20204. * 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.
  20205. * @param name The name of the particle system
  20206. * @param capacity The max number of particles alive at the same time
  20207. * @param scene The scene the particle system belongs to
  20208. * @param customEffect a custom effect used to change the way particles are rendered by default
  20209. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  20210. * @param epsilon Offset used to render the particles
  20211. */
  20212. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  20213. private _addFactorGradient;
  20214. private _removeFactorGradient;
  20215. /**
  20216. * Adds a new life time gradient
  20217. * @param gradient defines the gradient to use (between 0 and 1)
  20218. * @param factor defines the life time factor to affect to the specified gradient
  20219. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20220. * @returns the current particle system
  20221. */
  20222. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20223. /**
  20224. * Remove a specific life time gradient
  20225. * @param gradient defines the gradient to remove
  20226. * @returns the current particle system
  20227. */
  20228. removeLifeTimeGradient(gradient: number): IParticleSystem;
  20229. /**
  20230. * Adds a new size gradient
  20231. * @param gradient defines the gradient to use (between 0 and 1)
  20232. * @param factor defines the size factor to affect to the specified gradient
  20233. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20234. * @returns the current particle system
  20235. */
  20236. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20237. /**
  20238. * Remove a specific size gradient
  20239. * @param gradient defines the gradient to remove
  20240. * @returns the current particle system
  20241. */
  20242. removeSizeGradient(gradient: number): IParticleSystem;
  20243. /**
  20244. * Adds a new color remap gradient
  20245. * @param gradient defines the gradient to use (between 0 and 1)
  20246. * @param min defines the color remap minimal range
  20247. * @param max defines the color remap maximal range
  20248. * @returns the current particle system
  20249. */
  20250. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  20251. /**
  20252. * Remove a specific color remap gradient
  20253. * @param gradient defines the gradient to remove
  20254. * @returns the current particle system
  20255. */
  20256. removeColorRemapGradient(gradient: number): IParticleSystem;
  20257. /**
  20258. * Adds a new alpha remap gradient
  20259. * @param gradient defines the gradient to use (between 0 and 1)
  20260. * @param min defines the alpha remap minimal range
  20261. * @param max defines the alpha remap maximal range
  20262. * @returns the current particle system
  20263. */
  20264. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  20265. /**
  20266. * Remove a specific alpha remap gradient
  20267. * @param gradient defines the gradient to remove
  20268. * @returns the current particle system
  20269. */
  20270. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  20271. /**
  20272. * Adds a new angular speed gradient
  20273. * @param gradient defines the gradient to use (between 0 and 1)
  20274. * @param factor defines the angular speed to affect to the specified gradient
  20275. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20276. * @returns the current particle system
  20277. */
  20278. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20279. /**
  20280. * Remove a specific angular speed gradient
  20281. * @param gradient defines the gradient to remove
  20282. * @returns the current particle system
  20283. */
  20284. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  20285. /**
  20286. * Adds a new velocity gradient
  20287. * @param gradient defines the gradient to use (between 0 and 1)
  20288. * @param factor defines the velocity to affect to the specified gradient
  20289. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20290. * @returns the current particle system
  20291. */
  20292. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20293. /**
  20294. * Remove a specific velocity gradient
  20295. * @param gradient defines the gradient to remove
  20296. * @returns the current particle system
  20297. */
  20298. removeVelocityGradient(gradient: number): IParticleSystem;
  20299. /**
  20300. * Adds a new limit velocity gradient
  20301. * @param gradient defines the gradient to use (between 0 and 1)
  20302. * @param factor defines the limit velocity value to affect to the specified gradient
  20303. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20304. * @returns the current particle system
  20305. */
  20306. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20307. /**
  20308. * Remove a specific limit velocity gradient
  20309. * @param gradient defines the gradient to remove
  20310. * @returns the current particle system
  20311. */
  20312. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  20313. /**
  20314. * Adds a new drag gradient
  20315. * @param gradient defines the gradient to use (between 0 and 1)
  20316. * @param factor defines the drag value to affect to the specified gradient
  20317. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20318. * @returns the current particle system
  20319. */
  20320. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20321. /**
  20322. * Remove a specific drag gradient
  20323. * @param gradient defines the gradient to remove
  20324. * @returns the current particle system
  20325. */
  20326. removeDragGradient(gradient: number): IParticleSystem;
  20327. /**
  20328. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  20329. * @param gradient defines the gradient to use (between 0 and 1)
  20330. * @param factor defines the emit rate value to affect to the specified gradient
  20331. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20332. * @returns the current particle system
  20333. */
  20334. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20335. /**
  20336. * Remove a specific emit rate gradient
  20337. * @param gradient defines the gradient to remove
  20338. * @returns the current particle system
  20339. */
  20340. removeEmitRateGradient(gradient: number): IParticleSystem;
  20341. /**
  20342. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  20343. * @param gradient defines the gradient to use (between 0 and 1)
  20344. * @param factor defines the start size value to affect to the specified gradient
  20345. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  20346. * @returns the current particle system
  20347. */
  20348. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  20349. /**
  20350. * Remove a specific start size gradient
  20351. * @param gradient defines the gradient to remove
  20352. * @returns the current particle system
  20353. */
  20354. removeStartSizeGradient(gradient: number): IParticleSystem;
  20355. private _createRampGradientTexture;
  20356. /**
  20357. * Gets the current list of ramp gradients.
  20358. * You must use addRampGradient and removeRampGradient to udpate this list
  20359. * @returns the list of ramp gradients
  20360. */
  20361. getRampGradients(): Nullable<Array<Color3Gradient>>;
  20362. /**
  20363. * Adds a new ramp gradient used to remap particle colors
  20364. * @param gradient defines the gradient to use (between 0 and 1)
  20365. * @param color defines the color to affect to the specified gradient
  20366. * @returns the current particle system
  20367. */
  20368. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  20369. /**
  20370. * Remove a specific ramp gradient
  20371. * @param gradient defines the gradient to remove
  20372. * @returns the current particle system
  20373. */
  20374. removeRampGradient(gradient: number): ParticleSystem;
  20375. /**
  20376. * Adds a new color gradient
  20377. * @param gradient defines the gradient to use (between 0 and 1)
  20378. * @param color1 defines the color to affect to the specified gradient
  20379. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  20380. * @returns this particle system
  20381. */
  20382. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  20383. /**
  20384. * Remove a specific color gradient
  20385. * @param gradient defines the gradient to remove
  20386. * @returns this particle system
  20387. */
  20388. removeColorGradient(gradient: number): IParticleSystem;
  20389. private _fetchR;
  20390. protected _reset(): void;
  20391. private _resetEffect;
  20392. private _createVertexBuffers;
  20393. private _createIndexBuffer;
  20394. /**
  20395. * Gets the maximum number of particles active at the same time.
  20396. * @returns The max number of active particles.
  20397. */
  20398. getCapacity(): number;
  20399. /**
  20400. * Gets whether there are still active particles in the system.
  20401. * @returns True if it is alive, otherwise false.
  20402. */
  20403. isAlive(): boolean;
  20404. /**
  20405. * Gets if the system has been started. (Note: this will still be true after stop is called)
  20406. * @returns True if it has been started, otherwise false.
  20407. */
  20408. isStarted(): boolean;
  20409. private _prepareSubEmitterInternalArray;
  20410. /**
  20411. * Starts the particle system and begins to emit
  20412. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  20413. */
  20414. start(delay?: number): void;
  20415. /**
  20416. * Stops the particle system.
  20417. * @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.
  20418. */
  20419. stop(stopSubEmitters?: boolean): void;
  20420. /**
  20421. * Remove all active particles
  20422. */
  20423. reset(): void;
  20424. /**
  20425. * @hidden (for internal use only)
  20426. */
  20427. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  20428. /**
  20429. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  20430. * Its lifetime will start back at 0.
  20431. */
  20432. recycleParticle: (particle: Particle) => void;
  20433. private _stopSubEmitters;
  20434. private _createParticle;
  20435. private _removeFromRoot;
  20436. private _emitFromParticle;
  20437. private _update;
  20438. /** @hidden */
  20439. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  20440. /** @hidden */
  20441. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  20442. /** @hidden */
  20443. private _getEffect;
  20444. /**
  20445. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  20446. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  20447. */
  20448. animate(preWarmOnly?: boolean): void;
  20449. private _appendParticleVertices;
  20450. /**
  20451. * Rebuilds the particle system.
  20452. */
  20453. rebuild(): void;
  20454. /**
  20455. * Is this system ready to be used/rendered
  20456. * @return true if the system is ready
  20457. */
  20458. isReady(): boolean;
  20459. private _render;
  20460. /**
  20461. * Renders the particle system in its current state.
  20462. * @returns the current number of particles
  20463. */
  20464. render(): number;
  20465. /**
  20466. * Disposes the particle system and free the associated resources
  20467. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  20468. */
  20469. dispose(disposeTexture?: boolean): void;
  20470. /**
  20471. * Clones the particle system.
  20472. * @param name The name of the cloned object
  20473. * @param newEmitter The new emitter to use
  20474. * @returns the cloned particle system
  20475. */
  20476. clone(name: string, newEmitter: any): ParticleSystem;
  20477. /**
  20478. * Serializes the particle system to a JSON object.
  20479. * @returns the JSON object
  20480. */
  20481. serialize(): any;
  20482. /** @hidden */
  20483. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  20484. /** @hidden */
  20485. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  20486. /**
  20487. * Parses a JSON object to create a particle system.
  20488. * @param parsedParticleSystem The JSON object to parse
  20489. * @param scene The scene to create the particle system in
  20490. * @param rootUrl The root url to use to load external dependencies like texture
  20491. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  20492. * @returns the Parsed particle system
  20493. */
  20494. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  20495. }
  20496. }
  20497. declare module "babylonjs/Particles/particle" {
  20498. import { Nullable } from "babylonjs/types";
  20499. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  20500. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  20501. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  20502. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  20503. /**
  20504. * A particle represents one of the element emitted by a particle system.
  20505. * This is mainly define by its coordinates, direction, velocity and age.
  20506. */
  20507. export class Particle {
  20508. /**
  20509. * The particle system the particle belongs to.
  20510. */
  20511. particleSystem: ParticleSystem;
  20512. private static _Count;
  20513. /**
  20514. * Unique ID of the particle
  20515. */
  20516. id: number;
  20517. /**
  20518. * The world position of the particle in the scene.
  20519. */
  20520. position: Vector3;
  20521. /**
  20522. * The world direction of the particle in the scene.
  20523. */
  20524. direction: Vector3;
  20525. /**
  20526. * The color of the particle.
  20527. */
  20528. color: Color4;
  20529. /**
  20530. * The color change of the particle per step.
  20531. */
  20532. colorStep: Color4;
  20533. /**
  20534. * Defines how long will the life of the particle be.
  20535. */
  20536. lifeTime: number;
  20537. /**
  20538. * The current age of the particle.
  20539. */
  20540. age: number;
  20541. /**
  20542. * The current size of the particle.
  20543. */
  20544. size: number;
  20545. /**
  20546. * The current scale of the particle.
  20547. */
  20548. scale: Vector2;
  20549. /**
  20550. * The current angle of the particle.
  20551. */
  20552. angle: number;
  20553. /**
  20554. * Defines how fast is the angle changing.
  20555. */
  20556. angularSpeed: number;
  20557. /**
  20558. * Defines the cell index used by the particle to be rendered from a sprite.
  20559. */
  20560. cellIndex: number;
  20561. /**
  20562. * The information required to support color remapping
  20563. */
  20564. remapData: Vector4;
  20565. /** @hidden */
  20566. _randomCellOffset?: number;
  20567. /** @hidden */
  20568. _initialDirection: Nullable<Vector3>;
  20569. /** @hidden */
  20570. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  20571. /** @hidden */
  20572. _initialStartSpriteCellID: number;
  20573. /** @hidden */
  20574. _initialEndSpriteCellID: number;
  20575. /** @hidden */
  20576. _currentColorGradient: Nullable<ColorGradient>;
  20577. /** @hidden */
  20578. _currentColor1: Color4;
  20579. /** @hidden */
  20580. _currentColor2: Color4;
  20581. /** @hidden */
  20582. _currentSizeGradient: Nullable<FactorGradient>;
  20583. /** @hidden */
  20584. _currentSize1: number;
  20585. /** @hidden */
  20586. _currentSize2: number;
  20587. /** @hidden */
  20588. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  20589. /** @hidden */
  20590. _currentAngularSpeed1: number;
  20591. /** @hidden */
  20592. _currentAngularSpeed2: number;
  20593. /** @hidden */
  20594. _currentVelocityGradient: Nullable<FactorGradient>;
  20595. /** @hidden */
  20596. _currentVelocity1: number;
  20597. /** @hidden */
  20598. _currentVelocity2: number;
  20599. /** @hidden */
  20600. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  20601. /** @hidden */
  20602. _currentLimitVelocity1: number;
  20603. /** @hidden */
  20604. _currentLimitVelocity2: number;
  20605. /** @hidden */
  20606. _currentDragGradient: Nullable<FactorGradient>;
  20607. /** @hidden */
  20608. _currentDrag1: number;
  20609. /** @hidden */
  20610. _currentDrag2: number;
  20611. /** @hidden */
  20612. _randomNoiseCoordinates1: Vector3;
  20613. /** @hidden */
  20614. _randomNoiseCoordinates2: Vector3;
  20615. /**
  20616. * Creates a new instance Particle
  20617. * @param particleSystem the particle system the particle belongs to
  20618. */
  20619. constructor(
  20620. /**
  20621. * The particle system the particle belongs to.
  20622. */
  20623. particleSystem: ParticleSystem);
  20624. private updateCellInfoFromSystem;
  20625. /**
  20626. * Defines how the sprite cell index is updated for the particle
  20627. */
  20628. updateCellIndex(): void;
  20629. /** @hidden */
  20630. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  20631. /** @hidden */
  20632. _inheritParticleInfoToSubEmitters(): void;
  20633. /** @hidden */
  20634. _reset(): void;
  20635. /**
  20636. * Copy the properties of particle to another one.
  20637. * @param other the particle to copy the information to.
  20638. */
  20639. copyTo(other: Particle): void;
  20640. }
  20641. }
  20642. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  20643. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20644. import { Effect } from "babylonjs/Materials/effect";
  20645. import { Particle } from "babylonjs/Particles/particle";
  20646. /**
  20647. * Particle emitter represents a volume emitting particles.
  20648. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  20649. */
  20650. export interface IParticleEmitterType {
  20651. /**
  20652. * Called by the particle System when the direction is computed for the created particle.
  20653. * @param worldMatrix is the world matrix of the particle system
  20654. * @param directionToUpdate is the direction vector to update with the result
  20655. * @param particle is the particle we are computed the direction for
  20656. */
  20657. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20658. /**
  20659. * Called by the particle System when the position is computed for the created particle.
  20660. * @param worldMatrix is the world matrix of the particle system
  20661. * @param positionToUpdate is the position vector to update with the result
  20662. * @param particle is the particle we are computed the position for
  20663. */
  20664. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20665. /**
  20666. * Clones the current emitter and returns a copy of it
  20667. * @returns the new emitter
  20668. */
  20669. clone(): IParticleEmitterType;
  20670. /**
  20671. * Called by the GPUParticleSystem to setup the update shader
  20672. * @param effect defines the update shader
  20673. */
  20674. applyToShader(effect: Effect): void;
  20675. /**
  20676. * Returns a string to use to update the GPU particles update shader
  20677. * @returns the effect defines string
  20678. */
  20679. getEffectDefines(): string;
  20680. /**
  20681. * Returns a string representing the class name
  20682. * @returns a string containing the class name
  20683. */
  20684. getClassName(): string;
  20685. /**
  20686. * Serializes the particle system to a JSON object.
  20687. * @returns the JSON object
  20688. */
  20689. serialize(): any;
  20690. /**
  20691. * Parse properties from a JSON object
  20692. * @param serializationObject defines the JSON object
  20693. */
  20694. parse(serializationObject: any): void;
  20695. }
  20696. }
  20697. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  20698. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20699. import { Effect } from "babylonjs/Materials/effect";
  20700. import { Particle } from "babylonjs/Particles/particle";
  20701. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20702. /**
  20703. * Particle emitter emitting particles from the inside of a box.
  20704. * It emits the particles randomly between 2 given directions.
  20705. */
  20706. export class BoxParticleEmitter implements IParticleEmitterType {
  20707. /**
  20708. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20709. */
  20710. direction1: Vector3;
  20711. /**
  20712. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  20713. */
  20714. direction2: Vector3;
  20715. /**
  20716. * 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.
  20717. */
  20718. minEmitBox: Vector3;
  20719. /**
  20720. * 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.
  20721. */
  20722. maxEmitBox: Vector3;
  20723. /**
  20724. * Creates a new instance BoxParticleEmitter
  20725. */
  20726. constructor();
  20727. /**
  20728. * Called by the particle System when the direction is computed for the created particle.
  20729. * @param worldMatrix is the world matrix of the particle system
  20730. * @param directionToUpdate is the direction vector to update with the result
  20731. * @param particle is the particle we are computed the direction for
  20732. */
  20733. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20734. /**
  20735. * Called by the particle System when the position is computed for the created particle.
  20736. * @param worldMatrix is the world matrix of the particle system
  20737. * @param positionToUpdate is the position vector to update with the result
  20738. * @param particle is the particle we are computed the position for
  20739. */
  20740. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20741. /**
  20742. * Clones the current emitter and returns a copy of it
  20743. * @returns the new emitter
  20744. */
  20745. clone(): BoxParticleEmitter;
  20746. /**
  20747. * Called by the GPUParticleSystem to setup the update shader
  20748. * @param effect defines the update shader
  20749. */
  20750. applyToShader(effect: Effect): void;
  20751. /**
  20752. * Returns a string to use to update the GPU particles update shader
  20753. * @returns a string containng the defines string
  20754. */
  20755. getEffectDefines(): string;
  20756. /**
  20757. * Returns the string "BoxParticleEmitter"
  20758. * @returns a string containing the class name
  20759. */
  20760. getClassName(): string;
  20761. /**
  20762. * Serializes the particle system to a JSON object.
  20763. * @returns the JSON object
  20764. */
  20765. serialize(): any;
  20766. /**
  20767. * Parse properties from a JSON object
  20768. * @param serializationObject defines the JSON object
  20769. */
  20770. parse(serializationObject: any): void;
  20771. }
  20772. }
  20773. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  20774. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20775. import { Effect } from "babylonjs/Materials/effect";
  20776. import { Particle } from "babylonjs/Particles/particle";
  20777. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20778. /**
  20779. * Particle emitter emitting particles from the inside of a cone.
  20780. * It emits the particles alongside the cone volume from the base to the particle.
  20781. * The emission direction might be randomized.
  20782. */
  20783. export class ConeParticleEmitter implements IParticleEmitterType {
  20784. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20785. directionRandomizer: number;
  20786. private _radius;
  20787. private _angle;
  20788. private _height;
  20789. /**
  20790. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  20791. */
  20792. radiusRange: number;
  20793. /**
  20794. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  20795. */
  20796. heightRange: number;
  20797. /**
  20798. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  20799. */
  20800. emitFromSpawnPointOnly: boolean;
  20801. /**
  20802. * Gets or sets the radius of the emission cone
  20803. */
  20804. radius: number;
  20805. /**
  20806. * Gets or sets the angle of the emission cone
  20807. */
  20808. angle: number;
  20809. private _buildHeight;
  20810. /**
  20811. * Creates a new instance ConeParticleEmitter
  20812. * @param radius the radius of the emission cone (1 by default)
  20813. * @param angle the cone base angle (PI by default)
  20814. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  20815. */
  20816. constructor(radius?: number, angle?: number,
  20817. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  20818. directionRandomizer?: number);
  20819. /**
  20820. * Called by the particle System when the direction is computed for the created particle.
  20821. * @param worldMatrix is the world matrix of the particle system
  20822. * @param directionToUpdate is the direction vector to update with the result
  20823. * @param particle is the particle we are computed the direction for
  20824. */
  20825. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20826. /**
  20827. * Called by the particle System when the position is computed for the created particle.
  20828. * @param worldMatrix is the world matrix of the particle system
  20829. * @param positionToUpdate is the position vector to update with the result
  20830. * @param particle is the particle we are computed the position for
  20831. */
  20832. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20833. /**
  20834. * Clones the current emitter and returns a copy of it
  20835. * @returns the new emitter
  20836. */
  20837. clone(): ConeParticleEmitter;
  20838. /**
  20839. * Called by the GPUParticleSystem to setup the update shader
  20840. * @param effect defines the update shader
  20841. */
  20842. applyToShader(effect: Effect): void;
  20843. /**
  20844. * Returns a string to use to update the GPU particles update shader
  20845. * @returns a string containng the defines string
  20846. */
  20847. getEffectDefines(): string;
  20848. /**
  20849. * Returns the string "ConeParticleEmitter"
  20850. * @returns a string containing the class name
  20851. */
  20852. getClassName(): string;
  20853. /**
  20854. * Serializes the particle system to a JSON object.
  20855. * @returns the JSON object
  20856. */
  20857. serialize(): any;
  20858. /**
  20859. * Parse properties from a JSON object
  20860. * @param serializationObject defines the JSON object
  20861. */
  20862. parse(serializationObject: any): void;
  20863. }
  20864. }
  20865. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  20866. import { Vector3, Matrix } from "babylonjs/Maths/math";
  20867. import { Effect } from "babylonjs/Materials/effect";
  20868. import { Particle } from "babylonjs/Particles/particle";
  20869. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  20870. /**
  20871. * Particle emitter emitting particles from the inside of a cylinder.
  20872. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  20873. */
  20874. export class CylinderParticleEmitter implements IParticleEmitterType {
  20875. /**
  20876. * The radius of the emission cylinder.
  20877. */
  20878. radius: number;
  20879. /**
  20880. * The height of the emission cylinder.
  20881. */
  20882. height: number;
  20883. /**
  20884. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20885. */
  20886. radiusRange: number;
  20887. /**
  20888. * How much to randomize the particle direction [0-1].
  20889. */
  20890. directionRandomizer: number;
  20891. /**
  20892. * Creates a new instance CylinderParticleEmitter
  20893. * @param radius the radius of the emission cylinder (1 by default)
  20894. * @param height the height of the emission cylinder (1 by default)
  20895. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20896. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  20897. */
  20898. constructor(
  20899. /**
  20900. * The radius of the emission cylinder.
  20901. */
  20902. radius?: number,
  20903. /**
  20904. * The height of the emission cylinder.
  20905. */
  20906. height?: number,
  20907. /**
  20908. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  20909. */
  20910. radiusRange?: number,
  20911. /**
  20912. * How much to randomize the particle direction [0-1].
  20913. */
  20914. directionRandomizer?: number);
  20915. /**
  20916. * Called by the particle System when the direction is computed for the created particle.
  20917. * @param worldMatrix is the world matrix of the particle system
  20918. * @param directionToUpdate is the direction vector to update with the result
  20919. * @param particle is the particle we are computed the direction for
  20920. */
  20921. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20922. /**
  20923. * Called by the particle System when the position is computed for the created particle.
  20924. * @param worldMatrix is the world matrix of the particle system
  20925. * @param positionToUpdate is the position vector to update with the result
  20926. * @param particle is the particle we are computed the position for
  20927. */
  20928. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  20929. /**
  20930. * Clones the current emitter and returns a copy of it
  20931. * @returns the new emitter
  20932. */
  20933. clone(): CylinderParticleEmitter;
  20934. /**
  20935. * Called by the GPUParticleSystem to setup the update shader
  20936. * @param effect defines the update shader
  20937. */
  20938. applyToShader(effect: Effect): void;
  20939. /**
  20940. * Returns a string to use to update the GPU particles update shader
  20941. * @returns a string containng the defines string
  20942. */
  20943. getEffectDefines(): string;
  20944. /**
  20945. * Returns the string "CylinderParticleEmitter"
  20946. * @returns a string containing the class name
  20947. */
  20948. getClassName(): string;
  20949. /**
  20950. * Serializes the particle system to a JSON object.
  20951. * @returns the JSON object
  20952. */
  20953. serialize(): any;
  20954. /**
  20955. * Parse properties from a JSON object
  20956. * @param serializationObject defines the JSON object
  20957. */
  20958. parse(serializationObject: any): void;
  20959. }
  20960. /**
  20961. * Particle emitter emitting particles from the inside of a cylinder.
  20962. * It emits the particles randomly between two vectors.
  20963. */
  20964. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  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. * Creates a new instance CylinderDirectedParticleEmitter
  20975. * @param radius the radius of the emission cylinder (1 by default)
  20976. * @param height the height of the emission cylinder (1 by default)
  20977. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  20978. * @param direction1 the min limit of the emission direction (up vector by default)
  20979. * @param direction2 the max limit of the emission direction (up vector by default)
  20980. */
  20981. constructor(radius?: number, height?: number, radiusRange?: number,
  20982. /**
  20983. * The min limit of the emission direction.
  20984. */
  20985. direction1?: Vector3,
  20986. /**
  20987. * The max limit of the emission direction.
  20988. */
  20989. direction2?: Vector3);
  20990. /**
  20991. * Called by the particle System when the direction is computed for the created particle.
  20992. * @param worldMatrix is the world matrix of the particle system
  20993. * @param directionToUpdate is the direction vector to update with the result
  20994. * @param particle is the particle we are computed the direction for
  20995. */
  20996. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  20997. /**
  20998. * Clones the current emitter and returns a copy of it
  20999. * @returns the new emitter
  21000. */
  21001. clone(): CylinderDirectedParticleEmitter;
  21002. /**
  21003. * Called by the GPUParticleSystem to setup the update shader
  21004. * @param effect defines the update shader
  21005. */
  21006. applyToShader(effect: Effect): void;
  21007. /**
  21008. * Returns a string to use to update the GPU particles update shader
  21009. * @returns a string containng the defines string
  21010. */
  21011. getEffectDefines(): string;
  21012. /**
  21013. * Returns the string "CylinderDirectedParticleEmitter"
  21014. * @returns a string containing the class name
  21015. */
  21016. getClassName(): string;
  21017. /**
  21018. * Serializes the particle system to a JSON object.
  21019. * @returns the JSON object
  21020. */
  21021. serialize(): any;
  21022. /**
  21023. * Parse properties from a JSON object
  21024. * @param serializationObject defines the JSON object
  21025. */
  21026. parse(serializationObject: any): void;
  21027. }
  21028. }
  21029. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  21030. import { Vector3, Matrix } from "babylonjs/Maths/math";
  21031. import { Effect } from "babylonjs/Materials/effect";
  21032. import { Particle } from "babylonjs/Particles/particle";
  21033. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21034. /**
  21035. * Particle emitter emitting particles from the inside of a hemisphere.
  21036. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  21037. */
  21038. export class HemisphericParticleEmitter implements IParticleEmitterType {
  21039. /**
  21040. * The radius of the emission hemisphere.
  21041. */
  21042. radius: number;
  21043. /**
  21044. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21045. */
  21046. radiusRange: number;
  21047. /**
  21048. * How much to randomize the particle direction [0-1].
  21049. */
  21050. directionRandomizer: number;
  21051. /**
  21052. * Creates a new instance HemisphericParticleEmitter
  21053. * @param radius the radius of the emission hemisphere (1 by default)
  21054. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21055. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  21056. */
  21057. constructor(
  21058. /**
  21059. * The radius of the emission hemisphere.
  21060. */
  21061. radius?: number,
  21062. /**
  21063. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21064. */
  21065. radiusRange?: number,
  21066. /**
  21067. * How much to randomize the particle direction [0-1].
  21068. */
  21069. directionRandomizer?: number);
  21070. /**
  21071. * Called by the particle System when the direction is computed for the created particle.
  21072. * @param worldMatrix is the world matrix of the particle system
  21073. * @param directionToUpdate is the direction vector to update with the result
  21074. * @param particle is the particle we are computed the direction for
  21075. */
  21076. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21077. /**
  21078. * Called by the particle System when the position is computed for the created particle.
  21079. * @param worldMatrix is the world matrix of the particle system
  21080. * @param positionToUpdate is the position vector to update with the result
  21081. * @param particle is the particle we are computed the position for
  21082. */
  21083. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  21084. /**
  21085. * Clones the current emitter and returns a copy of it
  21086. * @returns the new emitter
  21087. */
  21088. clone(): HemisphericParticleEmitter;
  21089. /**
  21090. * Called by the GPUParticleSystem to setup the update shader
  21091. * @param effect defines the update shader
  21092. */
  21093. applyToShader(effect: Effect): void;
  21094. /**
  21095. * Returns a string to use to update the GPU particles update shader
  21096. * @returns a string containng the defines string
  21097. */
  21098. getEffectDefines(): string;
  21099. /**
  21100. * Returns the string "HemisphericParticleEmitter"
  21101. * @returns a string containing the class name
  21102. */
  21103. getClassName(): string;
  21104. /**
  21105. * Serializes the particle system to a JSON object.
  21106. * @returns the JSON object
  21107. */
  21108. serialize(): any;
  21109. /**
  21110. * Parse properties from a JSON object
  21111. * @param serializationObject defines the JSON object
  21112. */
  21113. parse(serializationObject: any): void;
  21114. }
  21115. }
  21116. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  21117. import { Vector3, Matrix } from "babylonjs/Maths/math";
  21118. import { Effect } from "babylonjs/Materials/effect";
  21119. import { Particle } from "babylonjs/Particles/particle";
  21120. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21121. /**
  21122. * Particle emitter emitting particles from a point.
  21123. * It emits the particles randomly between 2 given directions.
  21124. */
  21125. export class PointParticleEmitter implements IParticleEmitterType {
  21126. /**
  21127. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  21128. */
  21129. direction1: Vector3;
  21130. /**
  21131. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  21132. */
  21133. direction2: Vector3;
  21134. /**
  21135. * Creates a new instance PointParticleEmitter
  21136. */
  21137. constructor();
  21138. /**
  21139. * Called by the particle System when the direction is computed for the created particle.
  21140. * @param worldMatrix is the world matrix of the particle system
  21141. * @param directionToUpdate is the direction vector to update with the result
  21142. * @param particle is the particle we are computed the direction for
  21143. */
  21144. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21145. /**
  21146. * Called by the particle System when the position is computed for the created particle.
  21147. * @param worldMatrix is the world matrix of the particle system
  21148. * @param positionToUpdate is the position vector to update with the result
  21149. * @param particle is the particle we are computed the position for
  21150. */
  21151. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  21152. /**
  21153. * Clones the current emitter and returns a copy of it
  21154. * @returns the new emitter
  21155. */
  21156. clone(): PointParticleEmitter;
  21157. /**
  21158. * Called by the GPUParticleSystem to setup the update shader
  21159. * @param effect defines the update shader
  21160. */
  21161. applyToShader(effect: Effect): void;
  21162. /**
  21163. * Returns a string to use to update the GPU particles update shader
  21164. * @returns a string containng the defines string
  21165. */
  21166. getEffectDefines(): string;
  21167. /**
  21168. * Returns the string "PointParticleEmitter"
  21169. * @returns a string containing the class name
  21170. */
  21171. getClassName(): string;
  21172. /**
  21173. * Serializes the particle system to a JSON object.
  21174. * @returns the JSON object
  21175. */
  21176. serialize(): any;
  21177. /**
  21178. * Parse properties from a JSON object
  21179. * @param serializationObject defines the JSON object
  21180. */
  21181. parse(serializationObject: any): void;
  21182. }
  21183. }
  21184. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  21185. import { Vector3, Matrix } from "babylonjs/Maths/math";
  21186. import { Effect } from "babylonjs/Materials/effect";
  21187. import { Particle } from "babylonjs/Particles/particle";
  21188. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21189. /**
  21190. * Particle emitter emitting particles from the inside of a sphere.
  21191. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  21192. */
  21193. export class SphereParticleEmitter implements IParticleEmitterType {
  21194. /**
  21195. * The radius of the emission sphere.
  21196. */
  21197. radius: number;
  21198. /**
  21199. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21200. */
  21201. radiusRange: number;
  21202. /**
  21203. * How much to randomize the particle direction [0-1].
  21204. */
  21205. directionRandomizer: number;
  21206. /**
  21207. * Creates a new instance SphereParticleEmitter
  21208. * @param radius the radius of the emission sphere (1 by default)
  21209. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21210. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  21211. */
  21212. constructor(
  21213. /**
  21214. * The radius of the emission sphere.
  21215. */
  21216. radius?: number,
  21217. /**
  21218. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  21219. */
  21220. radiusRange?: number,
  21221. /**
  21222. * How much to randomize the particle direction [0-1].
  21223. */
  21224. directionRandomizer?: number);
  21225. /**
  21226. * Called by the particle System when the direction is computed for the created particle.
  21227. * @param worldMatrix is the world matrix of the particle system
  21228. * @param directionToUpdate is the direction vector to update with the result
  21229. * @param particle is the particle we are computed the direction for
  21230. */
  21231. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21232. /**
  21233. * Called by the particle System when the position is computed for the created particle.
  21234. * @param worldMatrix is the world matrix of the particle system
  21235. * @param positionToUpdate is the position vector to update with the result
  21236. * @param particle is the particle we are computed the position for
  21237. */
  21238. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  21239. /**
  21240. * Clones the current emitter and returns a copy of it
  21241. * @returns the new emitter
  21242. */
  21243. clone(): SphereParticleEmitter;
  21244. /**
  21245. * Called by the GPUParticleSystem to setup the update shader
  21246. * @param effect defines the update shader
  21247. */
  21248. applyToShader(effect: Effect): void;
  21249. /**
  21250. * Returns a string to use to update the GPU particles update shader
  21251. * @returns a string containng the defines string
  21252. */
  21253. getEffectDefines(): string;
  21254. /**
  21255. * Returns the string "SphereParticleEmitter"
  21256. * @returns a string containing the class name
  21257. */
  21258. getClassName(): string;
  21259. /**
  21260. * Serializes the particle system to a JSON object.
  21261. * @returns the JSON object
  21262. */
  21263. serialize(): any;
  21264. /**
  21265. * Parse properties from a JSON object
  21266. * @param serializationObject defines the JSON object
  21267. */
  21268. parse(serializationObject: any): void;
  21269. }
  21270. /**
  21271. * Particle emitter emitting particles from the inside of a sphere.
  21272. * It emits the particles randomly between two vectors.
  21273. */
  21274. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  21275. /**
  21276. * The min limit of the emission direction.
  21277. */
  21278. direction1: Vector3;
  21279. /**
  21280. * The max limit of the emission direction.
  21281. */
  21282. direction2: Vector3;
  21283. /**
  21284. * Creates a new instance SphereDirectedParticleEmitter
  21285. * @param radius the radius of the emission sphere (1 by default)
  21286. * @param direction1 the min limit of the emission direction (up vector by default)
  21287. * @param direction2 the max limit of the emission direction (up vector by default)
  21288. */
  21289. constructor(radius?: number,
  21290. /**
  21291. * The min limit of the emission direction.
  21292. */
  21293. direction1?: Vector3,
  21294. /**
  21295. * The max limit of the emission direction.
  21296. */
  21297. direction2?: Vector3);
  21298. /**
  21299. * Called by the particle System when the direction is computed for the created particle.
  21300. * @param worldMatrix is the world matrix of the particle system
  21301. * @param directionToUpdate is the direction vector to update with the result
  21302. * @param particle is the particle we are computed the direction for
  21303. */
  21304. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  21305. /**
  21306. * Clones the current emitter and returns a copy of it
  21307. * @returns the new emitter
  21308. */
  21309. clone(): SphereDirectedParticleEmitter;
  21310. /**
  21311. * Called by the GPUParticleSystem to setup the update shader
  21312. * @param effect defines the update shader
  21313. */
  21314. applyToShader(effect: Effect): void;
  21315. /**
  21316. * Returns a string to use to update the GPU particles update shader
  21317. * @returns a string containng the defines string
  21318. */
  21319. getEffectDefines(): string;
  21320. /**
  21321. * Returns the string "SphereDirectedParticleEmitter"
  21322. * @returns a string containing the class name
  21323. */
  21324. getClassName(): string;
  21325. /**
  21326. * Serializes the particle system to a JSON object.
  21327. * @returns the JSON object
  21328. */
  21329. serialize(): any;
  21330. /**
  21331. * Parse properties from a JSON object
  21332. * @param serializationObject defines the JSON object
  21333. */
  21334. parse(serializationObject: any): void;
  21335. }
  21336. }
  21337. declare module "babylonjs/Particles/EmitterTypes/index" {
  21338. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  21339. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  21340. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  21341. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  21342. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  21343. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  21344. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  21345. }
  21346. declare module "babylonjs/Particles/IParticleSystem" {
  21347. import { Nullable } from "babylonjs/types";
  21348. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  21349. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21350. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21351. import { Texture } from "babylonjs/Materials/Textures/texture";
  21352. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  21353. import { Scene } from "babylonjs/scene";
  21354. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  21355. import { Animation } from "babylonjs/Animations/animation";
  21356. /**
  21357. * Interface representing a particle system in Babylon.js.
  21358. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  21359. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  21360. */
  21361. export interface IParticleSystem {
  21362. /**
  21363. * List of animations used by the particle system.
  21364. */
  21365. animations: Animation[];
  21366. /**
  21367. * The id of the Particle system.
  21368. */
  21369. id: string;
  21370. /**
  21371. * The name of the Particle system.
  21372. */
  21373. name: string;
  21374. /**
  21375. * The emitter represents the Mesh or position we are attaching the particle system to.
  21376. */
  21377. emitter: Nullable<AbstractMesh | Vector3>;
  21378. /**
  21379. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  21380. */
  21381. isBillboardBased: boolean;
  21382. /**
  21383. * The rendering group used by the Particle system to chose when to render.
  21384. */
  21385. renderingGroupId: number;
  21386. /**
  21387. * The layer mask we are rendering the particles through.
  21388. */
  21389. layerMask: number;
  21390. /**
  21391. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  21392. */
  21393. updateSpeed: number;
  21394. /**
  21395. * The amount of time the particle system is running (depends of the overall update speed).
  21396. */
  21397. targetStopDuration: number;
  21398. /**
  21399. * The texture used to render each particle. (this can be a spritesheet)
  21400. */
  21401. particleTexture: Nullable<Texture>;
  21402. /**
  21403. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  21404. */
  21405. blendMode: number;
  21406. /**
  21407. * Minimum life time of emitting particles.
  21408. */
  21409. minLifeTime: number;
  21410. /**
  21411. * Maximum life time of emitting particles.
  21412. */
  21413. maxLifeTime: number;
  21414. /**
  21415. * Minimum Size of emitting particles.
  21416. */
  21417. minSize: number;
  21418. /**
  21419. * Maximum Size of emitting particles.
  21420. */
  21421. maxSize: number;
  21422. /**
  21423. * Minimum scale of emitting particles on X axis.
  21424. */
  21425. minScaleX: number;
  21426. /**
  21427. * Maximum scale of emitting particles on X axis.
  21428. */
  21429. maxScaleX: number;
  21430. /**
  21431. * Minimum scale of emitting particles on Y axis.
  21432. */
  21433. minScaleY: number;
  21434. /**
  21435. * Maximum scale of emitting particles on Y axis.
  21436. */
  21437. maxScaleY: number;
  21438. /**
  21439. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  21440. */
  21441. color1: Color4;
  21442. /**
  21443. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  21444. */
  21445. color2: Color4;
  21446. /**
  21447. * Color the particle will have at the end of its lifetime.
  21448. */
  21449. colorDead: Color4;
  21450. /**
  21451. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  21452. */
  21453. emitRate: number;
  21454. /**
  21455. * You can use gravity if you want to give an orientation to your particles.
  21456. */
  21457. gravity: Vector3;
  21458. /**
  21459. * Minimum power of emitting particles.
  21460. */
  21461. minEmitPower: number;
  21462. /**
  21463. * Maximum power of emitting particles.
  21464. */
  21465. maxEmitPower: number;
  21466. /**
  21467. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  21468. */
  21469. minAngularSpeed: number;
  21470. /**
  21471. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  21472. */
  21473. maxAngularSpeed: number;
  21474. /**
  21475. * Gets or sets the minimal initial rotation in radians.
  21476. */
  21477. minInitialRotation: number;
  21478. /**
  21479. * Gets or sets the maximal initial rotation in radians.
  21480. */
  21481. maxInitialRotation: number;
  21482. /**
  21483. * The particle emitter type defines the emitter used by the particle system.
  21484. * It can be for example box, sphere, or cone...
  21485. */
  21486. particleEmitterType: Nullable<IParticleEmitterType>;
  21487. /**
  21488. * Defines the delay in milliseconds before starting the system (0 by default)
  21489. */
  21490. startDelay: number;
  21491. /**
  21492. * 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
  21493. */
  21494. preWarmCycles: number;
  21495. /**
  21496. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  21497. */
  21498. preWarmStepOffset: number;
  21499. /**
  21500. * 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)
  21501. */
  21502. spriteCellChangeSpeed: number;
  21503. /**
  21504. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  21505. */
  21506. startSpriteCellID: number;
  21507. /**
  21508. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  21509. */
  21510. endSpriteCellID: number;
  21511. /**
  21512. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  21513. */
  21514. spriteCellWidth: number;
  21515. /**
  21516. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  21517. */
  21518. spriteCellHeight: number;
  21519. /**
  21520. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  21521. */
  21522. spriteRandomStartCell: boolean;
  21523. /**
  21524. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  21525. */
  21526. isAnimationSheetEnabled: boolean;
  21527. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  21528. translationPivot: Vector2;
  21529. /**
  21530. * Gets or sets a texture used to add random noise to particle positions
  21531. */
  21532. noiseTexture: Nullable<BaseTexture>;
  21533. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  21534. noiseStrength: Vector3;
  21535. /**
  21536. * Gets or sets the billboard mode to use when isBillboardBased = true.
  21537. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  21538. */
  21539. billboardMode: number;
  21540. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  21541. limitVelocityDamping: number;
  21542. /**
  21543. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  21544. */
  21545. beginAnimationOnStart: boolean;
  21546. /**
  21547. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  21548. */
  21549. beginAnimationFrom: number;
  21550. /**
  21551. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  21552. */
  21553. beginAnimationTo: number;
  21554. /**
  21555. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  21556. */
  21557. beginAnimationLoop: boolean;
  21558. /**
  21559. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  21560. */
  21561. disposeOnStop: boolean;
  21562. /**
  21563. * Gets the maximum number of particles active at the same time.
  21564. * @returns The max number of active particles.
  21565. */
  21566. getCapacity(): number;
  21567. /**
  21568. * Gets if the system has been started. (Note: this will still be true after stop is called)
  21569. * @returns True if it has been started, otherwise false.
  21570. */
  21571. isStarted(): boolean;
  21572. /**
  21573. * Animates the particle system for this frame.
  21574. */
  21575. animate(): void;
  21576. /**
  21577. * Renders the particle system in its current state.
  21578. * @returns the current number of particles
  21579. */
  21580. render(): number;
  21581. /**
  21582. * Dispose the particle system and frees its associated resources.
  21583. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  21584. */
  21585. dispose(disposeTexture?: boolean): void;
  21586. /**
  21587. * Clones the particle system.
  21588. * @param name The name of the cloned object
  21589. * @param newEmitter The new emitter to use
  21590. * @returns the cloned particle system
  21591. */
  21592. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  21593. /**
  21594. * Serializes the particle system to a JSON object.
  21595. * @returns the JSON object
  21596. */
  21597. serialize(): any;
  21598. /**
  21599. * Rebuild the particle system
  21600. */
  21601. rebuild(): void;
  21602. /**
  21603. * Starts the particle system and begins to emit
  21604. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  21605. */
  21606. start(delay?: number): void;
  21607. /**
  21608. * Stops the particle system.
  21609. */
  21610. stop(): void;
  21611. /**
  21612. * Remove all active particles
  21613. */
  21614. reset(): void;
  21615. /**
  21616. * Is this system ready to be used/rendered
  21617. * @return true if the system is ready
  21618. */
  21619. isReady(): boolean;
  21620. /**
  21621. * Adds a new color gradient
  21622. * @param gradient defines the gradient to use (between 0 and 1)
  21623. * @param color1 defines the color to affect to the specified gradient
  21624. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  21625. * @returns the current particle system
  21626. */
  21627. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  21628. /**
  21629. * Remove a specific color gradient
  21630. * @param gradient defines the gradient to remove
  21631. * @returns the current particle system
  21632. */
  21633. removeColorGradient(gradient: number): IParticleSystem;
  21634. /**
  21635. * Adds a new size gradient
  21636. * @param gradient defines the gradient to use (between 0 and 1)
  21637. * @param factor defines the size factor to affect to the specified gradient
  21638. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21639. * @returns the current particle system
  21640. */
  21641. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21642. /**
  21643. * Remove a specific size gradient
  21644. * @param gradient defines the gradient to remove
  21645. * @returns the current particle system
  21646. */
  21647. removeSizeGradient(gradient: number): IParticleSystem;
  21648. /**
  21649. * Gets the current list of color gradients.
  21650. * You must use addColorGradient and removeColorGradient to udpate this list
  21651. * @returns the list of color gradients
  21652. */
  21653. getColorGradients(): Nullable<Array<ColorGradient>>;
  21654. /**
  21655. * Gets the current list of size gradients.
  21656. * You must use addSizeGradient and removeSizeGradient to udpate this list
  21657. * @returns the list of size gradients
  21658. */
  21659. getSizeGradients(): Nullable<Array<FactorGradient>>;
  21660. /**
  21661. * Gets the current list of angular speed gradients.
  21662. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  21663. * @returns the list of angular speed gradients
  21664. */
  21665. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  21666. /**
  21667. * Adds a new angular speed gradient
  21668. * @param gradient defines the gradient to use (between 0 and 1)
  21669. * @param factor defines the angular speed to affect to the specified gradient
  21670. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21671. * @returns the current particle system
  21672. */
  21673. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21674. /**
  21675. * Remove a specific angular speed gradient
  21676. * @param gradient defines the gradient to remove
  21677. * @returns the current particle system
  21678. */
  21679. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  21680. /**
  21681. * Gets the current list of velocity gradients.
  21682. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  21683. * @returns the list of velocity gradients
  21684. */
  21685. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  21686. /**
  21687. * Adds a new velocity gradient
  21688. * @param gradient defines the gradient to use (between 0 and 1)
  21689. * @param factor defines the velocity to affect to the specified gradient
  21690. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21691. * @returns the current particle system
  21692. */
  21693. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21694. /**
  21695. * Remove a specific velocity gradient
  21696. * @param gradient defines the gradient to remove
  21697. * @returns the current particle system
  21698. */
  21699. removeVelocityGradient(gradient: number): IParticleSystem;
  21700. /**
  21701. * Gets the current list of limit velocity gradients.
  21702. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  21703. * @returns the list of limit velocity gradients
  21704. */
  21705. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  21706. /**
  21707. * Adds a new limit velocity gradient
  21708. * @param gradient defines the gradient to use (between 0 and 1)
  21709. * @param factor defines the limit velocity to affect to the specified gradient
  21710. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21711. * @returns the current particle system
  21712. */
  21713. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21714. /**
  21715. * Remove a specific limit velocity gradient
  21716. * @param gradient defines the gradient to remove
  21717. * @returns the current particle system
  21718. */
  21719. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  21720. /**
  21721. * Adds a new drag gradient
  21722. * @param gradient defines the gradient to use (between 0 and 1)
  21723. * @param factor defines the drag to affect to the specified gradient
  21724. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21725. * @returns the current particle system
  21726. */
  21727. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21728. /**
  21729. * Remove a specific drag gradient
  21730. * @param gradient defines the gradient to remove
  21731. * @returns the current particle system
  21732. */
  21733. removeDragGradient(gradient: number): IParticleSystem;
  21734. /**
  21735. * Gets the current list of drag gradients.
  21736. * You must use addDragGradient and removeDragGradient to udpate this list
  21737. * @returns the list of drag gradients
  21738. */
  21739. getDragGradients(): Nullable<Array<FactorGradient>>;
  21740. /**
  21741. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  21742. * @param gradient defines the gradient to use (between 0 and 1)
  21743. * @param factor defines the emit rate to affect to the specified gradient
  21744. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21745. * @returns the current particle system
  21746. */
  21747. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21748. /**
  21749. * Remove a specific emit rate gradient
  21750. * @param gradient defines the gradient to remove
  21751. * @returns the current particle system
  21752. */
  21753. removeEmitRateGradient(gradient: number): IParticleSystem;
  21754. /**
  21755. * Gets the current list of emit rate gradients.
  21756. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  21757. * @returns the list of emit rate gradients
  21758. */
  21759. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  21760. /**
  21761. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  21762. * @param gradient defines the gradient to use (between 0 and 1)
  21763. * @param factor defines the start size to affect to the specified gradient
  21764. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21765. * @returns the current particle system
  21766. */
  21767. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21768. /**
  21769. * Remove a specific start size gradient
  21770. * @param gradient defines the gradient to remove
  21771. * @returns the current particle system
  21772. */
  21773. removeStartSizeGradient(gradient: number): IParticleSystem;
  21774. /**
  21775. * Gets the current list of start size gradients.
  21776. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  21777. * @returns the list of start size gradients
  21778. */
  21779. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  21780. /**
  21781. * Adds a new life time gradient
  21782. * @param gradient defines the gradient to use (between 0 and 1)
  21783. * @param factor defines the life time factor to affect to the specified gradient
  21784. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  21785. * @returns the current particle system
  21786. */
  21787. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  21788. /**
  21789. * Remove a specific life time gradient
  21790. * @param gradient defines the gradient to remove
  21791. * @returns the current particle system
  21792. */
  21793. removeLifeTimeGradient(gradient: number): IParticleSystem;
  21794. /**
  21795. * Gets the current list of life time gradients.
  21796. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  21797. * @returns the list of life time gradients
  21798. */
  21799. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  21800. /**
  21801. * Gets the current list of color gradients.
  21802. * You must use addColorGradient and removeColorGradient to udpate this list
  21803. * @returns the list of color gradients
  21804. */
  21805. getColorGradients(): Nullable<Array<ColorGradient>>;
  21806. /**
  21807. * Adds a new ramp gradient used to remap particle colors
  21808. * @param gradient defines the gradient to use (between 0 and 1)
  21809. * @param color defines the color to affect to the specified gradient
  21810. * @returns the current particle system
  21811. */
  21812. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  21813. /**
  21814. * Gets the current list of ramp gradients.
  21815. * You must use addRampGradient and removeRampGradient to udpate this list
  21816. * @returns the list of ramp gradients
  21817. */
  21818. getRampGradients(): Nullable<Array<Color3Gradient>>;
  21819. /** Gets or sets a boolean indicating that ramp gradients must be used
  21820. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  21821. */
  21822. useRampGradients: boolean;
  21823. /**
  21824. * Adds a new color remap gradient
  21825. * @param gradient defines the gradient to use (between 0 and 1)
  21826. * @param min defines the color remap minimal range
  21827. * @param max defines the color remap maximal range
  21828. * @returns the current particle system
  21829. */
  21830. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21831. /**
  21832. * Gets the current list of color remap gradients.
  21833. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  21834. * @returns the list of color remap gradients
  21835. */
  21836. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  21837. /**
  21838. * Adds a new alpha remap gradient
  21839. * @param gradient defines the gradient to use (between 0 and 1)
  21840. * @param min defines the alpha remap minimal range
  21841. * @param max defines the alpha remap maximal range
  21842. * @returns the current particle system
  21843. */
  21844. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  21845. /**
  21846. * Gets the current list of alpha remap gradients.
  21847. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  21848. * @returns the list of alpha remap gradients
  21849. */
  21850. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  21851. /**
  21852. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  21853. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21854. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21855. * @returns the emitter
  21856. */
  21857. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  21858. /**
  21859. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  21860. * @param radius The radius of the hemisphere to emit from
  21861. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21862. * @returns the emitter
  21863. */
  21864. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  21865. /**
  21866. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  21867. * @param radius The radius of the sphere to emit from
  21868. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  21869. * @returns the emitter
  21870. */
  21871. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  21872. /**
  21873. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  21874. * @param radius The radius of the sphere to emit from
  21875. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  21876. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  21877. * @returns the emitter
  21878. */
  21879. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21880. /**
  21881. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  21882. * @param radius The radius of the emission cylinder
  21883. * @param height The height of the emission cylinder
  21884. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  21885. * @param directionRandomizer How much to randomize the particle direction [0-1]
  21886. * @returns the emitter
  21887. */
  21888. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  21889. /**
  21890. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  21891. * @param radius The radius of the cylinder to emit from
  21892. * @param height The height of the emission cylinder
  21893. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  21894. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  21895. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  21896. * @returns the emitter
  21897. */
  21898. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  21899. /**
  21900. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  21901. * @param radius The radius of the cone to emit from
  21902. * @param angle The base angle of the cone
  21903. * @returns the emitter
  21904. */
  21905. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  21906. /**
  21907. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  21908. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  21909. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  21910. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21911. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  21912. * @returns the emitter
  21913. */
  21914. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  21915. /**
  21916. * Get hosting scene
  21917. * @returns the scene
  21918. */
  21919. getScene(): Scene;
  21920. }
  21921. }
  21922. declare module "babylonjs/Shaders/line.fragment" {
  21923. /** @hidden */
  21924. export var linePixelShader: {
  21925. name: string;
  21926. shader: string;
  21927. };
  21928. }
  21929. declare module "babylonjs/Shaders/line.vertex" {
  21930. /** @hidden */
  21931. export var lineVertexShader: {
  21932. name: string;
  21933. shader: string;
  21934. };
  21935. }
  21936. declare module "babylonjs/Rendering/edgesRenderer" {
  21937. import { Nullable } from "babylonjs/types";
  21938. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21940. import { Vector3 } from "babylonjs/Maths/math";
  21941. import { IDisposable } from "babylonjs/scene";
  21942. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  21943. import "babylonjs/Shaders/line.fragment";
  21944. import "babylonjs/Shaders/line.vertex";
  21945. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21946. module "babylonjs/Meshes/abstractMesh" {
  21947. interface AbstractMesh {
  21948. /**
  21949. * Gets the edgesRenderer associated with the mesh
  21950. */
  21951. edgesRenderer: Nullable<EdgesRenderer>;
  21952. }
  21953. }
  21954. module "babylonjs/Meshes/linesMesh" {
  21955. interface LinesMesh {
  21956. /**
  21957. * Enables the edge rendering mode on the mesh.
  21958. * This mode makes the mesh edges visible
  21959. * @param epsilon defines the maximal distance between two angles to detect a face
  21960. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21961. * @returns the currentAbstractMesh
  21962. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21963. */
  21964. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  21965. }
  21966. }
  21967. module "babylonjs/Meshes/linesMesh" {
  21968. interface InstancedLinesMesh {
  21969. /**
  21970. * Enables the edge rendering mode on the mesh.
  21971. * This mode makes the mesh edges visible
  21972. * @param epsilon defines the maximal distance between two angles to detect a face
  21973. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  21974. * @returns the current InstancedLinesMesh
  21975. * @see https://www.babylonjs-playground.com/#19O9TU#0
  21976. */
  21977. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  21978. }
  21979. }
  21980. /**
  21981. * Defines the minimum contract an Edges renderer should follow.
  21982. */
  21983. export interface IEdgesRenderer extends IDisposable {
  21984. /**
  21985. * Gets or sets a boolean indicating if the edgesRenderer is active
  21986. */
  21987. isEnabled: boolean;
  21988. /**
  21989. * Renders the edges of the attached mesh,
  21990. */
  21991. render(): void;
  21992. /**
  21993. * Checks wether or not the edges renderer is ready to render.
  21994. * @return true if ready, otherwise false.
  21995. */
  21996. isReady(): boolean;
  21997. }
  21998. /**
  21999. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  22000. */
  22001. export class EdgesRenderer implements IEdgesRenderer {
  22002. /**
  22003. * Define the size of the edges with an orthographic camera
  22004. */
  22005. edgesWidthScalerForOrthographic: number;
  22006. /**
  22007. * Define the size of the edges with a perspective camera
  22008. */
  22009. edgesWidthScalerForPerspective: number;
  22010. protected _source: AbstractMesh;
  22011. protected _linesPositions: number[];
  22012. protected _linesNormals: number[];
  22013. protected _linesIndices: number[];
  22014. protected _epsilon: number;
  22015. protected _indicesCount: number;
  22016. protected _lineShader: ShaderMaterial;
  22017. protected _ib: DataBuffer;
  22018. protected _buffers: {
  22019. [key: string]: Nullable<VertexBuffer>;
  22020. };
  22021. protected _checkVerticesInsteadOfIndices: boolean;
  22022. private _meshRebuildObserver;
  22023. private _meshDisposeObserver;
  22024. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  22025. isEnabled: boolean;
  22026. /**
  22027. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  22028. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  22029. * @param source Mesh used to create edges
  22030. * @param epsilon sum of angles in adjacency to check for edge
  22031. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  22032. * @param generateEdgesLines - should generate Lines or only prepare resources.
  22033. */
  22034. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  22035. protected _prepareRessources(): void;
  22036. /** @hidden */
  22037. _rebuild(): void;
  22038. /**
  22039. * Releases the required resources for the edges renderer
  22040. */
  22041. dispose(): void;
  22042. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  22043. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  22044. /**
  22045. * Checks if the pair of p0 and p1 is en edge
  22046. * @param faceIndex
  22047. * @param edge
  22048. * @param faceNormals
  22049. * @param p0
  22050. * @param p1
  22051. * @private
  22052. */
  22053. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  22054. /**
  22055. * push line into the position, normal and index buffer
  22056. * @protected
  22057. */
  22058. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  22059. /**
  22060. * Generates lines edges from adjacencjes
  22061. * @private
  22062. */
  22063. _generateEdgesLines(): void;
  22064. /**
  22065. * Checks wether or not the edges renderer is ready to render.
  22066. * @return true if ready, otherwise false.
  22067. */
  22068. isReady(): boolean;
  22069. /**
  22070. * Renders the edges of the attached mesh,
  22071. */
  22072. render(): void;
  22073. }
  22074. /**
  22075. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  22076. */
  22077. export class LineEdgesRenderer extends EdgesRenderer {
  22078. /**
  22079. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  22080. * @param source LineMesh used to generate edges
  22081. * @param epsilon not important (specified angle for edge detection)
  22082. * @param checkVerticesInsteadOfIndices not important for LineMesh
  22083. */
  22084. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  22085. /**
  22086. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  22087. */
  22088. _generateEdgesLines(): void;
  22089. }
  22090. }
  22091. declare module "babylonjs/Rendering/renderingGroup" {
  22092. import { SmartArray } from "babylonjs/Misc/smartArray";
  22093. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22094. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22095. import { Nullable } from "babylonjs/types";
  22096. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22097. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  22098. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  22099. import { Material } from "babylonjs/Materials/material";
  22100. import { Scene } from "babylonjs/scene";
  22101. /**
  22102. * This represents the object necessary to create a rendering group.
  22103. * This is exclusively used and created by the rendering manager.
  22104. * To modify the behavior, you use the available helpers in your scene or meshes.
  22105. * @hidden
  22106. */
  22107. export class RenderingGroup {
  22108. index: number;
  22109. private static _zeroVector;
  22110. private _scene;
  22111. private _opaqueSubMeshes;
  22112. private _transparentSubMeshes;
  22113. private _alphaTestSubMeshes;
  22114. private _depthOnlySubMeshes;
  22115. private _particleSystems;
  22116. private _spriteManagers;
  22117. private _opaqueSortCompareFn;
  22118. private _alphaTestSortCompareFn;
  22119. private _transparentSortCompareFn;
  22120. private _renderOpaque;
  22121. private _renderAlphaTest;
  22122. private _renderTransparent;
  22123. /** @hidden */
  22124. _edgesRenderers: SmartArray<IEdgesRenderer>;
  22125. onBeforeTransparentRendering: () => void;
  22126. /**
  22127. * Set the opaque sort comparison function.
  22128. * If null the sub meshes will be render in the order they were created
  22129. */
  22130. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22131. /**
  22132. * Set the alpha test sort comparison function.
  22133. * If null the sub meshes will be render in the order they were created
  22134. */
  22135. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22136. /**
  22137. * Set the transparent sort comparison function.
  22138. * If null the sub meshes will be render in the order they were created
  22139. */
  22140. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  22141. /**
  22142. * Creates a new rendering group.
  22143. * @param index The rendering group index
  22144. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  22145. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  22146. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  22147. */
  22148. 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>);
  22149. /**
  22150. * Render all the sub meshes contained in the group.
  22151. * @param customRenderFunction Used to override the default render behaviour of the group.
  22152. * @returns true if rendered some submeshes.
  22153. */
  22154. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  22155. /**
  22156. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  22157. * @param subMeshes The submeshes to render
  22158. */
  22159. private renderOpaqueSorted;
  22160. /**
  22161. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  22162. * @param subMeshes The submeshes to render
  22163. */
  22164. private renderAlphaTestSorted;
  22165. /**
  22166. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  22167. * @param subMeshes The submeshes to render
  22168. */
  22169. private renderTransparentSorted;
  22170. /**
  22171. * Renders the submeshes in a specified order.
  22172. * @param subMeshes The submeshes to sort before render
  22173. * @param sortCompareFn The comparison function use to sort
  22174. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  22175. * @param transparent Specifies to activate blending if true
  22176. */
  22177. private static renderSorted;
  22178. /**
  22179. * Renders the submeshes in the order they were dispatched (no sort applied).
  22180. * @param subMeshes The submeshes to render
  22181. */
  22182. private static renderUnsorted;
  22183. /**
  22184. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22185. * are rendered back to front if in the same alpha index.
  22186. *
  22187. * @param a The first submesh
  22188. * @param b The second submesh
  22189. * @returns The result of the comparison
  22190. */
  22191. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  22192. /**
  22193. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22194. * are rendered back to front.
  22195. *
  22196. * @param a The first submesh
  22197. * @param b The second submesh
  22198. * @returns The result of the comparison
  22199. */
  22200. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  22201. /**
  22202. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  22203. * are rendered front to back (prevent overdraw).
  22204. *
  22205. * @param a The first submesh
  22206. * @param b The second submesh
  22207. * @returns The result of the comparison
  22208. */
  22209. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  22210. /**
  22211. * Resets the different lists of submeshes to prepare a new frame.
  22212. */
  22213. prepare(): void;
  22214. dispose(): void;
  22215. /**
  22216. * Inserts the submesh in its correct queue depending on its material.
  22217. * @param subMesh The submesh to dispatch
  22218. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  22219. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  22220. */
  22221. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  22222. dispatchSprites(spriteManager: ISpriteManager): void;
  22223. dispatchParticles(particleSystem: IParticleSystem): void;
  22224. private _renderParticles;
  22225. private _renderSprites;
  22226. }
  22227. }
  22228. declare module "babylonjs/Rendering/renderingManager" {
  22229. import { Nullable } from "babylonjs/types";
  22230. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22231. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22232. import { SmartArray } from "babylonjs/Misc/smartArray";
  22233. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  22234. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22235. import { Material } from "babylonjs/Materials/material";
  22236. import { Scene } from "babylonjs/scene";
  22237. import { Camera } from "babylonjs/Cameras/camera";
  22238. /**
  22239. * Interface describing the different options available in the rendering manager
  22240. * regarding Auto Clear between groups.
  22241. */
  22242. export interface IRenderingManagerAutoClearSetup {
  22243. /**
  22244. * Defines whether or not autoclear is enable.
  22245. */
  22246. autoClear: boolean;
  22247. /**
  22248. * Defines whether or not to autoclear the depth buffer.
  22249. */
  22250. depth: boolean;
  22251. /**
  22252. * Defines whether or not to autoclear the stencil buffer.
  22253. */
  22254. stencil: boolean;
  22255. }
  22256. /**
  22257. * This class is used by the onRenderingGroupObservable
  22258. */
  22259. export class RenderingGroupInfo {
  22260. /**
  22261. * The Scene that being rendered
  22262. */
  22263. scene: Scene;
  22264. /**
  22265. * The camera currently used for the rendering pass
  22266. */
  22267. camera: Nullable<Camera>;
  22268. /**
  22269. * The ID of the renderingGroup being processed
  22270. */
  22271. renderingGroupId: number;
  22272. }
  22273. /**
  22274. * This is the manager responsible of all the rendering for meshes sprites and particles.
  22275. * It is enable to manage the different groups as well as the different necessary sort functions.
  22276. * This should not be used directly aside of the few static configurations
  22277. */
  22278. export class RenderingManager {
  22279. /**
  22280. * The max id used for rendering groups (not included)
  22281. */
  22282. static MAX_RENDERINGGROUPS: number;
  22283. /**
  22284. * The min id used for rendering groups (included)
  22285. */
  22286. static MIN_RENDERINGGROUPS: number;
  22287. /**
  22288. * Used to globally prevent autoclearing scenes.
  22289. */
  22290. static AUTOCLEAR: boolean;
  22291. /**
  22292. * @hidden
  22293. */
  22294. _useSceneAutoClearSetup: boolean;
  22295. private _scene;
  22296. private _renderingGroups;
  22297. private _depthStencilBufferAlreadyCleaned;
  22298. private _autoClearDepthStencil;
  22299. private _customOpaqueSortCompareFn;
  22300. private _customAlphaTestSortCompareFn;
  22301. private _customTransparentSortCompareFn;
  22302. private _renderingGroupInfo;
  22303. /**
  22304. * Instantiates a new rendering group for a particular scene
  22305. * @param scene Defines the scene the groups belongs to
  22306. */
  22307. constructor(scene: Scene);
  22308. private _clearDepthStencilBuffer;
  22309. /**
  22310. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  22311. * @hidden
  22312. */
  22313. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  22314. /**
  22315. * Resets the different information of the group to prepare a new frame
  22316. * @hidden
  22317. */
  22318. reset(): void;
  22319. /**
  22320. * Dispose and release the group and its associated resources.
  22321. * @hidden
  22322. */
  22323. dispose(): void;
  22324. /**
  22325. * Clear the info related to rendering groups preventing retention points during dispose.
  22326. */
  22327. freeRenderingGroups(): void;
  22328. private _prepareRenderingGroup;
  22329. /**
  22330. * Add a sprite manager to the rendering manager in order to render it this frame.
  22331. * @param spriteManager Define the sprite manager to render
  22332. */
  22333. dispatchSprites(spriteManager: ISpriteManager): void;
  22334. /**
  22335. * Add a particle system to the rendering manager in order to render it this frame.
  22336. * @param particleSystem Define the particle system to render
  22337. */
  22338. dispatchParticles(particleSystem: IParticleSystem): void;
  22339. /**
  22340. * Add a submesh to the manager in order to render it this frame
  22341. * @param subMesh The submesh to dispatch
  22342. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  22343. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  22344. */
  22345. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  22346. /**
  22347. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  22348. * This allowed control for front to back rendering or reversly depending of the special needs.
  22349. *
  22350. * @param renderingGroupId The rendering group id corresponding to its index
  22351. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  22352. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  22353. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  22354. */
  22355. 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;
  22356. /**
  22357. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  22358. *
  22359. * @param renderingGroupId The rendering group id corresponding to its index
  22360. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  22361. * @param depth Automatically clears depth between groups if true and autoClear is true.
  22362. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  22363. */
  22364. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  22365. /**
  22366. * Gets the current auto clear configuration for one rendering group of the rendering
  22367. * manager.
  22368. * @param index the rendering group index to get the information for
  22369. * @returns The auto clear setup for the requested rendering group
  22370. */
  22371. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  22372. }
  22373. }
  22374. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  22375. import { Observable } from "babylonjs/Misc/observable";
  22376. import { SmartArray } from "babylonjs/Misc/smartArray";
  22377. import { Nullable } from "babylonjs/types";
  22378. import { Camera } from "babylonjs/Cameras/camera";
  22379. import { Scene } from "babylonjs/scene";
  22380. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  22381. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  22382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22383. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22384. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  22385. import { Texture } from "babylonjs/Materials/Textures/texture";
  22386. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  22387. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  22388. import "babylonjs/Engines/Extensions/engine.renderTarget";
  22389. import { Engine } from "babylonjs/Engines/engine";
  22390. /**
  22391. * This Helps creating a texture that will be created from a camera in your scene.
  22392. * It is basically a dynamic texture that could be used to create special effects for instance.
  22393. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  22394. */
  22395. export class RenderTargetTexture extends Texture {
  22396. isCube: boolean;
  22397. /**
  22398. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  22399. */
  22400. static readonly REFRESHRATE_RENDER_ONCE: number;
  22401. /**
  22402. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  22403. */
  22404. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  22405. /**
  22406. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  22407. * the central point of your effect and can save a lot of performances.
  22408. */
  22409. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  22410. /**
  22411. * Use this predicate to dynamically define the list of mesh you want to render.
  22412. * If set, the renderList property will be overwritten.
  22413. */
  22414. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  22415. private _renderList;
  22416. /**
  22417. * Use this list to define the list of mesh you want to render.
  22418. */
  22419. renderList: Nullable<Array<AbstractMesh>>;
  22420. private _hookArray;
  22421. /**
  22422. * Define if particles should be rendered in your texture.
  22423. */
  22424. renderParticles: boolean;
  22425. /**
  22426. * Define if sprites should be rendered in your texture.
  22427. */
  22428. renderSprites: boolean;
  22429. /**
  22430. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  22431. */
  22432. coordinatesMode: number;
  22433. /**
  22434. * Define the camera used to render the texture.
  22435. */
  22436. activeCamera: Nullable<Camera>;
  22437. /**
  22438. * Override the render function of the texture with your own one.
  22439. */
  22440. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  22441. /**
  22442. * Define if camera post processes should be use while rendering the texture.
  22443. */
  22444. useCameraPostProcesses: boolean;
  22445. /**
  22446. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  22447. */
  22448. ignoreCameraViewport: boolean;
  22449. private _postProcessManager;
  22450. private _postProcesses;
  22451. private _resizeObserver;
  22452. /**
  22453. * An event triggered when the texture is unbind.
  22454. */
  22455. onBeforeBindObservable: Observable<RenderTargetTexture>;
  22456. /**
  22457. * An event triggered when the texture is unbind.
  22458. */
  22459. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  22460. private _onAfterUnbindObserver;
  22461. /**
  22462. * Set a after unbind callback in the texture.
  22463. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  22464. */
  22465. onAfterUnbind: () => void;
  22466. /**
  22467. * An event triggered before rendering the texture
  22468. */
  22469. onBeforeRenderObservable: Observable<number>;
  22470. private _onBeforeRenderObserver;
  22471. /**
  22472. * Set a before render callback in the texture.
  22473. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  22474. */
  22475. onBeforeRender: (faceIndex: number) => void;
  22476. /**
  22477. * An event triggered after rendering the texture
  22478. */
  22479. onAfterRenderObservable: Observable<number>;
  22480. private _onAfterRenderObserver;
  22481. /**
  22482. * Set a after render callback in the texture.
  22483. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  22484. */
  22485. onAfterRender: (faceIndex: number) => void;
  22486. /**
  22487. * An event triggered after the texture clear
  22488. */
  22489. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  22490. private _onClearObserver;
  22491. /**
  22492. * Set a clear callback in the texture.
  22493. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  22494. */
  22495. onClear: (Engine: Engine) => void;
  22496. /**
  22497. * Define the clear color of the Render Target if it should be different from the scene.
  22498. */
  22499. clearColor: Color4;
  22500. protected _size: number | {
  22501. width: number;
  22502. height: number;
  22503. };
  22504. protected _initialSizeParameter: number | {
  22505. width: number;
  22506. height: number;
  22507. } | {
  22508. ratio: number;
  22509. };
  22510. protected _sizeRatio: Nullable<number>;
  22511. /** @hidden */
  22512. _generateMipMaps: boolean;
  22513. protected _renderingManager: RenderingManager;
  22514. /** @hidden */
  22515. _waitingRenderList: string[];
  22516. protected _doNotChangeAspectRatio: boolean;
  22517. protected _currentRefreshId: number;
  22518. protected _refreshRate: number;
  22519. protected _textureMatrix: Matrix;
  22520. protected _samples: number;
  22521. protected _renderTargetOptions: RenderTargetCreationOptions;
  22522. /**
  22523. * Gets render target creation options that were used.
  22524. */
  22525. readonly renderTargetOptions: RenderTargetCreationOptions;
  22526. protected _engine: Engine;
  22527. protected _onRatioRescale(): void;
  22528. /**
  22529. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  22530. * It must define where the camera used to render the texture is set
  22531. */
  22532. boundingBoxPosition: Vector3;
  22533. private _boundingBoxSize;
  22534. /**
  22535. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  22536. * When defined, the cubemap will switch to local mode
  22537. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  22538. * @example https://www.babylonjs-playground.com/#RNASML
  22539. */
  22540. boundingBoxSize: Vector3;
  22541. /**
  22542. * In case the RTT has been created with a depth texture, get the associated
  22543. * depth texture.
  22544. * Otherwise, return null.
  22545. */
  22546. depthStencilTexture: Nullable<InternalTexture>;
  22547. /**
  22548. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  22549. * or used a shadow, depth texture...
  22550. * @param name The friendly name of the texture
  22551. * @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)
  22552. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  22553. * @param generateMipMaps True if mip maps need to be generated after render.
  22554. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  22555. * @param type The type of the buffer in the RTT (int, half float, float...)
  22556. * @param isCube True if a cube texture needs to be created
  22557. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  22558. * @param generateDepthBuffer True to generate a depth buffer
  22559. * @param generateStencilBuffer True to generate a stencil buffer
  22560. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  22561. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  22562. * @param delayAllocation if the texture allocation should be delayed (default: false)
  22563. */
  22564. constructor(name: string, size: number | {
  22565. width: number;
  22566. height: number;
  22567. } | {
  22568. ratio: number;
  22569. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  22570. /**
  22571. * Creates a depth stencil texture.
  22572. * This is only available in WebGL 2 or with the depth texture extension available.
  22573. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  22574. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  22575. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  22576. */
  22577. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  22578. private _processSizeParameter;
  22579. /**
  22580. * Define the number of samples to use in case of MSAA.
  22581. * It defaults to one meaning no MSAA has been enabled.
  22582. */
  22583. samples: number;
  22584. /**
  22585. * Resets the refresh counter of the texture and start bak from scratch.
  22586. * Could be useful to regenerate the texture if it is setup to render only once.
  22587. */
  22588. resetRefreshCounter(): void;
  22589. /**
  22590. * Define the refresh rate of the texture or the rendering frequency.
  22591. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  22592. */
  22593. refreshRate: number;
  22594. /**
  22595. * Adds a post process to the render target rendering passes.
  22596. * @param postProcess define the post process to add
  22597. */
  22598. addPostProcess(postProcess: PostProcess): void;
  22599. /**
  22600. * Clear all the post processes attached to the render target
  22601. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  22602. */
  22603. clearPostProcesses(dispose?: boolean): void;
  22604. /**
  22605. * Remove one of the post process from the list of attached post processes to the texture
  22606. * @param postProcess define the post process to remove from the list
  22607. */
  22608. removePostProcess(postProcess: PostProcess): void;
  22609. /** @hidden */
  22610. _shouldRender(): boolean;
  22611. /**
  22612. * Gets the actual render size of the texture.
  22613. * @returns the width of the render size
  22614. */
  22615. getRenderSize(): number;
  22616. /**
  22617. * Gets the actual render width of the texture.
  22618. * @returns the width of the render size
  22619. */
  22620. getRenderWidth(): number;
  22621. /**
  22622. * Gets the actual render height of the texture.
  22623. * @returns the height of the render size
  22624. */
  22625. getRenderHeight(): number;
  22626. /**
  22627. * Get if the texture can be rescaled or not.
  22628. */
  22629. readonly canRescale: boolean;
  22630. /**
  22631. * Resize the texture using a ratio.
  22632. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  22633. */
  22634. scale(ratio: number): void;
  22635. /**
  22636. * Get the texture reflection matrix used to rotate/transform the reflection.
  22637. * @returns the reflection matrix
  22638. */
  22639. getReflectionTextureMatrix(): Matrix;
  22640. /**
  22641. * Resize the texture to a new desired size.
  22642. * Be carrefull as it will recreate all the data in the new texture.
  22643. * @param size Define the new size. It can be:
  22644. * - a number for squared texture,
  22645. * - an object containing { width: number, height: number }
  22646. * - or an object containing a ratio { ratio: number }
  22647. */
  22648. resize(size: number | {
  22649. width: number;
  22650. height: number;
  22651. } | {
  22652. ratio: number;
  22653. }): void;
  22654. /**
  22655. * Renders all the objects from the render list into the texture.
  22656. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  22657. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  22658. */
  22659. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  22660. private _bestReflectionRenderTargetDimension;
  22661. /**
  22662. * @hidden
  22663. * @param faceIndex face index to bind to if this is a cubetexture
  22664. */
  22665. _bindFrameBuffer(faceIndex?: number): void;
  22666. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  22667. private renderToTarget;
  22668. /**
  22669. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  22670. * This allowed control for front to back rendering or reversly depending of the special needs.
  22671. *
  22672. * @param renderingGroupId The rendering group id corresponding to its index
  22673. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  22674. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  22675. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  22676. */
  22677. 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;
  22678. /**
  22679. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  22680. *
  22681. * @param renderingGroupId The rendering group id corresponding to its index
  22682. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  22683. */
  22684. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  22685. /**
  22686. * Clones the texture.
  22687. * @returns the cloned texture
  22688. */
  22689. clone(): RenderTargetTexture;
  22690. /**
  22691. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  22692. * @returns The JSON representation of the texture
  22693. */
  22694. serialize(): any;
  22695. /**
  22696. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  22697. */
  22698. disposeFramebufferObjects(): void;
  22699. /**
  22700. * Dispose the texture and release its associated resources.
  22701. */
  22702. dispose(): void;
  22703. /** @hidden */
  22704. _rebuild(): void;
  22705. /**
  22706. * Clear the info related to rendering groups preventing retention point in material dispose.
  22707. */
  22708. freeRenderingGroups(): void;
  22709. /**
  22710. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  22711. * @returns the view count
  22712. */
  22713. getViewCount(): number;
  22714. }
  22715. }
  22716. declare module "babylonjs/Materials/material" {
  22717. import { IAnimatable } from "babylonjs/Misc/tools";
  22718. import { SmartArray } from "babylonjs/Misc/smartArray";
  22719. import { Observable } from "babylonjs/Misc/observable";
  22720. import { Nullable } from "babylonjs/types";
  22721. import { Scene } from "babylonjs/scene";
  22722. import { Matrix } from "babylonjs/Maths/math";
  22723. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22724. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22725. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22726. import { Effect } from "babylonjs/Materials/effect";
  22727. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22728. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22729. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22730. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22731. import { Mesh } from "babylonjs/Meshes/mesh";
  22732. import { Animation } from "babylonjs/Animations/animation";
  22733. /**
  22734. * Base class for the main features of a material in Babylon.js
  22735. */
  22736. export class Material implements IAnimatable {
  22737. /**
  22738. * Returns the triangle fill mode
  22739. */
  22740. static readonly TriangleFillMode: number;
  22741. /**
  22742. * Returns the wireframe mode
  22743. */
  22744. static readonly WireFrameFillMode: number;
  22745. /**
  22746. * Returns the point fill mode
  22747. */
  22748. static readonly PointFillMode: number;
  22749. /**
  22750. * Returns the point list draw mode
  22751. */
  22752. static readonly PointListDrawMode: number;
  22753. /**
  22754. * Returns the line list draw mode
  22755. */
  22756. static readonly LineListDrawMode: number;
  22757. /**
  22758. * Returns the line loop draw mode
  22759. */
  22760. static readonly LineLoopDrawMode: number;
  22761. /**
  22762. * Returns the line strip draw mode
  22763. */
  22764. static readonly LineStripDrawMode: number;
  22765. /**
  22766. * Returns the triangle strip draw mode
  22767. */
  22768. static readonly TriangleStripDrawMode: number;
  22769. /**
  22770. * Returns the triangle fan draw mode
  22771. */
  22772. static readonly TriangleFanDrawMode: number;
  22773. /**
  22774. * Stores the clock-wise side orientation
  22775. */
  22776. static readonly ClockWiseSideOrientation: number;
  22777. /**
  22778. * Stores the counter clock-wise side orientation
  22779. */
  22780. static readonly CounterClockWiseSideOrientation: number;
  22781. /**
  22782. * The dirty texture flag value
  22783. */
  22784. static readonly TextureDirtyFlag: number;
  22785. /**
  22786. * The dirty light flag value
  22787. */
  22788. static readonly LightDirtyFlag: number;
  22789. /**
  22790. * The dirty fresnel flag value
  22791. */
  22792. static readonly FresnelDirtyFlag: number;
  22793. /**
  22794. * The dirty attribute flag value
  22795. */
  22796. static readonly AttributesDirtyFlag: number;
  22797. /**
  22798. * The dirty misc flag value
  22799. */
  22800. static readonly MiscDirtyFlag: number;
  22801. /**
  22802. * The all dirty flag value
  22803. */
  22804. static readonly AllDirtyFlag: number;
  22805. /**
  22806. * The ID of the material
  22807. */
  22808. id: string;
  22809. /**
  22810. * Gets or sets the unique id of the material
  22811. */
  22812. uniqueId: number;
  22813. /**
  22814. * The name of the material
  22815. */
  22816. name: string;
  22817. /**
  22818. * Gets or sets user defined metadata
  22819. */
  22820. metadata: any;
  22821. /**
  22822. * For internal use only. Please do not use.
  22823. */
  22824. reservedDataStore: any;
  22825. /**
  22826. * Specifies if the ready state should be checked on each call
  22827. */
  22828. checkReadyOnEveryCall: boolean;
  22829. /**
  22830. * Specifies if the ready state should be checked once
  22831. */
  22832. checkReadyOnlyOnce: boolean;
  22833. /**
  22834. * The state of the material
  22835. */
  22836. state: string;
  22837. /**
  22838. * The alpha value of the material
  22839. */
  22840. protected _alpha: number;
  22841. /**
  22842. * List of inspectable custom properties (used by the Inspector)
  22843. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22844. */
  22845. inspectableCustomProperties: IInspectable[];
  22846. /**
  22847. * Sets the alpha value of the material
  22848. */
  22849. /**
  22850. * Gets the alpha value of the material
  22851. */
  22852. alpha: number;
  22853. /**
  22854. * Specifies if back face culling is enabled
  22855. */
  22856. protected _backFaceCulling: boolean;
  22857. /**
  22858. * Sets the back-face culling state
  22859. */
  22860. /**
  22861. * Gets the back-face culling state
  22862. */
  22863. backFaceCulling: boolean;
  22864. /**
  22865. * Stores the value for side orientation
  22866. */
  22867. sideOrientation: number;
  22868. /**
  22869. * Callback triggered when the material is compiled
  22870. */
  22871. onCompiled: Nullable<(effect: Effect) => void>;
  22872. /**
  22873. * Callback triggered when an error occurs
  22874. */
  22875. onError: Nullable<(effect: Effect, errors: string) => void>;
  22876. /**
  22877. * Callback triggered to get the render target textures
  22878. */
  22879. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22880. /**
  22881. * Gets a boolean indicating that current material needs to register RTT
  22882. */
  22883. readonly hasRenderTargetTextures: boolean;
  22884. /**
  22885. * Specifies if the material should be serialized
  22886. */
  22887. doNotSerialize: boolean;
  22888. /**
  22889. * @hidden
  22890. */
  22891. _storeEffectOnSubMeshes: boolean;
  22892. /**
  22893. * Stores the animations for the material
  22894. */
  22895. animations: Nullable<Array<Animation>>;
  22896. /**
  22897. * An event triggered when the material is disposed
  22898. */
  22899. onDisposeObservable: Observable<Material>;
  22900. /**
  22901. * An observer which watches for dispose events
  22902. */
  22903. private _onDisposeObserver;
  22904. private _onUnBindObservable;
  22905. /**
  22906. * Called during a dispose event
  22907. */
  22908. onDispose: () => void;
  22909. private _onBindObservable;
  22910. /**
  22911. * An event triggered when the material is bound
  22912. */
  22913. readonly onBindObservable: Observable<AbstractMesh>;
  22914. /**
  22915. * An observer which watches for bind events
  22916. */
  22917. private _onBindObserver;
  22918. /**
  22919. * Called during a bind event
  22920. */
  22921. onBind: (Mesh: AbstractMesh) => void;
  22922. /**
  22923. * An event triggered when the material is unbound
  22924. */
  22925. readonly onUnBindObservable: Observable<Material>;
  22926. /**
  22927. * Stores the value of the alpha mode
  22928. */
  22929. private _alphaMode;
  22930. /**
  22931. * Sets the value of the alpha mode.
  22932. *
  22933. * | Value | Type | Description |
  22934. * | --- | --- | --- |
  22935. * | 0 | ALPHA_DISABLE | |
  22936. * | 1 | ALPHA_ADD | |
  22937. * | 2 | ALPHA_COMBINE | |
  22938. * | 3 | ALPHA_SUBTRACT | |
  22939. * | 4 | ALPHA_MULTIPLY | |
  22940. * | 5 | ALPHA_MAXIMIZED | |
  22941. * | 6 | ALPHA_ONEONE | |
  22942. * | 7 | ALPHA_PREMULTIPLIED | |
  22943. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22944. * | 9 | ALPHA_INTERPOLATE | |
  22945. * | 10 | ALPHA_SCREENMODE | |
  22946. *
  22947. */
  22948. /**
  22949. * Gets the value of the alpha mode
  22950. */
  22951. alphaMode: number;
  22952. /**
  22953. * Stores the state of the need depth pre-pass value
  22954. */
  22955. private _needDepthPrePass;
  22956. /**
  22957. * Sets the need depth pre-pass value
  22958. */
  22959. /**
  22960. * Gets the depth pre-pass value
  22961. */
  22962. needDepthPrePass: boolean;
  22963. /**
  22964. * Specifies if depth writing should be disabled
  22965. */
  22966. disableDepthWrite: boolean;
  22967. /**
  22968. * Specifies if depth writing should be forced
  22969. */
  22970. forceDepthWrite: boolean;
  22971. /**
  22972. * Specifies if there should be a separate pass for culling
  22973. */
  22974. separateCullingPass: boolean;
  22975. /**
  22976. * Stores the state specifing if fog should be enabled
  22977. */
  22978. private _fogEnabled;
  22979. /**
  22980. * Sets the state for enabling fog
  22981. */
  22982. /**
  22983. * Gets the value of the fog enabled state
  22984. */
  22985. fogEnabled: boolean;
  22986. /**
  22987. * Stores the size of points
  22988. */
  22989. pointSize: number;
  22990. /**
  22991. * Stores the z offset value
  22992. */
  22993. zOffset: number;
  22994. /**
  22995. * Gets a value specifying if wireframe mode is enabled
  22996. */
  22997. /**
  22998. * Sets the state of wireframe mode
  22999. */
  23000. wireframe: boolean;
  23001. /**
  23002. * Gets the value specifying if point clouds are enabled
  23003. */
  23004. /**
  23005. * Sets the state of point cloud mode
  23006. */
  23007. pointsCloud: boolean;
  23008. /**
  23009. * Gets the material fill mode
  23010. */
  23011. /**
  23012. * Sets the material fill mode
  23013. */
  23014. fillMode: number;
  23015. /**
  23016. * @hidden
  23017. * Stores the effects for the material
  23018. */
  23019. _effect: Nullable<Effect>;
  23020. /**
  23021. * @hidden
  23022. * Specifies if the material was previously ready
  23023. */
  23024. _wasPreviouslyReady: boolean;
  23025. /**
  23026. * Specifies if uniform buffers should be used
  23027. */
  23028. private _useUBO;
  23029. /**
  23030. * Stores a reference to the scene
  23031. */
  23032. private _scene;
  23033. /**
  23034. * Stores the fill mode state
  23035. */
  23036. private _fillMode;
  23037. /**
  23038. * Specifies if the depth write state should be cached
  23039. */
  23040. private _cachedDepthWriteState;
  23041. /**
  23042. * Stores the uniform buffer
  23043. */
  23044. protected _uniformBuffer: UniformBuffer;
  23045. /** @hidden */
  23046. _indexInSceneMaterialArray: number;
  23047. /** @hidden */
  23048. meshMap: Nullable<{
  23049. [id: string]: AbstractMesh | undefined;
  23050. }>;
  23051. /**
  23052. * Creates a material instance
  23053. * @param name defines the name of the material
  23054. * @param scene defines the scene to reference
  23055. * @param doNotAdd specifies if the material should be added to the scene
  23056. */
  23057. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  23058. /**
  23059. * Returns a string representation of the current material
  23060. * @param fullDetails defines a boolean indicating which levels of logging is desired
  23061. * @returns a string with material information
  23062. */
  23063. toString(fullDetails?: boolean): string;
  23064. /**
  23065. * Gets the class name of the material
  23066. * @returns a string with the class name of the material
  23067. */
  23068. getClassName(): string;
  23069. /**
  23070. * Specifies if updates for the material been locked
  23071. */
  23072. readonly isFrozen: boolean;
  23073. /**
  23074. * Locks updates for the material
  23075. */
  23076. freeze(): void;
  23077. /**
  23078. * Unlocks updates for the material
  23079. */
  23080. unfreeze(): void;
  23081. /**
  23082. * Specifies if the material is ready to be used
  23083. * @param mesh defines the mesh to check
  23084. * @param useInstances specifies if instances should be used
  23085. * @returns a boolean indicating if the material is ready to be used
  23086. */
  23087. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  23088. /**
  23089. * Specifies that the submesh is ready to be used
  23090. * @param mesh defines the mesh to check
  23091. * @param subMesh defines which submesh to check
  23092. * @param useInstances specifies that instances should be used
  23093. * @returns a boolean indicating that the submesh is ready or not
  23094. */
  23095. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  23096. /**
  23097. * Returns the material effect
  23098. * @returns the effect associated with the material
  23099. */
  23100. getEffect(): Nullable<Effect>;
  23101. /**
  23102. * Returns the current scene
  23103. * @returns a Scene
  23104. */
  23105. getScene(): Scene;
  23106. /**
  23107. * Specifies if the material will require alpha blending
  23108. * @returns a boolean specifying if alpha blending is needed
  23109. */
  23110. needAlphaBlending(): boolean;
  23111. /**
  23112. * Specifies if the mesh will require alpha blending
  23113. * @param mesh defines the mesh to check
  23114. * @returns a boolean specifying if alpha blending is needed for the mesh
  23115. */
  23116. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  23117. /**
  23118. * Specifies if this material should be rendered in alpha test mode
  23119. * @returns a boolean specifying if an alpha test is needed.
  23120. */
  23121. needAlphaTesting(): boolean;
  23122. /**
  23123. * Gets the texture used for the alpha test
  23124. * @returns the texture to use for alpha testing
  23125. */
  23126. getAlphaTestTexture(): Nullable<BaseTexture>;
  23127. /**
  23128. * Marks the material to indicate that it needs to be re-calculated
  23129. */
  23130. markDirty(): void;
  23131. /** @hidden */
  23132. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  23133. /**
  23134. * Binds the material to the mesh
  23135. * @param world defines the world transformation matrix
  23136. * @param mesh defines the mesh to bind the material to
  23137. */
  23138. bind(world: Matrix, mesh?: Mesh): void;
  23139. /**
  23140. * Binds the submesh to the material
  23141. * @param world defines the world transformation matrix
  23142. * @param mesh defines the mesh containing the submesh
  23143. * @param subMesh defines the submesh to bind the material to
  23144. */
  23145. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23146. /**
  23147. * Binds the world matrix to the material
  23148. * @param world defines the world transformation matrix
  23149. */
  23150. bindOnlyWorldMatrix(world: Matrix): void;
  23151. /**
  23152. * Binds the scene's uniform buffer to the effect.
  23153. * @param effect defines the effect to bind to the scene uniform buffer
  23154. * @param sceneUbo defines the uniform buffer storing scene data
  23155. */
  23156. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  23157. /**
  23158. * Binds the view matrix to the effect
  23159. * @param effect defines the effect to bind the view matrix to
  23160. */
  23161. bindView(effect: Effect): void;
  23162. /**
  23163. * Binds the view projection matrix to the effect
  23164. * @param effect defines the effect to bind the view projection matrix to
  23165. */
  23166. bindViewProjection(effect: Effect): void;
  23167. /**
  23168. * Specifies if material alpha testing should be turned on for the mesh
  23169. * @param mesh defines the mesh to check
  23170. */
  23171. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  23172. /**
  23173. * Processes to execute after binding the material to a mesh
  23174. * @param mesh defines the rendered mesh
  23175. */
  23176. protected _afterBind(mesh?: Mesh): void;
  23177. /**
  23178. * Unbinds the material from the mesh
  23179. */
  23180. unbind(): void;
  23181. /**
  23182. * Gets the active textures from the material
  23183. * @returns an array of textures
  23184. */
  23185. getActiveTextures(): BaseTexture[];
  23186. /**
  23187. * Specifies if the material uses a texture
  23188. * @param texture defines the texture to check against the material
  23189. * @returns a boolean specifying if the material uses the texture
  23190. */
  23191. hasTexture(texture: BaseTexture): boolean;
  23192. /**
  23193. * Makes a duplicate of the material, and gives it a new name
  23194. * @param name defines the new name for the duplicated material
  23195. * @returns the cloned material
  23196. */
  23197. clone(name: string): Nullable<Material>;
  23198. /**
  23199. * Gets the meshes bound to the material
  23200. * @returns an array of meshes bound to the material
  23201. */
  23202. getBindedMeshes(): AbstractMesh[];
  23203. /**
  23204. * Force shader compilation
  23205. * @param mesh defines the mesh associated with this material
  23206. * @param onCompiled defines a function to execute once the material is compiled
  23207. * @param options defines the options to configure the compilation
  23208. */
  23209. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  23210. clipPlane: boolean;
  23211. }>): void;
  23212. /**
  23213. * Force shader compilation
  23214. * @param mesh defines the mesh that will use this material
  23215. * @param options defines additional options for compiling the shaders
  23216. * @returns a promise that resolves when the compilation completes
  23217. */
  23218. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  23219. clipPlane: boolean;
  23220. }>): Promise<void>;
  23221. private static readonly _AllDirtyCallBack;
  23222. private static readonly _ImageProcessingDirtyCallBack;
  23223. private static readonly _TextureDirtyCallBack;
  23224. private static readonly _FresnelDirtyCallBack;
  23225. private static readonly _MiscDirtyCallBack;
  23226. private static readonly _LightsDirtyCallBack;
  23227. private static readonly _AttributeDirtyCallBack;
  23228. private static _FresnelAndMiscDirtyCallBack;
  23229. private static _TextureAndMiscDirtyCallBack;
  23230. private static readonly _DirtyCallbackArray;
  23231. private static readonly _RunDirtyCallBacks;
  23232. /**
  23233. * Marks a define in the material to indicate that it needs to be re-computed
  23234. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  23235. */
  23236. markAsDirty(flag: number): void;
  23237. /**
  23238. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  23239. * @param func defines a function which checks material defines against the submeshes
  23240. */
  23241. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  23242. /**
  23243. * Indicates that we need to re-calculated for all submeshes
  23244. */
  23245. protected _markAllSubMeshesAsAllDirty(): void;
  23246. /**
  23247. * Indicates that image processing needs to be re-calculated for all submeshes
  23248. */
  23249. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  23250. /**
  23251. * Indicates that textures need to be re-calculated for all submeshes
  23252. */
  23253. protected _markAllSubMeshesAsTexturesDirty(): void;
  23254. /**
  23255. * Indicates that fresnel needs to be re-calculated for all submeshes
  23256. */
  23257. protected _markAllSubMeshesAsFresnelDirty(): void;
  23258. /**
  23259. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  23260. */
  23261. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  23262. /**
  23263. * Indicates that lights need to be re-calculated for all submeshes
  23264. */
  23265. protected _markAllSubMeshesAsLightsDirty(): void;
  23266. /**
  23267. * Indicates that attributes need to be re-calculated for all submeshes
  23268. */
  23269. protected _markAllSubMeshesAsAttributesDirty(): void;
  23270. /**
  23271. * Indicates that misc needs to be re-calculated for all submeshes
  23272. */
  23273. protected _markAllSubMeshesAsMiscDirty(): void;
  23274. /**
  23275. * Indicates that textures and misc need to be re-calculated for all submeshes
  23276. */
  23277. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  23278. /**
  23279. * Disposes the material
  23280. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23281. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23282. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23283. */
  23284. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23285. /** @hidden */
  23286. private releaseVertexArrayObject;
  23287. /**
  23288. * Serializes this material
  23289. * @returns the serialized material object
  23290. */
  23291. serialize(): any;
  23292. /**
  23293. * Creates a material from parsed material data
  23294. * @param parsedMaterial defines parsed material data
  23295. * @param scene defines the hosting scene
  23296. * @param rootUrl defines the root URL to use to load textures
  23297. * @returns a new material
  23298. */
  23299. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  23300. }
  23301. }
  23302. declare module "babylonjs/Meshes/subMesh" {
  23303. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  23304. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  23305. import { Engine } from "babylonjs/Engines/engine";
  23306. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  23307. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23308. import { Effect } from "babylonjs/Materials/effect";
  23309. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23310. import { Collider } from "babylonjs/Collisions/collider";
  23311. import { Material } from "babylonjs/Materials/material";
  23312. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23314. import { Mesh } from "babylonjs/Meshes/mesh";
  23315. import { Ray } from "babylonjs/Culling/ray";
  23316. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23317. /**
  23318. * Base class for submeshes
  23319. */
  23320. export class BaseSubMesh {
  23321. /** @hidden */
  23322. _materialDefines: Nullable<MaterialDefines>;
  23323. /** @hidden */
  23324. _materialEffect: Nullable<Effect>;
  23325. /**
  23326. * Gets associated effect
  23327. */
  23328. readonly effect: Nullable<Effect>;
  23329. /**
  23330. * Sets associated effect (effect used to render this submesh)
  23331. * @param effect defines the effect to associate with
  23332. * @param defines defines the set of defines used to compile this effect
  23333. */
  23334. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23335. }
  23336. /**
  23337. * Defines a subdivision inside a mesh
  23338. */
  23339. export class SubMesh extends BaseSubMesh implements ICullable {
  23340. /** the material index to use */
  23341. materialIndex: number;
  23342. /** vertex index start */
  23343. verticesStart: number;
  23344. /** vertices count */
  23345. verticesCount: number;
  23346. /** index start */
  23347. indexStart: number;
  23348. /** indices count */
  23349. indexCount: number;
  23350. /** @hidden */
  23351. _linesIndexCount: number;
  23352. private _mesh;
  23353. private _renderingMesh;
  23354. private _boundingInfo;
  23355. private _linesIndexBuffer;
  23356. /** @hidden */
  23357. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23358. /** @hidden */
  23359. _trianglePlanes: Plane[];
  23360. /** @hidden */
  23361. _lastColliderTransformMatrix: Nullable<Matrix>;
  23362. /** @hidden */
  23363. _renderId: number;
  23364. /** @hidden */
  23365. _alphaIndex: number;
  23366. /** @hidden */
  23367. _distanceToCamera: number;
  23368. /** @hidden */
  23369. _id: number;
  23370. private _currentMaterial;
  23371. /**
  23372. * Add a new submesh to a mesh
  23373. * @param materialIndex defines the material index to use
  23374. * @param verticesStart defines vertex index start
  23375. * @param verticesCount defines vertices count
  23376. * @param indexStart defines index start
  23377. * @param indexCount defines indices count
  23378. * @param mesh defines the parent mesh
  23379. * @param renderingMesh defines an optional rendering mesh
  23380. * @param createBoundingBox defines if bounding box should be created for this submesh
  23381. * @returns the new submesh
  23382. */
  23383. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23384. /**
  23385. * Creates a new submesh
  23386. * @param materialIndex defines the material index to use
  23387. * @param verticesStart defines vertex index start
  23388. * @param verticesCount defines vertices count
  23389. * @param indexStart defines index start
  23390. * @param indexCount defines indices count
  23391. * @param mesh defines the parent mesh
  23392. * @param renderingMesh defines an optional rendering mesh
  23393. * @param createBoundingBox defines if bounding box should be created for this submesh
  23394. */
  23395. constructor(
  23396. /** the material index to use */
  23397. materialIndex: number,
  23398. /** vertex index start */
  23399. verticesStart: number,
  23400. /** vertices count */
  23401. verticesCount: number,
  23402. /** index start */
  23403. indexStart: number,
  23404. /** indices count */
  23405. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23406. /**
  23407. * Returns true if this submesh covers the entire parent mesh
  23408. * @ignorenaming
  23409. */
  23410. readonly IsGlobal: boolean;
  23411. /**
  23412. * Returns the submesh BoudingInfo object
  23413. * @returns current bounding info (or mesh's one if the submesh is global)
  23414. */
  23415. getBoundingInfo(): BoundingInfo;
  23416. /**
  23417. * Sets the submesh BoundingInfo
  23418. * @param boundingInfo defines the new bounding info to use
  23419. * @returns the SubMesh
  23420. */
  23421. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23422. /**
  23423. * Returns the mesh of the current submesh
  23424. * @return the parent mesh
  23425. */
  23426. getMesh(): AbstractMesh;
  23427. /**
  23428. * Returns the rendering mesh of the submesh
  23429. * @returns the rendering mesh (could be different from parent mesh)
  23430. */
  23431. getRenderingMesh(): Mesh;
  23432. /**
  23433. * Returns the submesh material
  23434. * @returns null or the current material
  23435. */
  23436. getMaterial(): Nullable<Material>;
  23437. /**
  23438. * Sets a new updated BoundingInfo object to the submesh
  23439. * @param data defines an optional position array to use to determine the bounding info
  23440. * @returns the SubMesh
  23441. */
  23442. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  23443. /** @hidden */
  23444. _checkCollision(collider: Collider): boolean;
  23445. /**
  23446. * Updates the submesh BoundingInfo
  23447. * @param world defines the world matrix to use to update the bounding info
  23448. * @returns the submesh
  23449. */
  23450. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  23451. /**
  23452. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23453. * @param frustumPlanes defines the frustum planes
  23454. * @returns true if the submesh is intersecting with the frustum
  23455. */
  23456. isInFrustum(frustumPlanes: Plane[]): boolean;
  23457. /**
  23458. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  23459. * @param frustumPlanes defines the frustum planes
  23460. * @returns true if the submesh is inside the frustum
  23461. */
  23462. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23463. /**
  23464. * Renders the submesh
  23465. * @param enableAlphaMode defines if alpha needs to be used
  23466. * @returns the submesh
  23467. */
  23468. render(enableAlphaMode: boolean): SubMesh;
  23469. /**
  23470. * @hidden
  23471. */
  23472. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  23473. /**
  23474. * Checks if the submesh intersects with a ray
  23475. * @param ray defines the ray to test
  23476. * @returns true is the passed ray intersects the submesh bounding box
  23477. */
  23478. canIntersects(ray: Ray): boolean;
  23479. /**
  23480. * Intersects current submesh with a ray
  23481. * @param ray defines the ray to test
  23482. * @param positions defines mesh's positions array
  23483. * @param indices defines mesh's indices array
  23484. * @param fastCheck defines if only bounding info should be used
  23485. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  23486. * @returns intersection info or null if no intersection
  23487. */
  23488. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  23489. /** @hidden */
  23490. private _intersectLines;
  23491. /** @hidden */
  23492. private _intersectUnIndexedLines;
  23493. /** @hidden */
  23494. private _intersectTriangles;
  23495. /** @hidden */
  23496. private _intersectUnIndexedTriangles;
  23497. /** @hidden */
  23498. _rebuild(): void;
  23499. /**
  23500. * Creates a new submesh from the passed mesh
  23501. * @param newMesh defines the new hosting mesh
  23502. * @param newRenderingMesh defines an optional rendering mesh
  23503. * @returns the new submesh
  23504. */
  23505. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23506. /**
  23507. * Release associated resources
  23508. */
  23509. dispose(): void;
  23510. /**
  23511. * Gets the class name
  23512. * @returns the string "SubMesh".
  23513. */
  23514. getClassName(): string;
  23515. /**
  23516. * Creates a new submesh from indices data
  23517. * @param materialIndex the index of the main mesh material
  23518. * @param startIndex the index where to start the copy in the mesh indices array
  23519. * @param indexCount the number of indices to copy then from the startIndex
  23520. * @param mesh the main mesh to create the submesh from
  23521. * @param renderingMesh the optional rendering mesh
  23522. * @returns a new submesh
  23523. */
  23524. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23525. }
  23526. }
  23527. declare module "babylonjs/Meshes/geometry" {
  23528. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  23529. import { Scene } from "babylonjs/scene";
  23530. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  23531. import { Engine } from "babylonjs/Engines/engine";
  23532. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  23533. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23534. import { Effect } from "babylonjs/Materials/effect";
  23535. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23536. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23537. import { Mesh } from "babylonjs/Meshes/mesh";
  23538. /**
  23539. * Class used to store geometry data (vertex buffers + index buffer)
  23540. */
  23541. export class Geometry implements IGetSetVerticesData {
  23542. /**
  23543. * Gets or sets the ID of the geometry
  23544. */
  23545. id: string;
  23546. /**
  23547. * Gets or sets the unique ID of the geometry
  23548. */
  23549. uniqueId: number;
  23550. /**
  23551. * Gets the delay loading state of the geometry (none by default which means not delayed)
  23552. */
  23553. delayLoadState: number;
  23554. /**
  23555. * Gets the file containing the data to load when running in delay load state
  23556. */
  23557. delayLoadingFile: Nullable<string>;
  23558. /**
  23559. * Callback called when the geometry is updated
  23560. */
  23561. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  23562. private _scene;
  23563. private _engine;
  23564. private _meshes;
  23565. private _totalVertices;
  23566. /** @hidden */
  23567. _indices: IndicesArray;
  23568. /** @hidden */
  23569. _vertexBuffers: {
  23570. [key: string]: VertexBuffer;
  23571. };
  23572. private _isDisposed;
  23573. private _extend;
  23574. private _boundingBias;
  23575. /** @hidden */
  23576. _delayInfo: Array<string>;
  23577. private _indexBuffer;
  23578. private _indexBufferIsUpdatable;
  23579. /** @hidden */
  23580. _boundingInfo: Nullable<BoundingInfo>;
  23581. /** @hidden */
  23582. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  23583. /** @hidden */
  23584. _softwareSkinningFrameId: number;
  23585. private _vertexArrayObjects;
  23586. private _updatable;
  23587. /** @hidden */
  23588. _positions: Nullable<Vector3[]>;
  23589. /**
  23590. * 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
  23591. */
  23592. /**
  23593. * 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
  23594. */
  23595. boundingBias: Vector2;
  23596. /**
  23597. * Static function used to attach a new empty geometry to a mesh
  23598. * @param mesh defines the mesh to attach the geometry to
  23599. * @returns the new Geometry
  23600. */
  23601. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  23602. /**
  23603. * Creates a new geometry
  23604. * @param id defines the unique ID
  23605. * @param scene defines the hosting scene
  23606. * @param vertexData defines the VertexData used to get geometry data
  23607. * @param updatable defines if geometry must be updatable (false by default)
  23608. * @param mesh defines the mesh that will be associated with the geometry
  23609. */
  23610. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  23611. /**
  23612. * Gets the current extend of the geometry
  23613. */
  23614. readonly extend: {
  23615. minimum: Vector3;
  23616. maximum: Vector3;
  23617. };
  23618. /**
  23619. * Gets the hosting scene
  23620. * @returns the hosting Scene
  23621. */
  23622. getScene(): Scene;
  23623. /**
  23624. * Gets the hosting engine
  23625. * @returns the hosting Engine
  23626. */
  23627. getEngine(): Engine;
  23628. /**
  23629. * Defines if the geometry is ready to use
  23630. * @returns true if the geometry is ready to be used
  23631. */
  23632. isReady(): boolean;
  23633. /**
  23634. * Gets a value indicating that the geometry should not be serialized
  23635. */
  23636. readonly doNotSerialize: boolean;
  23637. /** @hidden */
  23638. _rebuild(): void;
  23639. /**
  23640. * Affects all geometry data in one call
  23641. * @param vertexData defines the geometry data
  23642. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23643. */
  23644. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23645. /**
  23646. * Set specific vertex data
  23647. * @param kind defines the data kind (Position, normal, etc...)
  23648. * @param data defines the vertex data to use
  23649. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23650. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23651. */
  23652. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23653. /**
  23654. * Removes a specific vertex data
  23655. * @param kind defines the data kind (Position, normal, etc...)
  23656. */
  23657. removeVerticesData(kind: string): void;
  23658. /**
  23659. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23660. * @param buffer defines the vertex buffer to use
  23661. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23662. */
  23663. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23664. /**
  23665. * Update a specific vertex buffer
  23666. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  23667. * It will do nothing if the buffer is not updatable
  23668. * @param kind defines the data kind (Position, normal, etc...)
  23669. * @param data defines the data to use
  23670. * @param offset defines the offset in the target buffer where to store the data
  23671. * @param useBytes set to true if the offset is in bytes
  23672. */
  23673. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23674. /**
  23675. * Update a specific vertex buffer
  23676. * This function will create a new buffer if the current one is not updatable
  23677. * @param kind defines the data kind (Position, normal, etc...)
  23678. * @param data defines the data to use
  23679. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23680. */
  23681. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23682. private _updateBoundingInfo;
  23683. /** @hidden */
  23684. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  23685. /**
  23686. * Gets total number of vertices
  23687. * @returns the total number of vertices
  23688. */
  23689. getTotalVertices(): number;
  23690. /**
  23691. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23692. * @param kind defines the data kind (Position, normal, etc...)
  23693. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23694. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23695. * @returns a float array containing vertex data
  23696. */
  23697. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23698. /**
  23699. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23700. * @param kind defines the data kind (Position, normal, etc...)
  23701. * @returns true if the vertex buffer with the specified kind is updatable
  23702. */
  23703. isVertexBufferUpdatable(kind: string): boolean;
  23704. /**
  23705. * Gets a specific vertex buffer
  23706. * @param kind defines the data kind (Position, normal, etc...)
  23707. * @returns a VertexBuffer
  23708. */
  23709. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23710. /**
  23711. * Returns all vertex buffers
  23712. * @return an object holding all vertex buffers indexed by kind
  23713. */
  23714. getVertexBuffers(): Nullable<{
  23715. [key: string]: VertexBuffer;
  23716. }>;
  23717. /**
  23718. * Gets a boolean indicating if specific vertex buffer is present
  23719. * @param kind defines the data kind (Position, normal, etc...)
  23720. * @returns true if data is present
  23721. */
  23722. isVerticesDataPresent(kind: string): boolean;
  23723. /**
  23724. * Gets a list of all attached data kinds (Position, normal, etc...)
  23725. * @returns a list of string containing all kinds
  23726. */
  23727. getVerticesDataKinds(): string[];
  23728. /**
  23729. * Update index buffer
  23730. * @param indices defines the indices to store in the index buffer
  23731. * @param offset defines the offset in the target buffer where to store the data
  23732. * @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)
  23733. */
  23734. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23735. /**
  23736. * Creates a new index buffer
  23737. * @param indices defines the indices to store in the index buffer
  23738. * @param totalVertices defines the total number of vertices (could be null)
  23739. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23740. */
  23741. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23742. /**
  23743. * Return the total number of indices
  23744. * @returns the total number of indices
  23745. */
  23746. getTotalIndices(): number;
  23747. /**
  23748. * Gets the index buffer array
  23749. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23750. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23751. * @returns the index buffer array
  23752. */
  23753. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23754. /**
  23755. * Gets the index buffer
  23756. * @return the index buffer
  23757. */
  23758. getIndexBuffer(): Nullable<DataBuffer>;
  23759. /** @hidden */
  23760. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23761. /**
  23762. * Release the associated resources for a specific mesh
  23763. * @param mesh defines the source mesh
  23764. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23765. */
  23766. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23767. /**
  23768. * Apply current geometry to a given mesh
  23769. * @param mesh defines the mesh to apply geometry to
  23770. */
  23771. applyToMesh(mesh: Mesh): void;
  23772. private _updateExtend;
  23773. private _applyToMesh;
  23774. private notifyUpdate;
  23775. /**
  23776. * Load the geometry if it was flagged as delay loaded
  23777. * @param scene defines the hosting scene
  23778. * @param onLoaded defines a callback called when the geometry is loaded
  23779. */
  23780. load(scene: Scene, onLoaded?: () => void): void;
  23781. private _queueLoad;
  23782. /**
  23783. * Invert the geometry to move from a right handed system to a left handed one.
  23784. */
  23785. toLeftHanded(): void;
  23786. /** @hidden */
  23787. _resetPointsArrayCache(): void;
  23788. /** @hidden */
  23789. _generatePointsArray(): boolean;
  23790. /**
  23791. * Gets a value indicating if the geometry is disposed
  23792. * @returns true if the geometry was disposed
  23793. */
  23794. isDisposed(): boolean;
  23795. private _disposeVertexArrayObjects;
  23796. /**
  23797. * Free all associated resources
  23798. */
  23799. dispose(): void;
  23800. /**
  23801. * Clone the current geometry into a new geometry
  23802. * @param id defines the unique ID of the new geometry
  23803. * @returns a new geometry object
  23804. */
  23805. copy(id: string): Geometry;
  23806. /**
  23807. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23808. * @return a JSON representation of the current geometry data (without the vertices data)
  23809. */
  23810. serialize(): any;
  23811. private toNumberArray;
  23812. /**
  23813. * Serialize all vertices data into a JSON oject
  23814. * @returns a JSON representation of the current geometry data
  23815. */
  23816. serializeVerticeData(): any;
  23817. /**
  23818. * Extracts a clone of a mesh geometry
  23819. * @param mesh defines the source mesh
  23820. * @param id defines the unique ID of the new geometry object
  23821. * @returns the new geometry object
  23822. */
  23823. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23824. /**
  23825. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23826. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23827. * Be aware Math.random() could cause collisions, but:
  23828. * "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"
  23829. * @returns a string containing a new GUID
  23830. */
  23831. static RandomId(): string;
  23832. /** @hidden */
  23833. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23834. private static _CleanMatricesWeights;
  23835. /**
  23836. * Create a new geometry from persisted data (Using .babylon file format)
  23837. * @param parsedVertexData defines the persisted data
  23838. * @param scene defines the hosting scene
  23839. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23840. * @returns the new geometry object
  23841. */
  23842. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23843. }
  23844. }
  23845. declare module "babylonjs/Meshes/mesh.vertexData" {
  23846. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23847. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23848. import { Geometry } from "babylonjs/Meshes/geometry";
  23849. import { Mesh } from "babylonjs/Meshes/mesh";
  23850. /**
  23851. * Define an interface for all classes that will get and set the data on vertices
  23852. */
  23853. export interface IGetSetVerticesData {
  23854. /**
  23855. * Gets a boolean indicating if specific vertex data is present
  23856. * @param kind defines the vertex data kind to use
  23857. * @returns true is data kind is present
  23858. */
  23859. isVerticesDataPresent(kind: string): boolean;
  23860. /**
  23861. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23862. * @param kind defines the data kind (Position, normal, etc...)
  23863. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23864. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23865. * @returns a float array containing vertex data
  23866. */
  23867. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23868. /**
  23869. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23870. * @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.
  23871. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23872. * @returns the indices array or an empty array if the mesh has no geometry
  23873. */
  23874. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23875. /**
  23876. * Set specific vertex data
  23877. * @param kind defines the data kind (Position, normal, etc...)
  23878. * @param data defines the vertex data to use
  23879. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23880. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23881. */
  23882. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23883. /**
  23884. * Update a specific associated vertex buffer
  23885. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23886. * - VertexBuffer.PositionKind
  23887. * - VertexBuffer.UVKind
  23888. * - VertexBuffer.UV2Kind
  23889. * - VertexBuffer.UV3Kind
  23890. * - VertexBuffer.UV4Kind
  23891. * - VertexBuffer.UV5Kind
  23892. * - VertexBuffer.UV6Kind
  23893. * - VertexBuffer.ColorKind
  23894. * - VertexBuffer.MatricesIndicesKind
  23895. * - VertexBuffer.MatricesIndicesExtraKind
  23896. * - VertexBuffer.MatricesWeightsKind
  23897. * - VertexBuffer.MatricesWeightsExtraKind
  23898. * @param data defines the data source
  23899. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23900. * @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)
  23901. */
  23902. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23903. /**
  23904. * Creates a new index buffer
  23905. * @param indices defines the indices to store in the index buffer
  23906. * @param totalVertices defines the total number of vertices (could be null)
  23907. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23908. */
  23909. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23910. }
  23911. /**
  23912. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23913. */
  23914. export class VertexData {
  23915. /**
  23916. * Mesh side orientation : usually the external or front surface
  23917. */
  23918. static readonly FRONTSIDE: number;
  23919. /**
  23920. * Mesh side orientation : usually the internal or back surface
  23921. */
  23922. static readonly BACKSIDE: number;
  23923. /**
  23924. * Mesh side orientation : both internal and external or front and back surfaces
  23925. */
  23926. static readonly DOUBLESIDE: number;
  23927. /**
  23928. * Mesh side orientation : by default, `FRONTSIDE`
  23929. */
  23930. static readonly DEFAULTSIDE: number;
  23931. /**
  23932. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23933. */
  23934. positions: Nullable<FloatArray>;
  23935. /**
  23936. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23937. */
  23938. normals: Nullable<FloatArray>;
  23939. /**
  23940. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23941. */
  23942. tangents: Nullable<FloatArray>;
  23943. /**
  23944. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23945. */
  23946. uvs: Nullable<FloatArray>;
  23947. /**
  23948. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23949. */
  23950. uvs2: Nullable<FloatArray>;
  23951. /**
  23952. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23953. */
  23954. uvs3: Nullable<FloatArray>;
  23955. /**
  23956. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23957. */
  23958. uvs4: Nullable<FloatArray>;
  23959. /**
  23960. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23961. */
  23962. uvs5: Nullable<FloatArray>;
  23963. /**
  23964. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23965. */
  23966. uvs6: Nullable<FloatArray>;
  23967. /**
  23968. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23969. */
  23970. colors: Nullable<FloatArray>;
  23971. /**
  23972. * 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).
  23973. */
  23974. matricesIndices: Nullable<FloatArray>;
  23975. /**
  23976. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23977. */
  23978. matricesWeights: Nullable<FloatArray>;
  23979. /**
  23980. * An array extending the number of possible indices
  23981. */
  23982. matricesIndicesExtra: Nullable<FloatArray>;
  23983. /**
  23984. * An array extending the number of possible weights when the number of indices is extended
  23985. */
  23986. matricesWeightsExtra: Nullable<FloatArray>;
  23987. /**
  23988. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23989. */
  23990. indices: Nullable<IndicesArray>;
  23991. /**
  23992. * Uses the passed data array to set the set the values for the specified kind of data
  23993. * @param data a linear array of floating numbers
  23994. * @param kind the type of data that is being set, eg positions, colors etc
  23995. */
  23996. set(data: FloatArray, kind: string): void;
  23997. /**
  23998. * Associates the vertexData to the passed Mesh.
  23999. * Sets it as updatable or not (default `false`)
  24000. * @param mesh the mesh the vertexData is applied to
  24001. * @param updatable when used and having the value true allows new data to update the vertexData
  24002. * @returns the VertexData
  24003. */
  24004. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  24005. /**
  24006. * Associates the vertexData to the passed Geometry.
  24007. * Sets it as updatable or not (default `false`)
  24008. * @param geometry the geometry the vertexData is applied to
  24009. * @param updatable when used and having the value true allows new data to update the vertexData
  24010. * @returns VertexData
  24011. */
  24012. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  24013. /**
  24014. * Updates the associated mesh
  24015. * @param mesh the mesh to be updated
  24016. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  24017. * @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
  24018. * @returns VertexData
  24019. */
  24020. updateMesh(mesh: Mesh): VertexData;
  24021. /**
  24022. * Updates the associated geometry
  24023. * @param geometry the geometry to be updated
  24024. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  24025. * @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
  24026. * @returns VertexData.
  24027. */
  24028. updateGeometry(geometry: Geometry): VertexData;
  24029. private _applyTo;
  24030. private _update;
  24031. /**
  24032. * Transforms each position and each normal of the vertexData according to the passed Matrix
  24033. * @param matrix the transforming matrix
  24034. * @returns the VertexData
  24035. */
  24036. transform(matrix: Matrix): VertexData;
  24037. /**
  24038. * Merges the passed VertexData into the current one
  24039. * @param other the VertexData to be merged into the current one
  24040. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  24041. * @returns the modified VertexData
  24042. */
  24043. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  24044. private _mergeElement;
  24045. private _validate;
  24046. /**
  24047. * Serializes the VertexData
  24048. * @returns a serialized object
  24049. */
  24050. serialize(): any;
  24051. /**
  24052. * Extracts the vertexData from a mesh
  24053. * @param mesh the mesh from which to extract the VertexData
  24054. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  24055. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  24056. * @returns the object VertexData associated to the passed mesh
  24057. */
  24058. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  24059. /**
  24060. * Extracts the vertexData from the geometry
  24061. * @param geometry the geometry from which to extract the VertexData
  24062. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  24063. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  24064. * @returns the object VertexData associated to the passed mesh
  24065. */
  24066. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  24067. private static _ExtractFrom;
  24068. /**
  24069. * Creates the VertexData for a Ribbon
  24070. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  24071. * * pathArray array of paths, each of which an array of successive Vector3
  24072. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  24073. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  24074. * * 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
  24075. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24076. * * 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)
  24077. * * 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)
  24078. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  24079. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  24080. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  24081. * @returns the VertexData of the ribbon
  24082. */
  24083. static CreateRibbon(options: {
  24084. pathArray: Vector3[][];
  24085. closeArray?: boolean;
  24086. closePath?: boolean;
  24087. offset?: number;
  24088. sideOrientation?: number;
  24089. frontUVs?: Vector4;
  24090. backUVs?: Vector4;
  24091. invertUV?: boolean;
  24092. uvs?: Vector2[];
  24093. colors?: Color4[];
  24094. }): VertexData;
  24095. /**
  24096. * Creates the VertexData for a box
  24097. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24098. * * size sets the width, height and depth of the box to the value of size, optional default 1
  24099. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  24100. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  24101. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  24102. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  24103. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  24104. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24105. * * 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)
  24106. * * 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)
  24107. * @returns the VertexData of the box
  24108. */
  24109. static CreateBox(options: {
  24110. size?: number;
  24111. width?: number;
  24112. height?: number;
  24113. depth?: number;
  24114. faceUV?: Vector4[];
  24115. faceColors?: Color4[];
  24116. sideOrientation?: number;
  24117. frontUVs?: Vector4;
  24118. backUVs?: Vector4;
  24119. }): VertexData;
  24120. /**
  24121. * Creates the VertexData for a tiled box
  24122. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24123. * * faceTiles sets the pattern, tile size and number of tiles for a face
  24124. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  24125. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  24126. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24127. * @returns the VertexData of the box
  24128. */
  24129. static CreateTiledBox(options: {
  24130. pattern?: number;
  24131. width?: number;
  24132. height?: number;
  24133. depth?: number;
  24134. tileSize?: number;
  24135. tileWidth?: number;
  24136. tileHeight?: number;
  24137. alignHorizontal?: number;
  24138. alignVertical?: number;
  24139. faceUV?: Vector4[];
  24140. faceColors?: Color4[];
  24141. sideOrientation?: number;
  24142. }): VertexData;
  24143. /**
  24144. * Creates the VertexData for a tiled plane
  24145. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24146. * * pattern a limited pattern arrangement depending on the number
  24147. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  24148. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  24149. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  24150. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24151. * * 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)
  24152. * * 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)
  24153. * @returns the VertexData of the tiled plane
  24154. */
  24155. static CreateTiledPlane(options: {
  24156. pattern?: number;
  24157. tileSize?: number;
  24158. tileWidth?: number;
  24159. tileHeight?: number;
  24160. size?: number;
  24161. width?: number;
  24162. height?: number;
  24163. alignHorizontal?: number;
  24164. alignVertical?: number;
  24165. sideOrientation?: number;
  24166. frontUVs?: Vector4;
  24167. backUVs?: Vector4;
  24168. }): VertexData;
  24169. /**
  24170. * Creates the VertexData for an ellipsoid, defaults to a sphere
  24171. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24172. * * segments sets the number of horizontal strips optional, default 32
  24173. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  24174. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  24175. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  24176. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  24177. * * 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
  24178. * * 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
  24179. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24180. * * 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)
  24181. * * 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)
  24182. * @returns the VertexData of the ellipsoid
  24183. */
  24184. static CreateSphere(options: {
  24185. segments?: number;
  24186. diameter?: number;
  24187. diameterX?: number;
  24188. diameterY?: number;
  24189. diameterZ?: number;
  24190. arc?: number;
  24191. slice?: number;
  24192. sideOrientation?: number;
  24193. frontUVs?: Vector4;
  24194. backUVs?: Vector4;
  24195. }): VertexData;
  24196. /**
  24197. * Creates the VertexData for a cylinder, cone or prism
  24198. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24199. * * height sets the height (y direction) of the cylinder, optional, default 2
  24200. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  24201. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  24202. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  24203. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24204. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  24205. * * 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
  24206. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24207. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24208. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  24209. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  24210. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24211. * * 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)
  24212. * * 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)
  24213. * @returns the VertexData of the cylinder, cone or prism
  24214. */
  24215. static CreateCylinder(options: {
  24216. height?: number;
  24217. diameterTop?: number;
  24218. diameterBottom?: number;
  24219. diameter?: number;
  24220. tessellation?: number;
  24221. subdivisions?: number;
  24222. arc?: number;
  24223. faceColors?: Color4[];
  24224. faceUV?: Vector4[];
  24225. hasRings?: boolean;
  24226. enclose?: boolean;
  24227. sideOrientation?: number;
  24228. frontUVs?: Vector4;
  24229. backUVs?: Vector4;
  24230. }): VertexData;
  24231. /**
  24232. * Creates the VertexData for a torus
  24233. * @param options an object used to set the following optional parameters for the box, required but can be empty
  24234. * * diameter the diameter of the torus, optional default 1
  24235. * * thickness the diameter of the tube forming the torus, optional default 0.5
  24236. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  24237. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24238. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  24239. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  24240. * @returns the VertexData of the torus
  24241. */
  24242. static CreateTorus(options: {
  24243. diameter?: number;
  24244. thickness?: number;
  24245. tessellation?: number;
  24246. sideOrientation?: number;
  24247. frontUVs?: Vector4;
  24248. backUVs?: Vector4;
  24249. }): VertexData;
  24250. /**
  24251. * Creates the VertexData of the LineSystem
  24252. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  24253. * - lines an array of lines, each line being an array of successive Vector3
  24254. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  24255. * @returns the VertexData of the LineSystem
  24256. */
  24257. static CreateLineSystem(options: {
  24258. lines: Vector3[][];
  24259. colors?: Nullable<Color4[][]>;
  24260. }): VertexData;
  24261. /**
  24262. * Create the VertexData for a DashedLines
  24263. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  24264. * - points an array successive Vector3
  24265. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  24266. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  24267. * - dashNb the intended total number of dashes, optional, default 200
  24268. * @returns the VertexData for the DashedLines
  24269. */
  24270. static CreateDashedLines(options: {
  24271. points: Vector3[];
  24272. dashSize?: number;
  24273. gapSize?: number;
  24274. dashNb?: number;
  24275. }): VertexData;
  24276. /**
  24277. * Creates the VertexData for a Ground
  24278. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24279. * - width the width (x direction) of the ground, optional, default 1
  24280. * - height the height (z direction) of the ground, optional, default 1
  24281. * - subdivisions the number of subdivisions per side, optional, default 1
  24282. * @returns the VertexData of the Ground
  24283. */
  24284. static CreateGround(options: {
  24285. width?: number;
  24286. height?: number;
  24287. subdivisions?: number;
  24288. subdivisionsX?: number;
  24289. subdivisionsY?: number;
  24290. }): VertexData;
  24291. /**
  24292. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  24293. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24294. * * xmin the ground minimum X coordinate, optional, default -1
  24295. * * zmin the ground minimum Z coordinate, optional, default -1
  24296. * * xmax the ground maximum X coordinate, optional, default 1
  24297. * * zmax the ground maximum Z coordinate, optional, default 1
  24298. * * 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}
  24299. * * 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}
  24300. * @returns the VertexData of the TiledGround
  24301. */
  24302. static CreateTiledGround(options: {
  24303. xmin: number;
  24304. zmin: number;
  24305. xmax: number;
  24306. zmax: number;
  24307. subdivisions?: {
  24308. w: number;
  24309. h: number;
  24310. };
  24311. precision?: {
  24312. w: number;
  24313. h: number;
  24314. };
  24315. }): VertexData;
  24316. /**
  24317. * Creates the VertexData of the Ground designed from a heightmap
  24318. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  24319. * * width the width (x direction) of the ground
  24320. * * height the height (z direction) of the ground
  24321. * * subdivisions the number of subdivisions per side
  24322. * * minHeight the minimum altitude on the ground, optional, default 0
  24323. * * maxHeight the maximum altitude on the ground, optional default 1
  24324. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  24325. * * buffer the array holding the image color data
  24326. * * bufferWidth the width of image
  24327. * * bufferHeight the height of image
  24328. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  24329. * @returns the VertexData of the Ground designed from a heightmap
  24330. */
  24331. static CreateGroundFromHeightMap(options: {
  24332. width: number;
  24333. height: number;
  24334. subdivisions: number;
  24335. minHeight: number;
  24336. maxHeight: number;
  24337. colorFilter: Color3;
  24338. buffer: Uint8Array;
  24339. bufferWidth: number;
  24340. bufferHeight: number;
  24341. alphaFilter: number;
  24342. }): VertexData;
  24343. /**
  24344. * Creates the VertexData for a Plane
  24345. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  24346. * * size sets the width and height of the plane to the value of size, optional default 1
  24347. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  24348. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  24349. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24350. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  24351. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  24352. * @returns the VertexData of the box
  24353. */
  24354. static CreatePlane(options: {
  24355. size?: number;
  24356. width?: number;
  24357. height?: number;
  24358. sideOrientation?: number;
  24359. frontUVs?: Vector4;
  24360. backUVs?: Vector4;
  24361. }): VertexData;
  24362. /**
  24363. * Creates the VertexData of the Disc or regular Polygon
  24364. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  24365. * * radius the radius of the disc, optional default 0.5
  24366. * * tessellation the number of polygon sides, optional, default 64
  24367. * * 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
  24368. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24369. * * 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)
  24370. * * 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)
  24371. * @returns the VertexData of the box
  24372. */
  24373. static CreateDisc(options: {
  24374. radius?: number;
  24375. tessellation?: number;
  24376. arc?: number;
  24377. sideOrientation?: number;
  24378. frontUVs?: Vector4;
  24379. backUVs?: Vector4;
  24380. }): VertexData;
  24381. /**
  24382. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  24383. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  24384. * @param polygon a mesh built from polygonTriangulation.build()
  24385. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24386. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24387. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24388. * @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)
  24389. * @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)
  24390. * @returns the VertexData of the Polygon
  24391. */
  24392. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  24393. /**
  24394. * Creates the VertexData of the IcoSphere
  24395. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  24396. * * radius the radius of the IcoSphere, optional default 1
  24397. * * radiusX allows stretching in the x direction, optional, default radius
  24398. * * radiusY allows stretching in the y direction, optional, default radius
  24399. * * radiusZ allows stretching in the z direction, optional, default radius
  24400. * * flat when true creates a flat shaded mesh, optional, default true
  24401. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24402. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24403. * * 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)
  24404. * * 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)
  24405. * @returns the VertexData of the IcoSphere
  24406. */
  24407. static CreateIcoSphere(options: {
  24408. radius?: number;
  24409. radiusX?: number;
  24410. radiusY?: number;
  24411. radiusZ?: number;
  24412. flat?: boolean;
  24413. subdivisions?: number;
  24414. sideOrientation?: number;
  24415. frontUVs?: Vector4;
  24416. backUVs?: Vector4;
  24417. }): VertexData;
  24418. /**
  24419. * Creates the VertexData for a Polyhedron
  24420. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  24421. * * type provided types are:
  24422. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  24423. * * 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)
  24424. * * size the size of the IcoSphere, optional default 1
  24425. * * sizeX allows stretching in the x direction, optional, default size
  24426. * * sizeY allows stretching in the y direction, optional, default size
  24427. * * sizeZ allows stretching in the z direction, optional, default size
  24428. * * 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
  24429. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24430. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24431. * * flat when true creates a flat shaded mesh, optional, default true
  24432. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24433. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24434. * * 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)
  24435. * * 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)
  24436. * @returns the VertexData of the Polyhedron
  24437. */
  24438. static CreatePolyhedron(options: {
  24439. type?: number;
  24440. size?: number;
  24441. sizeX?: number;
  24442. sizeY?: number;
  24443. sizeZ?: number;
  24444. custom?: any;
  24445. faceUV?: Vector4[];
  24446. faceColors?: Color4[];
  24447. flat?: boolean;
  24448. sideOrientation?: number;
  24449. frontUVs?: Vector4;
  24450. backUVs?: Vector4;
  24451. }): VertexData;
  24452. /**
  24453. * Creates the VertexData for a TorusKnot
  24454. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  24455. * * radius the radius of the torus knot, optional, default 2
  24456. * * tube the thickness of the tube, optional, default 0.5
  24457. * * radialSegments the number of sides on each tube segments, optional, default 32
  24458. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  24459. * * p the number of windings around the z axis, optional, default 2
  24460. * * q the number of windings around the x axis, optional, default 3
  24461. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24462. * * 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)
  24463. * * 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)
  24464. * @returns the VertexData of the Torus Knot
  24465. */
  24466. static CreateTorusKnot(options: {
  24467. radius?: number;
  24468. tube?: number;
  24469. radialSegments?: number;
  24470. tubularSegments?: number;
  24471. p?: number;
  24472. q?: number;
  24473. sideOrientation?: number;
  24474. frontUVs?: Vector4;
  24475. backUVs?: Vector4;
  24476. }): VertexData;
  24477. /**
  24478. * Compute normals for given positions and indices
  24479. * @param positions an array of vertex positions, [...., x, y, z, ......]
  24480. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  24481. * @param normals an array of vertex normals, [...., x, y, z, ......]
  24482. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  24483. * * facetNormals : optional array of facet normals (vector3)
  24484. * * facetPositions : optional array of facet positions (vector3)
  24485. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  24486. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  24487. * * bInfo : optional bounding info, required for facetPartitioning computation
  24488. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  24489. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  24490. * * useRightHandedSystem: optional boolean to for right handed system computation
  24491. * * depthSort : optional boolean to enable the facet depth sort computation
  24492. * * distanceTo : optional Vector3 to compute the facet depth from this location
  24493. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  24494. */
  24495. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  24496. facetNormals?: any;
  24497. facetPositions?: any;
  24498. facetPartitioning?: any;
  24499. ratio?: number;
  24500. bInfo?: any;
  24501. bbSize?: Vector3;
  24502. subDiv?: any;
  24503. useRightHandedSystem?: boolean;
  24504. depthSort?: boolean;
  24505. distanceTo?: Vector3;
  24506. depthSortedFacets?: any;
  24507. }): void;
  24508. /** @hidden */
  24509. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  24510. /**
  24511. * Applies VertexData created from the imported parameters to the geometry
  24512. * @param parsedVertexData the parsed data from an imported file
  24513. * @param geometry the geometry to apply the VertexData to
  24514. */
  24515. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  24516. }
  24517. }
  24518. declare module "babylonjs/Meshes/Builders/discBuilder" {
  24519. import { Nullable } from "babylonjs/types";
  24520. import { Scene } from "babylonjs/scene";
  24521. import { Vector4 } from "babylonjs/Maths/math";
  24522. import { Mesh } from "babylonjs/Meshes/mesh";
  24523. /**
  24524. * Class containing static functions to help procedurally build meshes
  24525. */
  24526. export class DiscBuilder {
  24527. /**
  24528. * Creates a plane polygonal mesh. By default, this is a disc
  24529. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24530. * * 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
  24531. * * 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
  24532. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24533. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24535. * @param name defines the name of the mesh
  24536. * @param options defines the options used to create the mesh
  24537. * @param scene defines the hosting scene
  24538. * @returns the plane polygonal mesh
  24539. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24540. */
  24541. static CreateDisc(name: string, options: {
  24542. radius?: number;
  24543. tessellation?: number;
  24544. arc?: number;
  24545. updatable?: boolean;
  24546. sideOrientation?: number;
  24547. frontUVs?: Vector4;
  24548. backUVs?: Vector4;
  24549. }, scene?: Nullable<Scene>): Mesh;
  24550. }
  24551. }
  24552. declare module "babylonjs/Particles/solidParticleSystem" {
  24553. import { Vector3 } from "babylonjs/Maths/math";
  24554. import { Mesh } from "babylonjs/Meshes/mesh";
  24555. import { Scene, IDisposable } from "babylonjs/scene";
  24556. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  24557. /**
  24558. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24559. *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.
  24560. * The SPS is also a particle system. It provides some methods to manage the particles.
  24561. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24562. *
  24563. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24564. */
  24565. export class SolidParticleSystem implements IDisposable {
  24566. /**
  24567. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24568. * Example : var p = SPS.particles[i];
  24569. */
  24570. particles: SolidParticle[];
  24571. /**
  24572. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24573. */
  24574. nbParticles: number;
  24575. /**
  24576. * If the particles must ever face the camera (default false). Useful for planar particles.
  24577. */
  24578. billboard: boolean;
  24579. /**
  24580. * Recompute normals when adding a shape
  24581. */
  24582. recomputeNormals: boolean;
  24583. /**
  24584. * This a counter ofr your own usage. It's not set by any SPS functions.
  24585. */
  24586. counter: number;
  24587. /**
  24588. * The SPS name. This name is also given to the underlying mesh.
  24589. */
  24590. name: string;
  24591. /**
  24592. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24593. */
  24594. mesh: Mesh;
  24595. /**
  24596. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24597. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24598. */
  24599. vars: any;
  24600. /**
  24601. * This array is populated when the SPS is set as 'pickable'.
  24602. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24603. * Each element of this array is an object `{idx: int, faceId: int}`.
  24604. * `idx` is the picked particle index in the `SPS.particles` array
  24605. * `faceId` is the picked face index counted within this particle.
  24606. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24607. */
  24608. pickedParticles: {
  24609. idx: number;
  24610. faceId: number;
  24611. }[];
  24612. /**
  24613. * This array is populated when `enableDepthSort` is set to true.
  24614. * Each element of this array is an instance of the class DepthSortedParticle.
  24615. */
  24616. depthSortedParticles: DepthSortedParticle[];
  24617. /**
  24618. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24619. * @hidden
  24620. */
  24621. _bSphereOnly: boolean;
  24622. /**
  24623. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24624. * @hidden
  24625. */
  24626. _bSphereRadiusFactor: number;
  24627. private _scene;
  24628. private _positions;
  24629. private _indices;
  24630. private _normals;
  24631. private _colors;
  24632. private _uvs;
  24633. private _indices32;
  24634. private _positions32;
  24635. private _normals32;
  24636. private _fixedNormal32;
  24637. private _colors32;
  24638. private _uvs32;
  24639. private _index;
  24640. private _updatable;
  24641. private _pickable;
  24642. private _isVisibilityBoxLocked;
  24643. private _alwaysVisible;
  24644. private _depthSort;
  24645. private _shapeCounter;
  24646. private _copy;
  24647. private _color;
  24648. private _computeParticleColor;
  24649. private _computeParticleTexture;
  24650. private _computeParticleRotation;
  24651. private _computeParticleVertex;
  24652. private _computeBoundingBox;
  24653. private _depthSortParticles;
  24654. private _camera;
  24655. private _mustUnrotateFixedNormals;
  24656. private _particlesIntersect;
  24657. private _needs32Bits;
  24658. /**
  24659. * Creates a SPS (Solid Particle System) object.
  24660. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24661. * @param scene (Scene) is the scene in which the SPS is added.
  24662. * @param options defines the options of the sps e.g.
  24663. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24664. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24665. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24666. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24667. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24668. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24669. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24670. */
  24671. constructor(name: string, scene: Scene, options?: {
  24672. updatable?: boolean;
  24673. isPickable?: boolean;
  24674. enableDepthSort?: boolean;
  24675. particleIntersection?: boolean;
  24676. boundingSphereOnly?: boolean;
  24677. bSphereRadiusFactor?: number;
  24678. });
  24679. /**
  24680. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24681. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24682. * @returns the created mesh
  24683. */
  24684. buildMesh(): Mesh;
  24685. /**
  24686. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24687. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24688. * Thus the particles generated from `digest()` have their property `position` set yet.
  24689. * @param mesh ( Mesh ) is the mesh to be digested
  24690. * @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
  24691. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24692. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24693. * @returns the current SPS
  24694. */
  24695. digest(mesh: Mesh, options?: {
  24696. facetNb?: number;
  24697. number?: number;
  24698. delta?: number;
  24699. }): SolidParticleSystem;
  24700. private _unrotateFixedNormals;
  24701. private _resetCopy;
  24702. private _meshBuilder;
  24703. private _posToShape;
  24704. private _uvsToShapeUV;
  24705. private _addParticle;
  24706. /**
  24707. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24708. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24709. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24710. * @param nb (positive integer) the number of particles to be created from this model
  24711. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24712. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24713. * @returns the number of shapes in the system
  24714. */
  24715. addShape(mesh: Mesh, nb: number, options?: {
  24716. positionFunction?: any;
  24717. vertexFunction?: any;
  24718. }): number;
  24719. private _rebuildParticle;
  24720. /**
  24721. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24722. * @returns the SPS.
  24723. */
  24724. rebuildMesh(): SolidParticleSystem;
  24725. /**
  24726. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24727. * This method calls `updateParticle()` for each particle of the SPS.
  24728. * For an animated SPS, it is usually called within the render loop.
  24729. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24730. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24731. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24732. * @returns the SPS.
  24733. */
  24734. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24735. /**
  24736. * Disposes the SPS.
  24737. */
  24738. dispose(): void;
  24739. /**
  24740. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24741. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24742. * @returns the SPS.
  24743. */
  24744. refreshVisibleSize(): SolidParticleSystem;
  24745. /**
  24746. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24747. * @param size the size (float) of the visibility box
  24748. * note : this doesn't lock the SPS mesh bounding box.
  24749. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24750. */
  24751. setVisibilityBox(size: number): void;
  24752. /**
  24753. * Gets whether the SPS as always visible or not
  24754. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24755. */
  24756. /**
  24757. * Sets the SPS as always visible or not
  24758. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24759. */
  24760. isAlwaysVisible: boolean;
  24761. /**
  24762. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24763. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24764. */
  24765. /**
  24766. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24767. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24768. */
  24769. isVisibilityBoxLocked: boolean;
  24770. /**
  24771. * Tells to `setParticles()` to compute the particle rotations or not.
  24772. * Default value : true. The SPS is faster when it's set to false.
  24773. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24774. */
  24775. /**
  24776. * Gets if `setParticles()` computes the particle rotations or not.
  24777. * Default value : true. The SPS is faster when it's set to false.
  24778. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24779. */
  24780. computeParticleRotation: boolean;
  24781. /**
  24782. * Tells to `setParticles()` to compute the particle colors or not.
  24783. * Default value : true. The SPS is faster when it's set to false.
  24784. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24785. */
  24786. /**
  24787. * Gets if `setParticles()` computes the particle colors or not.
  24788. * Default value : true. The SPS is faster when it's set to false.
  24789. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24790. */
  24791. computeParticleColor: boolean;
  24792. /**
  24793. * Gets if `setParticles()` computes the particle textures or not.
  24794. * Default value : true. The SPS is faster when it's set to false.
  24795. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24796. */
  24797. computeParticleTexture: boolean;
  24798. /**
  24799. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24800. * Default value : false. The SPS is faster when it's set to false.
  24801. * Note : the particle custom vertex positions aren't stored values.
  24802. */
  24803. /**
  24804. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24805. * Default value : false. The SPS is faster when it's set to false.
  24806. * Note : the particle custom vertex positions aren't stored values.
  24807. */
  24808. computeParticleVertex: boolean;
  24809. /**
  24810. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24811. */
  24812. /**
  24813. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24814. */
  24815. computeBoundingBox: boolean;
  24816. /**
  24817. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24818. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24819. * Default : `true`
  24820. */
  24821. /**
  24822. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24823. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24824. * Default : `true`
  24825. */
  24826. depthSortParticles: boolean;
  24827. /**
  24828. * This function does nothing. It may be overwritten to set all the particle first values.
  24829. * The SPS doesn't call this function, you may have to call it by your own.
  24830. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24831. */
  24832. initParticles(): void;
  24833. /**
  24834. * This function does nothing. It may be overwritten to recycle a particle.
  24835. * The SPS doesn't call this function, you may have to call it by your own.
  24836. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24837. * @param particle The particle to recycle
  24838. * @returns the recycled particle
  24839. */
  24840. recycleParticle(particle: SolidParticle): SolidParticle;
  24841. /**
  24842. * Updates a particle : this function should be overwritten by the user.
  24843. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24844. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24845. * @example : just set a particle position or velocity and recycle conditions
  24846. * @param particle The particle to update
  24847. * @returns the updated particle
  24848. */
  24849. updateParticle(particle: SolidParticle): SolidParticle;
  24850. /**
  24851. * Updates a vertex of a particle : it can be overwritten by the user.
  24852. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24853. * @param particle the current particle
  24854. * @param vertex the current index of the current particle
  24855. * @param pt the index of the current vertex in the particle shape
  24856. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24857. * @example : just set a vertex particle position
  24858. * @returns the updated vertex
  24859. */
  24860. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24861. /**
  24862. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24863. * This does nothing and may be overwritten by the user.
  24864. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24865. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24866. * @param update the boolean update value actually passed to setParticles()
  24867. */
  24868. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24869. /**
  24870. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24871. * This will be passed three parameters.
  24872. * This does nothing and may be overwritten by the user.
  24873. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24874. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24875. * @param update the boolean update value actually passed to setParticles()
  24876. */
  24877. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24878. }
  24879. }
  24880. declare module "babylonjs/Particles/solidParticle" {
  24881. import { Nullable } from "babylonjs/types";
  24882. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24883. import { Mesh } from "babylonjs/Meshes/mesh";
  24884. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24885. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24886. /**
  24887. * Represents one particle of a solid particle system.
  24888. */
  24889. export class SolidParticle {
  24890. /**
  24891. * particle global index
  24892. */
  24893. idx: number;
  24894. /**
  24895. * The color of the particle
  24896. */
  24897. color: Nullable<Color4>;
  24898. /**
  24899. * The world space position of the particle.
  24900. */
  24901. position: Vector3;
  24902. /**
  24903. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24904. */
  24905. rotation: Vector3;
  24906. /**
  24907. * The world space rotation quaternion of the particle.
  24908. */
  24909. rotationQuaternion: Nullable<Quaternion>;
  24910. /**
  24911. * The scaling of the particle.
  24912. */
  24913. scaling: Vector3;
  24914. /**
  24915. * The uvs of the particle.
  24916. */
  24917. uvs: Vector4;
  24918. /**
  24919. * The current speed of the particle.
  24920. */
  24921. velocity: Vector3;
  24922. /**
  24923. * The pivot point in the particle local space.
  24924. */
  24925. pivot: Vector3;
  24926. /**
  24927. * Must the particle be translated from its pivot point in its local space ?
  24928. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24929. * Default : false
  24930. */
  24931. translateFromPivot: boolean;
  24932. /**
  24933. * Is the particle active or not ?
  24934. */
  24935. alive: boolean;
  24936. /**
  24937. * Is the particle visible or not ?
  24938. */
  24939. isVisible: boolean;
  24940. /**
  24941. * Index of this particle in the global "positions" array (Internal use)
  24942. * @hidden
  24943. */
  24944. _pos: number;
  24945. /**
  24946. * @hidden Index of this particle in the global "indices" array (Internal use)
  24947. */
  24948. _ind: number;
  24949. /**
  24950. * @hidden ModelShape of this particle (Internal use)
  24951. */
  24952. _model: ModelShape;
  24953. /**
  24954. * ModelShape id of this particle
  24955. */
  24956. shapeId: number;
  24957. /**
  24958. * Index of the particle in its shape id (Internal use)
  24959. */
  24960. idxInShape: number;
  24961. /**
  24962. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24963. */
  24964. _modelBoundingInfo: BoundingInfo;
  24965. /**
  24966. * @hidden Particle BoundingInfo object (Internal use)
  24967. */
  24968. _boundingInfo: BoundingInfo;
  24969. /**
  24970. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24971. */
  24972. _sps: SolidParticleSystem;
  24973. /**
  24974. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24975. */
  24976. _stillInvisible: boolean;
  24977. /**
  24978. * @hidden Last computed particle rotation matrix
  24979. */
  24980. _rotationMatrix: number[];
  24981. /**
  24982. * Parent particle Id, if any.
  24983. * Default null.
  24984. */
  24985. parentId: Nullable<number>;
  24986. /**
  24987. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24988. * The possible values are :
  24989. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24990. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24991. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24992. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24993. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24994. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24995. * */
  24996. cullingStrategy: number;
  24997. /**
  24998. * @hidden Internal global position in the SPS.
  24999. */
  25000. _globalPosition: Vector3;
  25001. /**
  25002. * Creates a Solid Particle object.
  25003. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  25004. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  25005. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  25006. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  25007. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  25008. * @param shapeId (integer) is the model shape identifier in the SPS.
  25009. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  25010. * @param sps defines the sps it is associated to
  25011. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  25012. */
  25013. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  25014. /**
  25015. * Legacy support, changed scale to scaling
  25016. */
  25017. /**
  25018. * Legacy support, changed scale to scaling
  25019. */
  25020. scale: Vector3;
  25021. /**
  25022. * Legacy support, changed quaternion to rotationQuaternion
  25023. */
  25024. /**
  25025. * Legacy support, changed quaternion to rotationQuaternion
  25026. */
  25027. quaternion: Nullable<Quaternion>;
  25028. /**
  25029. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25030. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25031. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25032. * @returns true if it intersects
  25033. */
  25034. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25035. /**
  25036. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25037. * A particle is in the frustum if its bounding box intersects the frustum
  25038. * @param frustumPlanes defines the frustum to test
  25039. * @returns true if the particle is in the frustum planes
  25040. */
  25041. isInFrustum(frustumPlanes: Plane[]): boolean;
  25042. /**
  25043. * get the rotation matrix of the particle
  25044. * @hidden
  25045. */
  25046. getRotationMatrix(m: Matrix): void;
  25047. }
  25048. /**
  25049. * Represents the shape of the model used by one particle of a solid particle system.
  25050. * SPS internal tool, don't use it manually.
  25051. */
  25052. export class ModelShape {
  25053. /**
  25054. * The shape id
  25055. * @hidden
  25056. */
  25057. shapeID: number;
  25058. /**
  25059. * flat array of model positions (internal use)
  25060. * @hidden
  25061. */
  25062. _shape: Vector3[];
  25063. /**
  25064. * flat array of model UVs (internal use)
  25065. * @hidden
  25066. */
  25067. _shapeUV: number[];
  25068. /**
  25069. * length of the shape in the model indices array (internal use)
  25070. * @hidden
  25071. */
  25072. _indicesLength: number;
  25073. /**
  25074. * Custom position function (internal use)
  25075. * @hidden
  25076. */
  25077. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25078. /**
  25079. * Custom vertex function (internal use)
  25080. * @hidden
  25081. */
  25082. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25083. /**
  25084. * 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.
  25085. * SPS internal tool, don't use it manually.
  25086. * @hidden
  25087. */
  25088. 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>);
  25089. }
  25090. /**
  25091. * Represents a Depth Sorted Particle in the solid particle system.
  25092. */
  25093. export class DepthSortedParticle {
  25094. /**
  25095. * Index of the particle in the "indices" array
  25096. */
  25097. ind: number;
  25098. /**
  25099. * Length of the particle shape in the "indices" array
  25100. */
  25101. indicesLength: number;
  25102. /**
  25103. * Squared distance from the particle to the camera
  25104. */
  25105. sqDistance: number;
  25106. }
  25107. }
  25108. declare module "babylonjs/Collisions/meshCollisionData" {
  25109. import { Collider } from "babylonjs/Collisions/collider";
  25110. import { Vector3 } from "babylonjs/Maths/math";
  25111. import { Nullable } from "babylonjs/types";
  25112. import { Observer } from "babylonjs/Misc/observable";
  25113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25114. /**
  25115. * @hidden
  25116. */
  25117. export class _MeshCollisionData {
  25118. _checkCollisions: boolean;
  25119. _collisionMask: number;
  25120. _collisionGroup: number;
  25121. _collider: Nullable<Collider>;
  25122. _oldPositionForCollisions: Vector3;
  25123. _diffPositionForCollisions: Vector3;
  25124. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  25125. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  25126. }
  25127. }
  25128. declare module "babylonjs/Meshes/abstractMesh" {
  25129. import { Observable } from "babylonjs/Misc/observable";
  25130. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  25131. import { Camera } from "babylonjs/Cameras/camera";
  25132. import { Scene, IDisposable } from "babylonjs/scene";
  25133. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  25134. import { Node } from "babylonjs/node";
  25135. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  25136. import { TransformNode } from "babylonjs/Meshes/transformNode";
  25137. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25138. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  25139. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25140. import { Material } from "babylonjs/Materials/material";
  25141. import { Light } from "babylonjs/Lights/light";
  25142. import { Skeleton } from "babylonjs/Bones/skeleton";
  25143. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  25144. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  25145. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25146. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  25147. import { Ray } from "babylonjs/Culling/ray";
  25148. import { Collider } from "babylonjs/Collisions/collider";
  25149. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  25150. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  25151. /** @hidden */
  25152. class _FacetDataStorage {
  25153. facetPositions: Vector3[];
  25154. facetNormals: Vector3[];
  25155. facetPartitioning: number[][];
  25156. facetNb: number;
  25157. partitioningSubdivisions: number;
  25158. partitioningBBoxRatio: number;
  25159. facetDataEnabled: boolean;
  25160. facetParameters: any;
  25161. bbSize: Vector3;
  25162. subDiv: {
  25163. max: number;
  25164. X: number;
  25165. Y: number;
  25166. Z: number;
  25167. };
  25168. facetDepthSort: boolean;
  25169. facetDepthSortEnabled: boolean;
  25170. depthSortedIndices: IndicesArray;
  25171. depthSortedFacets: {
  25172. ind: number;
  25173. sqDistance: number;
  25174. }[];
  25175. facetDepthSortFunction: (f1: {
  25176. ind: number;
  25177. sqDistance: number;
  25178. }, f2: {
  25179. ind: number;
  25180. sqDistance: number;
  25181. }) => number;
  25182. facetDepthSortFrom: Vector3;
  25183. facetDepthSortOrigin: Vector3;
  25184. invertedMatrix: Matrix;
  25185. }
  25186. /**
  25187. * @hidden
  25188. **/
  25189. class _InternalAbstractMeshDataInfo {
  25190. _hasVertexAlpha: boolean;
  25191. _useVertexColors: boolean;
  25192. _numBoneInfluencers: number;
  25193. _applyFog: boolean;
  25194. _receiveShadows: boolean;
  25195. _facetData: _FacetDataStorage;
  25196. _visibility: number;
  25197. _skeleton: Nullable<Skeleton>;
  25198. _layerMask: number;
  25199. _computeBonesUsingShaders: boolean;
  25200. _isActive: boolean;
  25201. _onlyForInstances: boolean;
  25202. _isActiveIntermediate: boolean;
  25203. _onlyForInstancesIntermediate: boolean;
  25204. }
  25205. /**
  25206. * Class used to store all common mesh properties
  25207. */
  25208. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25209. /** No occlusion */
  25210. static OCCLUSION_TYPE_NONE: number;
  25211. /** Occlusion set to optimisitic */
  25212. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25213. /** Occlusion set to strict */
  25214. static OCCLUSION_TYPE_STRICT: number;
  25215. /** Use an accurante occlusion algorithm */
  25216. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25217. /** Use a conservative occlusion algorithm */
  25218. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25219. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25220. * Test order :
  25221. * Is the bounding sphere outside the frustum ?
  25222. * If not, are the bounding box vertices outside the frustum ?
  25223. * It not, then the cullable object is in the frustum.
  25224. */
  25225. static readonly CULLINGSTRATEGY_STANDARD: number;
  25226. /** Culling strategy : Bounding Sphere Only.
  25227. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25228. * It's also less accurate than the standard because some not visible objects can still be selected.
  25229. * Test : is the bounding sphere outside the frustum ?
  25230. * If not, then the cullable object is in the frustum.
  25231. */
  25232. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25233. /** Culling strategy : Optimistic Inclusion.
  25234. * This in an inclusion test first, then the standard exclusion test.
  25235. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25236. * 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.
  25237. * Anyway, it's as accurate as the standard strategy.
  25238. * Test :
  25239. * Is the cullable object bounding sphere center in the frustum ?
  25240. * If not, apply the default culling strategy.
  25241. */
  25242. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25243. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25244. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25245. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25246. * 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.
  25247. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25248. * Test :
  25249. * Is the cullable object bounding sphere center in the frustum ?
  25250. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25251. */
  25252. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25253. /**
  25254. * No billboard
  25255. */
  25256. static readonly BILLBOARDMODE_NONE: number;
  25257. /** Billboard on X axis */
  25258. static readonly BILLBOARDMODE_X: number;
  25259. /** Billboard on Y axis */
  25260. static readonly BILLBOARDMODE_Y: number;
  25261. /** Billboard on Z axis */
  25262. static readonly BILLBOARDMODE_Z: number;
  25263. /** Billboard on all axes */
  25264. static readonly BILLBOARDMODE_ALL: number;
  25265. /** @hidden */
  25266. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25267. /**
  25268. * The culling strategy to use to check whether the mesh must be rendered or not.
  25269. * This value can be changed at any time and will be used on the next render mesh selection.
  25270. * The possible values are :
  25271. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25272. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25273. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25274. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25275. * Please read each static variable documentation to get details about the culling process.
  25276. * */
  25277. cullingStrategy: number;
  25278. /**
  25279. * Gets the number of facets in the mesh
  25280. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25281. */
  25282. readonly facetNb: number;
  25283. /**
  25284. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25285. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25286. */
  25287. partitioningSubdivisions: number;
  25288. /**
  25289. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25290. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25291. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25292. */
  25293. partitioningBBoxRatio: number;
  25294. /**
  25295. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25296. * Works only for updatable meshes.
  25297. * Doesn't work with multi-materials
  25298. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25299. */
  25300. mustDepthSortFacets: boolean;
  25301. /**
  25302. * The location (Vector3) where the facet depth sort must be computed from.
  25303. * By default, the active camera position.
  25304. * Used only when facet depth sort is enabled
  25305. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25306. */
  25307. facetDepthSortFrom: Vector3;
  25308. /**
  25309. * gets a boolean indicating if facetData is enabled
  25310. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25311. */
  25312. readonly isFacetDataEnabled: boolean;
  25313. /** @hidden */
  25314. _updateNonUniformScalingState(value: boolean): boolean;
  25315. /**
  25316. * An event triggered when this mesh collides with another one
  25317. */
  25318. onCollideObservable: Observable<AbstractMesh>;
  25319. /** Set a function to call when this mesh collides with another one */
  25320. onCollide: () => void;
  25321. /**
  25322. * An event triggered when the collision's position changes
  25323. */
  25324. onCollisionPositionChangeObservable: Observable<Vector3>;
  25325. /** Set a function to call when the collision's position changes */
  25326. onCollisionPositionChange: () => void;
  25327. /**
  25328. * An event triggered when material is changed
  25329. */
  25330. onMaterialChangedObservable: Observable<AbstractMesh>;
  25331. /**
  25332. * Gets or sets the orientation for POV movement & rotation
  25333. */
  25334. definedFacingForward: boolean;
  25335. /** @hidden */
  25336. _occlusionQuery: Nullable<WebGLQuery>;
  25337. /** @hidden */
  25338. _renderingGroup: Nullable<RenderingGroup>;
  25339. /**
  25340. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25341. */
  25342. /**
  25343. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25344. */
  25345. visibility: number;
  25346. /** Gets or sets the alpha index used to sort transparent meshes
  25347. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25348. */
  25349. alphaIndex: number;
  25350. /**
  25351. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25352. */
  25353. isVisible: boolean;
  25354. /**
  25355. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25356. */
  25357. isPickable: boolean;
  25358. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25359. showSubMeshesBoundingBox: boolean;
  25360. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25361. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25362. */
  25363. isBlocker: boolean;
  25364. /**
  25365. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25366. */
  25367. enablePointerMoveEvents: boolean;
  25368. /**
  25369. * Specifies the rendering group id for this mesh (0 by default)
  25370. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25371. */
  25372. renderingGroupId: number;
  25373. private _material;
  25374. /** Gets or sets current material */
  25375. material: Nullable<Material>;
  25376. /**
  25377. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25378. * @see http://doc.babylonjs.com/babylon101/shadows
  25379. */
  25380. receiveShadows: boolean;
  25381. /** Defines color to use when rendering outline */
  25382. outlineColor: Color3;
  25383. /** Define width to use when rendering outline */
  25384. outlineWidth: number;
  25385. /** Defines color to use when rendering overlay */
  25386. overlayColor: Color3;
  25387. /** Defines alpha to use when rendering overlay */
  25388. overlayAlpha: number;
  25389. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25390. hasVertexAlpha: boolean;
  25391. /** 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) */
  25392. useVertexColors: boolean;
  25393. /**
  25394. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25395. */
  25396. computeBonesUsingShaders: boolean;
  25397. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25398. numBoneInfluencers: number;
  25399. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25400. applyFog: boolean;
  25401. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25402. useOctreeForRenderingSelection: boolean;
  25403. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25404. useOctreeForPicking: boolean;
  25405. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25406. useOctreeForCollisions: boolean;
  25407. /**
  25408. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25409. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25410. */
  25411. layerMask: number;
  25412. /**
  25413. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25414. */
  25415. alwaysSelectAsActiveMesh: boolean;
  25416. /**
  25417. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25418. */
  25419. doNotSyncBoundingInfo: boolean;
  25420. /**
  25421. * Gets or sets the current action manager
  25422. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25423. */
  25424. actionManager: Nullable<AbstractActionManager>;
  25425. private _meshCollisionData;
  25426. /**
  25427. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25428. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25429. */
  25430. ellipsoid: Vector3;
  25431. /**
  25432. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25433. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25434. */
  25435. ellipsoidOffset: Vector3;
  25436. /**
  25437. * Gets or sets a collision mask used to mask collisions (default is -1).
  25438. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25439. */
  25440. collisionMask: number;
  25441. /**
  25442. * Gets or sets the current collision group mask (-1 by default).
  25443. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25444. */
  25445. collisionGroup: number;
  25446. /**
  25447. * Defines edge width used when edgesRenderer is enabled
  25448. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25449. */
  25450. edgesWidth: number;
  25451. /**
  25452. * Defines edge color used when edgesRenderer is enabled
  25453. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25454. */
  25455. edgesColor: Color4;
  25456. /** @hidden */
  25457. _edgesRenderer: Nullable<IEdgesRenderer>;
  25458. /** @hidden */
  25459. _masterMesh: Nullable<AbstractMesh>;
  25460. /** @hidden */
  25461. _boundingInfo: Nullable<BoundingInfo>;
  25462. /** @hidden */
  25463. _renderId: number;
  25464. /**
  25465. * Gets or sets the list of subMeshes
  25466. * @see http://doc.babylonjs.com/how_to/multi_materials
  25467. */
  25468. subMeshes: SubMesh[];
  25469. /** @hidden */
  25470. _intersectionsInProgress: AbstractMesh[];
  25471. /** @hidden */
  25472. _unIndexed: boolean;
  25473. /** @hidden */
  25474. _lightSources: Light[];
  25475. /** Gets the list of lights affecting that mesh */
  25476. readonly lightSources: Light[];
  25477. /** @hidden */
  25478. readonly _positions: Nullable<Vector3[]>;
  25479. /** @hidden */
  25480. _waitingData: {
  25481. lods: Nullable<any>;
  25482. actions: Nullable<any>;
  25483. freezeWorldMatrix: Nullable<boolean>;
  25484. };
  25485. /** @hidden */
  25486. _bonesTransformMatrices: Nullable<Float32Array>;
  25487. /** @hidden */
  25488. _transformMatrixTexture: Nullable<RawTexture>;
  25489. /**
  25490. * Gets or sets a skeleton to apply skining transformations
  25491. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25492. */
  25493. skeleton: Nullable<Skeleton>;
  25494. /**
  25495. * An event triggered when the mesh is rebuilt.
  25496. */
  25497. onRebuildObservable: Observable<AbstractMesh>;
  25498. /**
  25499. * Creates a new AbstractMesh
  25500. * @param name defines the name of the mesh
  25501. * @param scene defines the hosting scene
  25502. */
  25503. constructor(name: string, scene?: Nullable<Scene>);
  25504. /**
  25505. * Returns the string "AbstractMesh"
  25506. * @returns "AbstractMesh"
  25507. */
  25508. getClassName(): string;
  25509. /**
  25510. * Gets a string representation of the current mesh
  25511. * @param fullDetails defines a boolean indicating if full details must be included
  25512. * @returns a string representation of the current mesh
  25513. */
  25514. toString(fullDetails?: boolean): string;
  25515. /**
  25516. * @hidden
  25517. */
  25518. protected _getEffectiveParent(): Nullable<Node>;
  25519. /** @hidden */
  25520. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25521. /** @hidden */
  25522. _rebuild(): void;
  25523. /** @hidden */
  25524. _resyncLightSources(): void;
  25525. /** @hidden */
  25526. _resyncLighSource(light: Light): void;
  25527. /** @hidden */
  25528. _unBindEffect(): void;
  25529. /** @hidden */
  25530. _removeLightSource(light: Light): void;
  25531. private _markSubMeshesAsDirty;
  25532. /** @hidden */
  25533. _markSubMeshesAsLightDirty(): void;
  25534. /** @hidden */
  25535. _markSubMeshesAsAttributesDirty(): void;
  25536. /** @hidden */
  25537. _markSubMeshesAsMiscDirty(): void;
  25538. /**
  25539. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25540. */
  25541. scaling: Vector3;
  25542. /**
  25543. * Returns true if the mesh is blocked. Implemented by child classes
  25544. */
  25545. readonly isBlocked: boolean;
  25546. /**
  25547. * Returns the mesh itself by default. Implemented by child classes
  25548. * @param camera defines the camera to use to pick the right LOD level
  25549. * @returns the currentAbstractMesh
  25550. */
  25551. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25552. /**
  25553. * Returns 0 by default. Implemented by child classes
  25554. * @returns an integer
  25555. */
  25556. getTotalVertices(): number;
  25557. /**
  25558. * Returns a positive integer : the total number of indices in this mesh geometry.
  25559. * @returns the numner of indices or zero if the mesh has no geometry.
  25560. */
  25561. getTotalIndices(): number;
  25562. /**
  25563. * Returns null by default. Implemented by child classes
  25564. * @returns null
  25565. */
  25566. getIndices(): Nullable<IndicesArray>;
  25567. /**
  25568. * Returns the array of the requested vertex data kind. Implemented by child classes
  25569. * @param kind defines the vertex data kind to use
  25570. * @returns null
  25571. */
  25572. getVerticesData(kind: string): Nullable<FloatArray>;
  25573. /**
  25574. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25575. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25576. * Note that a new underlying VertexBuffer object is created each call.
  25577. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25578. * @param kind defines vertex data kind:
  25579. * * VertexBuffer.PositionKind
  25580. * * VertexBuffer.UVKind
  25581. * * VertexBuffer.UV2Kind
  25582. * * VertexBuffer.UV3Kind
  25583. * * VertexBuffer.UV4Kind
  25584. * * VertexBuffer.UV5Kind
  25585. * * VertexBuffer.UV6Kind
  25586. * * VertexBuffer.ColorKind
  25587. * * VertexBuffer.MatricesIndicesKind
  25588. * * VertexBuffer.MatricesIndicesExtraKind
  25589. * * VertexBuffer.MatricesWeightsKind
  25590. * * VertexBuffer.MatricesWeightsExtraKind
  25591. * @param data defines the data source
  25592. * @param updatable defines if the data must be flagged as updatable (or static)
  25593. * @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
  25594. * @returns the current mesh
  25595. */
  25596. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25597. /**
  25598. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25599. * If the mesh has no geometry, it is simply returned as it is.
  25600. * @param kind defines vertex data kind:
  25601. * * VertexBuffer.PositionKind
  25602. * * VertexBuffer.UVKind
  25603. * * VertexBuffer.UV2Kind
  25604. * * VertexBuffer.UV3Kind
  25605. * * VertexBuffer.UV4Kind
  25606. * * VertexBuffer.UV5Kind
  25607. * * VertexBuffer.UV6Kind
  25608. * * VertexBuffer.ColorKind
  25609. * * VertexBuffer.MatricesIndicesKind
  25610. * * VertexBuffer.MatricesIndicesExtraKind
  25611. * * VertexBuffer.MatricesWeightsKind
  25612. * * VertexBuffer.MatricesWeightsExtraKind
  25613. * @param data defines the data source
  25614. * @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
  25615. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25616. * @returns the current mesh
  25617. */
  25618. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25619. /**
  25620. * Sets the mesh indices,
  25621. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25622. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25623. * @param totalVertices Defines the total number of vertices
  25624. * @returns the current mesh
  25625. */
  25626. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25627. /**
  25628. * Gets a boolean indicating if specific vertex data is present
  25629. * @param kind defines the vertex data kind to use
  25630. * @returns true is data kind is present
  25631. */
  25632. isVerticesDataPresent(kind: string): boolean;
  25633. /**
  25634. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  25635. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  25636. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  25637. * @returns a BoundingInfo
  25638. */
  25639. getBoundingInfo(): BoundingInfo;
  25640. /**
  25641. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25642. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25643. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25644. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  25645. * @returns the current mesh
  25646. */
  25647. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  25648. /**
  25649. * Overwrite the current bounding info
  25650. * @param boundingInfo defines the new bounding info
  25651. * @returns the current mesh
  25652. */
  25653. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25654. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25655. readonly useBones: boolean;
  25656. /** @hidden */
  25657. _preActivate(): void;
  25658. /** @hidden */
  25659. _preActivateForIntermediateRendering(renderId: number): void;
  25660. /** @hidden */
  25661. _activate(renderId: number, intermediateRendering: boolean): boolean;
  25662. /** @hidden */
  25663. _postActivate(): void;
  25664. /** @hidden */
  25665. _freeze(): void;
  25666. /** @hidden */
  25667. _unFreeze(): void;
  25668. /**
  25669. * Gets the current world matrix
  25670. * @returns a Matrix
  25671. */
  25672. getWorldMatrix(): Matrix;
  25673. /** @hidden */
  25674. _getWorldMatrixDeterminant(): number;
  25675. /**
  25676. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25677. */
  25678. readonly isAnInstance: boolean;
  25679. /**
  25680. * Perform relative position change from the point of view of behind the front of the mesh.
  25681. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25682. * Supports definition of mesh facing forward or backward
  25683. * @param amountRight defines the distance on the right axis
  25684. * @param amountUp defines the distance on the up axis
  25685. * @param amountForward defines the distance on the forward axis
  25686. * @returns the current mesh
  25687. */
  25688. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25689. /**
  25690. * Calculate relative position change from the point of view of behind the front of the mesh.
  25691. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25692. * Supports definition of mesh facing forward or backward
  25693. * @param amountRight defines the distance on the right axis
  25694. * @param amountUp defines the distance on the up axis
  25695. * @param amountForward defines the distance on the forward axis
  25696. * @returns the new displacement vector
  25697. */
  25698. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25699. /**
  25700. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25701. * Supports definition of mesh facing forward or backward
  25702. * @param flipBack defines the flip
  25703. * @param twirlClockwise defines the twirl
  25704. * @param tiltRight defines the tilt
  25705. * @returns the current mesh
  25706. */
  25707. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25708. /**
  25709. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25710. * Supports definition of mesh facing forward or backward.
  25711. * @param flipBack defines the flip
  25712. * @param twirlClockwise defines the twirl
  25713. * @param tiltRight defines the tilt
  25714. * @returns the new rotation vector
  25715. */
  25716. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25717. /**
  25718. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25719. * This means the mesh underlying bounding box and sphere are recomputed.
  25720. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25721. * @returns the current mesh
  25722. */
  25723. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25724. /** @hidden */
  25725. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25726. /** @hidden */
  25727. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25728. /** @hidden */
  25729. _updateBoundingInfo(): AbstractMesh;
  25730. /** @hidden */
  25731. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25732. /** @hidden */
  25733. protected _afterComputeWorldMatrix(): void;
  25734. /** @hidden */
  25735. readonly _effectiveMesh: AbstractMesh;
  25736. /**
  25737. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25738. * A mesh is in the frustum if its bounding box intersects the frustum
  25739. * @param frustumPlanes defines the frustum to test
  25740. * @returns true if the mesh is in the frustum planes
  25741. */
  25742. isInFrustum(frustumPlanes: Plane[]): boolean;
  25743. /**
  25744. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25745. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25746. * @param frustumPlanes defines the frustum to test
  25747. * @returns true if the mesh is completely in the frustum planes
  25748. */
  25749. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25750. /**
  25751. * True if the mesh intersects another mesh or a SolidParticle object
  25752. * @param mesh defines a target mesh or SolidParticle to test
  25753. * @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)
  25754. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25755. * @returns true if there is an intersection
  25756. */
  25757. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25758. /**
  25759. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25760. * @param point defines the point to test
  25761. * @returns true if there is an intersection
  25762. */
  25763. intersectsPoint(point: Vector3): boolean;
  25764. /**
  25765. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25766. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25767. */
  25768. checkCollisions: boolean;
  25769. /**
  25770. * Gets Collider object used to compute collisions (not physics)
  25771. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25772. */
  25773. readonly collider: Nullable<Collider>;
  25774. /**
  25775. * Move the mesh using collision engine
  25776. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25777. * @param displacement defines the requested displacement vector
  25778. * @returns the current mesh
  25779. */
  25780. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25781. private _onCollisionPositionChange;
  25782. /** @hidden */
  25783. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25784. /** @hidden */
  25785. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25786. /** @hidden */
  25787. _checkCollision(collider: Collider): AbstractMesh;
  25788. /** @hidden */
  25789. _generatePointsArray(): boolean;
  25790. /**
  25791. * Checks if the passed Ray intersects with the mesh
  25792. * @param ray defines the ray to use
  25793. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25794. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25795. * @returns the picking info
  25796. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25797. */
  25798. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25799. /**
  25800. * Clones the current mesh
  25801. * @param name defines the mesh name
  25802. * @param newParent defines the new mesh parent
  25803. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25804. * @returns the new mesh
  25805. */
  25806. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25807. /**
  25808. * Disposes all the submeshes of the current meshnp
  25809. * @returns the current mesh
  25810. */
  25811. releaseSubMeshes(): AbstractMesh;
  25812. /**
  25813. * Releases resources associated with this abstract mesh.
  25814. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25815. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25816. */
  25817. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25818. /**
  25819. * Adds the passed mesh as a child to the current mesh
  25820. * @param mesh defines the child mesh
  25821. * @returns the current mesh
  25822. */
  25823. addChild(mesh: AbstractMesh): AbstractMesh;
  25824. /**
  25825. * Removes the passed mesh from the current mesh children list
  25826. * @param mesh defines the child mesh
  25827. * @returns the current mesh
  25828. */
  25829. removeChild(mesh: AbstractMesh): AbstractMesh;
  25830. /** @hidden */
  25831. private _initFacetData;
  25832. /**
  25833. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25834. * This method can be called within the render loop.
  25835. * 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
  25836. * @returns the current mesh
  25837. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25838. */
  25839. updateFacetData(): AbstractMesh;
  25840. /**
  25841. * Returns the facetLocalNormals array.
  25842. * The normals are expressed in the mesh local spac
  25843. * @returns an array of Vector3
  25844. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25845. */
  25846. getFacetLocalNormals(): Vector3[];
  25847. /**
  25848. * Returns the facetLocalPositions array.
  25849. * The facet positions are expressed in the mesh local space
  25850. * @returns an array of Vector3
  25851. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25852. */
  25853. getFacetLocalPositions(): Vector3[];
  25854. /**
  25855. * Returns the facetLocalPartioning array
  25856. * @returns an array of array of numbers
  25857. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25858. */
  25859. getFacetLocalPartitioning(): number[][];
  25860. /**
  25861. * Returns the i-th facet position in the world system.
  25862. * This method allocates a new Vector3 per call
  25863. * @param i defines the facet index
  25864. * @returns a new Vector3
  25865. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25866. */
  25867. getFacetPosition(i: number): Vector3;
  25868. /**
  25869. * Sets the reference Vector3 with the i-th facet position in the world system
  25870. * @param i defines the facet index
  25871. * @param ref defines the target vector
  25872. * @returns the current mesh
  25873. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25874. */
  25875. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25876. /**
  25877. * Returns the i-th facet normal in the world system.
  25878. * This method allocates a new Vector3 per call
  25879. * @param i defines the facet index
  25880. * @returns a new Vector3
  25881. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25882. */
  25883. getFacetNormal(i: number): Vector3;
  25884. /**
  25885. * Sets the reference Vector3 with the i-th facet normal in the world system
  25886. * @param i defines the facet index
  25887. * @param ref defines the target vector
  25888. * @returns the current mesh
  25889. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25890. */
  25891. getFacetNormalToRef(i: number, ref: Vector3): this;
  25892. /**
  25893. * 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)
  25894. * @param x defines x coordinate
  25895. * @param y defines y coordinate
  25896. * @param z defines z coordinate
  25897. * @returns the array of facet indexes
  25898. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25899. */
  25900. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25901. /**
  25902. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25903. * @param projected sets as the (x,y,z) world projection on the facet
  25904. * @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
  25905. * @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
  25906. * @param x defines x coordinate
  25907. * @param y defines y coordinate
  25908. * @param z defines z coordinate
  25909. * @returns the face index if found (or null instead)
  25910. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25911. */
  25912. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25913. /**
  25914. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25915. * @param projected sets as the (x,y,z) local projection on the facet
  25916. * @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
  25917. * @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
  25918. * @param x defines x coordinate
  25919. * @param y defines y coordinate
  25920. * @param z defines z coordinate
  25921. * @returns the face index if found (or null instead)
  25922. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25923. */
  25924. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25925. /**
  25926. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25927. * @returns the parameters
  25928. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25929. */
  25930. getFacetDataParameters(): any;
  25931. /**
  25932. * Disables the feature FacetData and frees the related memory
  25933. * @returns the current mesh
  25934. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25935. */
  25936. disableFacetData(): AbstractMesh;
  25937. /**
  25938. * Updates the AbstractMesh indices array
  25939. * @param indices defines the data source
  25940. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25941. * @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)
  25942. * @returns the current mesh
  25943. */
  25944. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25945. /**
  25946. * Creates new normals data for the mesh
  25947. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25948. * @returns the current mesh
  25949. */
  25950. createNormals(updatable: boolean): AbstractMesh;
  25951. /**
  25952. * Align the mesh with a normal
  25953. * @param normal defines the normal to use
  25954. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25955. * @returns the current mesh
  25956. */
  25957. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25958. /** @hidden */
  25959. _checkOcclusionQuery(): boolean;
  25960. /**
  25961. * Disables the mesh edge rendering mode
  25962. * @returns the currentAbstractMesh
  25963. */
  25964. disableEdgesRendering(): AbstractMesh;
  25965. /**
  25966. * Enables the edge rendering mode on the mesh.
  25967. * This mode makes the mesh edges visible
  25968. * @param epsilon defines the maximal distance between two angles to detect a face
  25969. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  25970. * @returns the currentAbstractMesh
  25971. * @see https://www.babylonjs-playground.com/#19O9TU#0
  25972. */
  25973. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  25974. }
  25975. }
  25976. declare module "babylonjs/Actions/actionEvent" {
  25977. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25978. import { Nullable } from "babylonjs/types";
  25979. import { Sprite } from "babylonjs/Sprites/sprite";
  25980. import { Scene } from "babylonjs/scene";
  25981. import { Vector2 } from "babylonjs/Maths/math";
  25982. /**
  25983. * Interface used to define ActionEvent
  25984. */
  25985. export interface IActionEvent {
  25986. /** The mesh or sprite that triggered the action */
  25987. source: any;
  25988. /** The X mouse cursor position at the time of the event */
  25989. pointerX: number;
  25990. /** The Y mouse cursor position at the time of the event */
  25991. pointerY: number;
  25992. /** The mesh that is currently pointed at (can be null) */
  25993. meshUnderPointer: Nullable<AbstractMesh>;
  25994. /** the original (browser) event that triggered the ActionEvent */
  25995. sourceEvent?: any;
  25996. /** additional data for the event */
  25997. additionalData?: any;
  25998. }
  25999. /**
  26000. * ActionEvent is the event being sent when an action is triggered.
  26001. */
  26002. export class ActionEvent implements IActionEvent {
  26003. /** The mesh or sprite that triggered the action */
  26004. source: any;
  26005. /** The X mouse cursor position at the time of the event */
  26006. pointerX: number;
  26007. /** The Y mouse cursor position at the time of the event */
  26008. pointerY: number;
  26009. /** The mesh that is currently pointed at (can be null) */
  26010. meshUnderPointer: Nullable<AbstractMesh>;
  26011. /** the original (browser) event that triggered the ActionEvent */
  26012. sourceEvent?: any;
  26013. /** additional data for the event */
  26014. additionalData?: any;
  26015. /**
  26016. * Creates a new ActionEvent
  26017. * @param source The mesh or sprite that triggered the action
  26018. * @param pointerX The X mouse cursor position at the time of the event
  26019. * @param pointerY The Y mouse cursor position at the time of the event
  26020. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  26021. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  26022. * @param additionalData additional data for the event
  26023. */
  26024. constructor(
  26025. /** The mesh or sprite that triggered the action */
  26026. source: any,
  26027. /** The X mouse cursor position at the time of the event */
  26028. pointerX: number,
  26029. /** The Y mouse cursor position at the time of the event */
  26030. pointerY: number,
  26031. /** The mesh that is currently pointed at (can be null) */
  26032. meshUnderPointer: Nullable<AbstractMesh>,
  26033. /** the original (browser) event that triggered the ActionEvent */
  26034. sourceEvent?: any,
  26035. /** additional data for the event */
  26036. additionalData?: any);
  26037. /**
  26038. * Helper function to auto-create an ActionEvent from a source mesh.
  26039. * @param source The source mesh that triggered the event
  26040. * @param evt The original (browser) event
  26041. * @param additionalData additional data for the event
  26042. * @returns the new ActionEvent
  26043. */
  26044. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  26045. /**
  26046. * Helper function to auto-create an ActionEvent from a source sprite
  26047. * @param source The source sprite that triggered the event
  26048. * @param scene Scene associated with the sprite
  26049. * @param evt The original (browser) event
  26050. * @param additionalData additional data for the event
  26051. * @returns the new ActionEvent
  26052. */
  26053. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  26054. /**
  26055. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  26056. * @param scene the scene where the event occurred
  26057. * @param evt The original (browser) event
  26058. * @returns the new ActionEvent
  26059. */
  26060. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  26061. /**
  26062. * Helper function to auto-create an ActionEvent from a primitive
  26063. * @param prim defines the target primitive
  26064. * @param pointerPos defines the pointer position
  26065. * @param evt The original (browser) event
  26066. * @param additionalData additional data for the event
  26067. * @returns the new ActionEvent
  26068. */
  26069. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  26070. }
  26071. }
  26072. declare module "babylonjs/Actions/abstractActionManager" {
  26073. import { IDisposable } from "babylonjs/scene";
  26074. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  26075. import { IAction } from "babylonjs/Actions/action";
  26076. import { Nullable } from "babylonjs/types";
  26077. /**
  26078. * Abstract class used to decouple action Manager from scene and meshes.
  26079. * Do not instantiate.
  26080. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26081. */
  26082. export abstract class AbstractActionManager implements IDisposable {
  26083. /** Gets the list of active triggers */
  26084. static Triggers: {
  26085. [key: string]: number;
  26086. };
  26087. /** Gets the cursor to use when hovering items */
  26088. hoverCursor: string;
  26089. /** Gets the list of actions */
  26090. actions: IAction[];
  26091. /**
  26092. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  26093. */
  26094. isRecursive: boolean;
  26095. /**
  26096. * Releases all associated resources
  26097. */
  26098. abstract dispose(): void;
  26099. /**
  26100. * Does this action manager has pointer triggers
  26101. */
  26102. abstract readonly hasPointerTriggers: boolean;
  26103. /**
  26104. * Does this action manager has pick triggers
  26105. */
  26106. abstract readonly hasPickTriggers: boolean;
  26107. /**
  26108. * Process a specific trigger
  26109. * @param trigger defines the trigger to process
  26110. * @param evt defines the event details to be processed
  26111. */
  26112. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  26113. /**
  26114. * Does this action manager handles actions of any of the given triggers
  26115. * @param triggers defines the triggers to be tested
  26116. * @return a boolean indicating whether one (or more) of the triggers is handled
  26117. */
  26118. abstract hasSpecificTriggers(triggers: number[]): boolean;
  26119. /**
  26120. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  26121. * speed.
  26122. * @param triggerA defines the trigger to be tested
  26123. * @param triggerB defines the trigger to be tested
  26124. * @return a boolean indicating whether one (or more) of the triggers is handled
  26125. */
  26126. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26127. /**
  26128. * Does this action manager handles actions of a given trigger
  26129. * @param trigger defines the trigger to be tested
  26130. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26131. * @return whether the trigger is handled
  26132. */
  26133. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26134. /**
  26135. * Serialize this manager to a JSON object
  26136. * @param name defines the property name to store this manager
  26137. * @returns a JSON representation of this manager
  26138. */
  26139. abstract serialize(name: string): any;
  26140. /**
  26141. * Registers an action to this action manager
  26142. * @param action defines the action to be registered
  26143. * @return the action amended (prepared) after registration
  26144. */
  26145. abstract registerAction(action: IAction): Nullable<IAction>;
  26146. /**
  26147. * Unregisters an action to this action manager
  26148. * @param action defines the action to be unregistered
  26149. * @return a boolean indicating whether the action has been unregistered
  26150. */
  26151. abstract unregisterAction(action: IAction): Boolean;
  26152. /**
  26153. * Does exist one action manager with at least one trigger
  26154. **/
  26155. static readonly HasTriggers: boolean;
  26156. /**
  26157. * Does exist one action manager with at least one pick trigger
  26158. **/
  26159. static readonly HasPickTriggers: boolean;
  26160. /**
  26161. * Does exist one action manager that handles actions of a given trigger
  26162. * @param trigger defines the trigger to be tested
  26163. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26164. **/
  26165. static HasSpecificTrigger(trigger: number): boolean;
  26166. }
  26167. }
  26168. declare module "babylonjs/node" {
  26169. import { Scene } from "babylonjs/scene";
  26170. import { Nullable } from "babylonjs/types";
  26171. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  26172. import { Engine } from "babylonjs/Engines/engine";
  26173. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  26174. import { Observable } from "babylonjs/Misc/observable";
  26175. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26176. import { IInspectable } from "babylonjs/Misc/iInspectable";
  26177. import { Animatable } from "babylonjs/Animations/animatable";
  26178. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26179. import { Animation } from "babylonjs/Animations/animation";
  26180. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26181. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26182. /**
  26183. * Defines how a node can be built from a string name.
  26184. */
  26185. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26186. /**
  26187. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26188. */
  26189. export class Node implements IBehaviorAware<Node> {
  26190. /** @hidden */
  26191. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  26192. private static _NodeConstructors;
  26193. /**
  26194. * Add a new node constructor
  26195. * @param type defines the type name of the node to construct
  26196. * @param constructorFunc defines the constructor function
  26197. */
  26198. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26199. /**
  26200. * Returns a node constructor based on type name
  26201. * @param type defines the type name
  26202. * @param name defines the new node name
  26203. * @param scene defines the hosting scene
  26204. * @param options defines optional options to transmit to constructors
  26205. * @returns the new constructor or null
  26206. */
  26207. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26208. /**
  26209. * Gets or sets the name of the node
  26210. */
  26211. name: string;
  26212. /**
  26213. * Gets or sets the id of the node
  26214. */
  26215. id: string;
  26216. /**
  26217. * Gets or sets the unique id of the node
  26218. */
  26219. uniqueId: number;
  26220. /**
  26221. * Gets or sets a string used to store user defined state for the node
  26222. */
  26223. state: string;
  26224. /**
  26225. * Gets or sets an object used to store user defined information for the node
  26226. */
  26227. metadata: any;
  26228. /**
  26229. * For internal use only. Please do not use.
  26230. */
  26231. reservedDataStore: any;
  26232. /**
  26233. * List of inspectable custom properties (used by the Inspector)
  26234. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26235. */
  26236. inspectableCustomProperties: IInspectable[];
  26237. /**
  26238. * Gets or sets a boolean used to define if the node must be serialized
  26239. */
  26240. doNotSerialize: boolean;
  26241. /** @hidden */
  26242. _isDisposed: boolean;
  26243. /**
  26244. * Gets a list of Animations associated with the node
  26245. */
  26246. animations: import("babylonjs/Animations/animation").Animation[];
  26247. protected _ranges: {
  26248. [name: string]: Nullable<AnimationRange>;
  26249. };
  26250. /**
  26251. * Callback raised when the node is ready to be used
  26252. */
  26253. onReady: Nullable<(node: Node) => void>;
  26254. private _isEnabled;
  26255. private _isParentEnabled;
  26256. private _isReady;
  26257. /** @hidden */
  26258. _currentRenderId: number;
  26259. private _parentUpdateId;
  26260. /** @hidden */
  26261. _childUpdateId: number;
  26262. /** @hidden */
  26263. _waitingParentId: Nullable<string>;
  26264. /** @hidden */
  26265. _scene: Scene;
  26266. /** @hidden */
  26267. _cache: any;
  26268. private _parentNode;
  26269. private _children;
  26270. /** @hidden */
  26271. _worldMatrix: Matrix;
  26272. /** @hidden */
  26273. _worldMatrixDeterminant: number;
  26274. /** @hidden */
  26275. _worldMatrixDeterminantIsDirty: boolean;
  26276. /** @hidden */
  26277. private _sceneRootNodesIndex;
  26278. /**
  26279. * Gets a boolean indicating if the node has been disposed
  26280. * @returns true if the node was disposed
  26281. */
  26282. isDisposed(): boolean;
  26283. /**
  26284. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26285. * @see https://doc.babylonjs.com/how_to/parenting
  26286. */
  26287. parent: Nullable<Node>;
  26288. private addToSceneRootNodes;
  26289. private removeFromSceneRootNodes;
  26290. private _animationPropertiesOverride;
  26291. /**
  26292. * Gets or sets the animation properties override
  26293. */
  26294. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26295. /**
  26296. * Gets a string idenfifying the name of the class
  26297. * @returns "Node" string
  26298. */
  26299. getClassName(): string;
  26300. /** @hidden */
  26301. readonly _isNode: boolean;
  26302. /**
  26303. * An event triggered when the mesh is disposed
  26304. */
  26305. onDisposeObservable: Observable<Node>;
  26306. private _onDisposeObserver;
  26307. /**
  26308. * Sets a callback that will be raised when the node will be disposed
  26309. */
  26310. onDispose: () => void;
  26311. /**
  26312. * Creates a new Node
  26313. * @param name the name and id to be given to this node
  26314. * @param scene the scene this node will be added to
  26315. * @param addToRootNodes the node will be added to scene.rootNodes
  26316. */
  26317. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26318. /**
  26319. * Gets the scene of the node
  26320. * @returns a scene
  26321. */
  26322. getScene(): Scene;
  26323. /**
  26324. * Gets the engine of the node
  26325. * @returns a Engine
  26326. */
  26327. getEngine(): Engine;
  26328. private _behaviors;
  26329. /**
  26330. * Attach a behavior to the node
  26331. * @see http://doc.babylonjs.com/features/behaviour
  26332. * @param behavior defines the behavior to attach
  26333. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26334. * @returns the current Node
  26335. */
  26336. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26337. /**
  26338. * Remove an attached behavior
  26339. * @see http://doc.babylonjs.com/features/behaviour
  26340. * @param behavior defines the behavior to attach
  26341. * @returns the current Node
  26342. */
  26343. removeBehavior(behavior: Behavior<Node>): Node;
  26344. /**
  26345. * Gets the list of attached behaviors
  26346. * @see http://doc.babylonjs.com/features/behaviour
  26347. */
  26348. readonly behaviors: Behavior<Node>[];
  26349. /**
  26350. * Gets an attached behavior by name
  26351. * @param name defines the name of the behavior to look for
  26352. * @see http://doc.babylonjs.com/features/behaviour
  26353. * @returns null if behavior was not found else the requested behavior
  26354. */
  26355. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26356. /**
  26357. * Returns the latest update of the World matrix
  26358. * @returns a Matrix
  26359. */
  26360. getWorldMatrix(): Matrix;
  26361. /** @hidden */
  26362. _getWorldMatrixDeterminant(): number;
  26363. /**
  26364. * Returns directly the latest state of the mesh World matrix.
  26365. * A Matrix is returned.
  26366. */
  26367. readonly worldMatrixFromCache: Matrix;
  26368. /** @hidden */
  26369. _initCache(): void;
  26370. /** @hidden */
  26371. updateCache(force?: boolean): void;
  26372. /** @hidden */
  26373. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26374. /** @hidden */
  26375. _updateCache(ignoreParentClass?: boolean): void;
  26376. /** @hidden */
  26377. _isSynchronized(): boolean;
  26378. /** @hidden */
  26379. _markSyncedWithParent(): void;
  26380. /** @hidden */
  26381. isSynchronizedWithParent(): boolean;
  26382. /** @hidden */
  26383. isSynchronized(): boolean;
  26384. /**
  26385. * Is this node ready to be used/rendered
  26386. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26387. * @return true if the node is ready
  26388. */
  26389. isReady(completeCheck?: boolean): boolean;
  26390. /**
  26391. * Is this node enabled?
  26392. * 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
  26393. * @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
  26394. * @return whether this node (and its parent) is enabled
  26395. */
  26396. isEnabled(checkAncestors?: boolean): boolean;
  26397. /** @hidden */
  26398. protected _syncParentEnabledState(): void;
  26399. /**
  26400. * Set the enabled state of this node
  26401. * @param value defines the new enabled state
  26402. */
  26403. setEnabled(value: boolean): void;
  26404. /**
  26405. * Is this node a descendant of the given node?
  26406. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26407. * @param ancestor defines the parent node to inspect
  26408. * @returns a boolean indicating if this node is a descendant of the given node
  26409. */
  26410. isDescendantOf(ancestor: Node): boolean;
  26411. /** @hidden */
  26412. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26413. /**
  26414. * Will return all nodes that have this node as ascendant
  26415. * @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
  26416. * @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
  26417. * @return all children nodes of all types
  26418. */
  26419. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26420. /**
  26421. * Get all child-meshes of this node
  26422. * @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)
  26423. * @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
  26424. * @returns an array of AbstractMesh
  26425. */
  26426. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26427. /**
  26428. * Get all direct children of this node
  26429. * @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
  26430. * @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)
  26431. * @returns an array of Node
  26432. */
  26433. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26434. /** @hidden */
  26435. _setReady(state: boolean): void;
  26436. /**
  26437. * Get an animation by name
  26438. * @param name defines the name of the animation to look for
  26439. * @returns null if not found else the requested animation
  26440. */
  26441. getAnimationByName(name: string): Nullable<Animation>;
  26442. /**
  26443. * Creates an animation range for this node
  26444. * @param name defines the name of the range
  26445. * @param from defines the starting key
  26446. * @param to defines the end key
  26447. */
  26448. createAnimationRange(name: string, from: number, to: number): void;
  26449. /**
  26450. * Delete a specific animation range
  26451. * @param name defines the name of the range to delete
  26452. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26453. */
  26454. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26455. /**
  26456. * Get an animation range by name
  26457. * @param name defines the name of the animation range to look for
  26458. * @returns null if not found else the requested animation range
  26459. */
  26460. getAnimationRange(name: string): Nullable<AnimationRange>;
  26461. /**
  26462. * Gets the list of all animation ranges defined on this node
  26463. * @returns an array
  26464. */
  26465. getAnimationRanges(): Nullable<AnimationRange>[];
  26466. /**
  26467. * Will start the animation sequence
  26468. * @param name defines the range frames for animation sequence
  26469. * @param loop defines if the animation should loop (false by default)
  26470. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26471. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26472. * @returns the object created for this animation. If range does not exist, it will return null
  26473. */
  26474. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26475. /**
  26476. * Serialize animation ranges into a JSON compatible object
  26477. * @returns serialization object
  26478. */
  26479. serializeAnimationRanges(): any;
  26480. /**
  26481. * Computes the world matrix of the node
  26482. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26483. * @returns the world matrix
  26484. */
  26485. computeWorldMatrix(force?: boolean): Matrix;
  26486. /**
  26487. * Releases resources associated with this node.
  26488. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26489. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26490. */
  26491. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26492. /**
  26493. * Parse animation range data from a serialization object and store them into a given node
  26494. * @param node defines where to store the animation ranges
  26495. * @param parsedNode defines the serialization object to read data from
  26496. * @param scene defines the hosting scene
  26497. */
  26498. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26499. /**
  26500. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26501. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26502. * @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
  26503. * @returns the new bounding vectors
  26504. */
  26505. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26506. min: Vector3;
  26507. max: Vector3;
  26508. };
  26509. }
  26510. }
  26511. declare module "babylonjs/Animations/animation" {
  26512. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  26513. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  26514. import { Nullable } from "babylonjs/types";
  26515. import { Scene } from "babylonjs/scene";
  26516. import { IAnimatable } from "babylonjs/Misc/tools";
  26517. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  26518. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26519. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  26520. import { Node } from "babylonjs/node";
  26521. import { Animatable } from "babylonjs/Animations/animatable";
  26522. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  26523. /**
  26524. * @hidden
  26525. */
  26526. export class _IAnimationState {
  26527. key: number;
  26528. repeatCount: number;
  26529. workValue?: any;
  26530. loopMode?: number;
  26531. offsetValue?: any;
  26532. highLimitValue?: any;
  26533. }
  26534. /**
  26535. * Class used to store any kind of animation
  26536. */
  26537. export class Animation {
  26538. /**Name of the animation */
  26539. name: string;
  26540. /**Property to animate */
  26541. targetProperty: string;
  26542. /**The frames per second of the animation */
  26543. framePerSecond: number;
  26544. /**The data type of the animation */
  26545. dataType: number;
  26546. /**The loop mode of the animation */
  26547. loopMode?: number | undefined;
  26548. /**Specifies if blending should be enabled */
  26549. enableBlending?: boolean | undefined;
  26550. /**
  26551. * Use matrix interpolation instead of using direct key value when animating matrices
  26552. */
  26553. static AllowMatricesInterpolation: boolean;
  26554. /**
  26555. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26556. */
  26557. static AllowMatrixDecomposeForInterpolation: boolean;
  26558. /**
  26559. * Stores the key frames of the animation
  26560. */
  26561. private _keys;
  26562. /**
  26563. * Stores the easing function of the animation
  26564. */
  26565. private _easingFunction;
  26566. /**
  26567. * @hidden Internal use only
  26568. */
  26569. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  26570. /**
  26571. * The set of event that will be linked to this animation
  26572. */
  26573. private _events;
  26574. /**
  26575. * Stores an array of target property paths
  26576. */
  26577. targetPropertyPath: string[];
  26578. /**
  26579. * Stores the blending speed of the animation
  26580. */
  26581. blendingSpeed: number;
  26582. /**
  26583. * Stores the animation ranges for the animation
  26584. */
  26585. private _ranges;
  26586. /**
  26587. * @hidden Internal use
  26588. */
  26589. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26590. /**
  26591. * Sets up an animation
  26592. * @param property The property to animate
  26593. * @param animationType The animation type to apply
  26594. * @param framePerSecond The frames per second of the animation
  26595. * @param easingFunction The easing function used in the animation
  26596. * @returns The created animation
  26597. */
  26598. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26599. /**
  26600. * Create and start an animation on a node
  26601. * @param name defines the name of the global animation that will be run on all nodes
  26602. * @param node defines the root node where the animation will take place
  26603. * @param targetProperty defines property to animate
  26604. * @param framePerSecond defines the number of frame per second yo use
  26605. * @param totalFrame defines the number of frames in total
  26606. * @param from defines the initial value
  26607. * @param to defines the final value
  26608. * @param loopMode defines which loop mode you want to use (off by default)
  26609. * @param easingFunction defines the easing function to use (linear by default)
  26610. * @param onAnimationEnd defines the callback to call when animation end
  26611. * @returns the animatable created for this animation
  26612. */
  26613. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26614. /**
  26615. * Create and start an animation on a node and its descendants
  26616. * @param name defines the name of the global animation that will be run on all nodes
  26617. * @param node defines the root node where the animation will take place
  26618. * @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
  26619. * @param targetProperty defines property to animate
  26620. * @param framePerSecond defines the number of frame per second to use
  26621. * @param totalFrame defines the number of frames in total
  26622. * @param from defines the initial value
  26623. * @param to defines the final value
  26624. * @param loopMode defines which loop mode you want to use (off by default)
  26625. * @param easingFunction defines the easing function to use (linear by default)
  26626. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26627. * @returns the list of animatables created for all nodes
  26628. * @example https://www.babylonjs-playground.com/#MH0VLI
  26629. */
  26630. 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[]>;
  26631. /**
  26632. * Creates a new animation, merges it with the existing animations and starts it
  26633. * @param name Name of the animation
  26634. * @param node Node which contains the scene that begins the animations
  26635. * @param targetProperty Specifies which property to animate
  26636. * @param framePerSecond The frames per second of the animation
  26637. * @param totalFrame The total number of frames
  26638. * @param from The frame at the beginning of the animation
  26639. * @param to The frame at the end of the animation
  26640. * @param loopMode Specifies the loop mode of the animation
  26641. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26642. * @param onAnimationEnd Callback to run once the animation is complete
  26643. * @returns Nullable animation
  26644. */
  26645. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26646. /**
  26647. * Transition property of an host to the target Value
  26648. * @param property The property to transition
  26649. * @param targetValue The target Value of the property
  26650. * @param host The object where the property to animate belongs
  26651. * @param scene Scene used to run the animation
  26652. * @param frameRate Framerate (in frame/s) to use
  26653. * @param transition The transition type we want to use
  26654. * @param duration The duration of the animation, in milliseconds
  26655. * @param onAnimationEnd Callback trigger at the end of the animation
  26656. * @returns Nullable animation
  26657. */
  26658. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26659. /**
  26660. * Return the array of runtime animations currently using this animation
  26661. */
  26662. readonly runtimeAnimations: RuntimeAnimation[];
  26663. /**
  26664. * Specifies if any of the runtime animations are currently running
  26665. */
  26666. readonly hasRunningRuntimeAnimations: boolean;
  26667. /**
  26668. * Initializes the animation
  26669. * @param name Name of the animation
  26670. * @param targetProperty Property to animate
  26671. * @param framePerSecond The frames per second of the animation
  26672. * @param dataType The data type of the animation
  26673. * @param loopMode The loop mode of the animation
  26674. * @param enableBlending Specifies if blending should be enabled
  26675. */
  26676. constructor(
  26677. /**Name of the animation */
  26678. name: string,
  26679. /**Property to animate */
  26680. targetProperty: string,
  26681. /**The frames per second of the animation */
  26682. framePerSecond: number,
  26683. /**The data type of the animation */
  26684. dataType: number,
  26685. /**The loop mode of the animation */
  26686. loopMode?: number | undefined,
  26687. /**Specifies if blending should be enabled */
  26688. enableBlending?: boolean | undefined);
  26689. /**
  26690. * Converts the animation to a string
  26691. * @param fullDetails support for multiple levels of logging within scene loading
  26692. * @returns String form of the animation
  26693. */
  26694. toString(fullDetails?: boolean): string;
  26695. /**
  26696. * Add an event to this animation
  26697. * @param event Event to add
  26698. */
  26699. addEvent(event: AnimationEvent): void;
  26700. /**
  26701. * Remove all events found at the given frame
  26702. * @param frame The frame to remove events from
  26703. */
  26704. removeEvents(frame: number): void;
  26705. /**
  26706. * Retrieves all the events from the animation
  26707. * @returns Events from the animation
  26708. */
  26709. getEvents(): AnimationEvent[];
  26710. /**
  26711. * Creates an animation range
  26712. * @param name Name of the animation range
  26713. * @param from Starting frame of the animation range
  26714. * @param to Ending frame of the animation
  26715. */
  26716. createRange(name: string, from: number, to: number): void;
  26717. /**
  26718. * Deletes an animation range by name
  26719. * @param name Name of the animation range to delete
  26720. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26721. */
  26722. deleteRange(name: string, deleteFrames?: boolean): void;
  26723. /**
  26724. * Gets the animation range by name, or null if not defined
  26725. * @param name Name of the animation range
  26726. * @returns Nullable animation range
  26727. */
  26728. getRange(name: string): Nullable<AnimationRange>;
  26729. /**
  26730. * Gets the key frames from the animation
  26731. * @returns The key frames of the animation
  26732. */
  26733. getKeys(): Array<IAnimationKey>;
  26734. /**
  26735. * Gets the highest frame rate of the animation
  26736. * @returns Highest frame rate of the animation
  26737. */
  26738. getHighestFrame(): number;
  26739. /**
  26740. * Gets the easing function of the animation
  26741. * @returns Easing function of the animation
  26742. */
  26743. getEasingFunction(): IEasingFunction;
  26744. /**
  26745. * Sets the easing function of the animation
  26746. * @param easingFunction A custom mathematical formula for animation
  26747. */
  26748. setEasingFunction(easingFunction: EasingFunction): void;
  26749. /**
  26750. * Interpolates a scalar linearly
  26751. * @param startValue Start value of the animation curve
  26752. * @param endValue End value of the animation curve
  26753. * @param gradient Scalar amount to interpolate
  26754. * @returns Interpolated scalar value
  26755. */
  26756. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26757. /**
  26758. * Interpolates a scalar cubically
  26759. * @param startValue Start value of the animation curve
  26760. * @param outTangent End tangent of the animation
  26761. * @param endValue End value of the animation curve
  26762. * @param inTangent Start tangent of the animation curve
  26763. * @param gradient Scalar amount to interpolate
  26764. * @returns Interpolated scalar value
  26765. */
  26766. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26767. /**
  26768. * Interpolates a quaternion using a spherical linear interpolation
  26769. * @param startValue Start value of the animation curve
  26770. * @param endValue End value of the animation curve
  26771. * @param gradient Scalar amount to interpolate
  26772. * @returns Interpolated quaternion value
  26773. */
  26774. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26775. /**
  26776. * Interpolates a quaternion cubically
  26777. * @param startValue Start value of the animation curve
  26778. * @param outTangent End tangent of the animation curve
  26779. * @param endValue End value of the animation curve
  26780. * @param inTangent Start tangent of the animation curve
  26781. * @param gradient Scalar amount to interpolate
  26782. * @returns Interpolated quaternion value
  26783. */
  26784. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26785. /**
  26786. * Interpolates a Vector3 linearl
  26787. * @param startValue Start value of the animation curve
  26788. * @param endValue End value of the animation curve
  26789. * @param gradient Scalar amount to interpolate
  26790. * @returns Interpolated scalar value
  26791. */
  26792. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26793. /**
  26794. * Interpolates a Vector3 cubically
  26795. * @param startValue Start value of the animation curve
  26796. * @param outTangent End tangent of the animation
  26797. * @param endValue End value of the animation curve
  26798. * @param inTangent Start tangent of the animation curve
  26799. * @param gradient Scalar amount to interpolate
  26800. * @returns InterpolatedVector3 value
  26801. */
  26802. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26803. /**
  26804. * Interpolates a Vector2 linearly
  26805. * @param startValue Start value of the animation curve
  26806. * @param endValue End value of the animation curve
  26807. * @param gradient Scalar amount to interpolate
  26808. * @returns Interpolated Vector2 value
  26809. */
  26810. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26811. /**
  26812. * Interpolates a Vector2 cubically
  26813. * @param startValue Start value of the animation curve
  26814. * @param outTangent End tangent of the animation
  26815. * @param endValue End value of the animation curve
  26816. * @param inTangent Start tangent of the animation curve
  26817. * @param gradient Scalar amount to interpolate
  26818. * @returns Interpolated Vector2 value
  26819. */
  26820. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26821. /**
  26822. * Interpolates a size linearly
  26823. * @param startValue Start value of the animation curve
  26824. * @param endValue End value of the animation curve
  26825. * @param gradient Scalar amount to interpolate
  26826. * @returns Interpolated Size value
  26827. */
  26828. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26829. /**
  26830. * Interpolates a Color3 linearly
  26831. * @param startValue Start value of the animation curve
  26832. * @param endValue End value of the animation curve
  26833. * @param gradient Scalar amount to interpolate
  26834. * @returns Interpolated Color3 value
  26835. */
  26836. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26837. /**
  26838. * @hidden Internal use only
  26839. */
  26840. _getKeyValue(value: any): any;
  26841. /**
  26842. * @hidden Internal use only
  26843. */
  26844. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26845. /**
  26846. * Defines the function to use to interpolate matrices
  26847. * @param startValue defines the start matrix
  26848. * @param endValue defines the end matrix
  26849. * @param gradient defines the gradient between both matrices
  26850. * @param result defines an optional target matrix where to store the interpolation
  26851. * @returns the interpolated matrix
  26852. */
  26853. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26854. /**
  26855. * Makes a copy of the animation
  26856. * @returns Cloned animation
  26857. */
  26858. clone(): Animation;
  26859. /**
  26860. * Sets the key frames of the animation
  26861. * @param values The animation key frames to set
  26862. */
  26863. setKeys(values: Array<IAnimationKey>): void;
  26864. /**
  26865. * Serializes the animation to an object
  26866. * @returns Serialized object
  26867. */
  26868. serialize(): any;
  26869. /**
  26870. * Float animation type
  26871. */
  26872. private static _ANIMATIONTYPE_FLOAT;
  26873. /**
  26874. * Vector3 animation type
  26875. */
  26876. private static _ANIMATIONTYPE_VECTOR3;
  26877. /**
  26878. * Quaternion animation type
  26879. */
  26880. private static _ANIMATIONTYPE_QUATERNION;
  26881. /**
  26882. * Matrix animation type
  26883. */
  26884. private static _ANIMATIONTYPE_MATRIX;
  26885. /**
  26886. * Color3 animation type
  26887. */
  26888. private static _ANIMATIONTYPE_COLOR3;
  26889. /**
  26890. * Vector2 animation type
  26891. */
  26892. private static _ANIMATIONTYPE_VECTOR2;
  26893. /**
  26894. * Size animation type
  26895. */
  26896. private static _ANIMATIONTYPE_SIZE;
  26897. /**
  26898. * Relative Loop Mode
  26899. */
  26900. private static _ANIMATIONLOOPMODE_RELATIVE;
  26901. /**
  26902. * Cycle Loop Mode
  26903. */
  26904. private static _ANIMATIONLOOPMODE_CYCLE;
  26905. /**
  26906. * Constant Loop Mode
  26907. */
  26908. private static _ANIMATIONLOOPMODE_CONSTANT;
  26909. /**
  26910. * Get the float animation type
  26911. */
  26912. static readonly ANIMATIONTYPE_FLOAT: number;
  26913. /**
  26914. * Get the Vector3 animation type
  26915. */
  26916. static readonly ANIMATIONTYPE_VECTOR3: number;
  26917. /**
  26918. * Get the Vector2 animation type
  26919. */
  26920. static readonly ANIMATIONTYPE_VECTOR2: number;
  26921. /**
  26922. * Get the Size animation type
  26923. */
  26924. static readonly ANIMATIONTYPE_SIZE: number;
  26925. /**
  26926. * Get the Quaternion animation type
  26927. */
  26928. static readonly ANIMATIONTYPE_QUATERNION: number;
  26929. /**
  26930. * Get the Matrix animation type
  26931. */
  26932. static readonly ANIMATIONTYPE_MATRIX: number;
  26933. /**
  26934. * Get the Color3 animation type
  26935. */
  26936. static readonly ANIMATIONTYPE_COLOR3: number;
  26937. /**
  26938. * Get the Relative Loop Mode
  26939. */
  26940. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26941. /**
  26942. * Get the Cycle Loop Mode
  26943. */
  26944. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26945. /**
  26946. * Get the Constant Loop Mode
  26947. */
  26948. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26949. /** @hidden */
  26950. static _UniversalLerp(left: any, right: any, amount: number): any;
  26951. /**
  26952. * Parses an animation object and creates an animation
  26953. * @param parsedAnimation Parsed animation object
  26954. * @returns Animation object
  26955. */
  26956. static Parse(parsedAnimation: any): Animation;
  26957. /**
  26958. * Appends the serialized animations from the source animations
  26959. * @param source Source containing the animations
  26960. * @param destination Target to store the animations
  26961. */
  26962. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26963. }
  26964. }
  26965. declare module "babylonjs/Materials/Textures/baseTexture" {
  26966. import { Observable } from "babylonjs/Misc/observable";
  26967. import { IAnimatable } from "babylonjs/Misc/tools";
  26968. import { Nullable } from "babylonjs/types";
  26969. import { Scene } from "babylonjs/scene";
  26970. import { Matrix, ISize } from "babylonjs/Maths/math";
  26971. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26972. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26973. /**
  26974. * Base class of all the textures in babylon.
  26975. * It groups all the common properties the materials, post process, lights... might need
  26976. * in order to make a correct use of the texture.
  26977. */
  26978. export class BaseTexture implements IAnimatable {
  26979. /**
  26980. * Default anisotropic filtering level for the application.
  26981. * It is set to 4 as a good tradeoff between perf and quality.
  26982. */
  26983. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26984. /**
  26985. * Gets or sets the unique id of the texture
  26986. */
  26987. uniqueId: number;
  26988. /**
  26989. * Define the name of the texture.
  26990. */
  26991. name: string;
  26992. /**
  26993. * Gets or sets an object used to store user defined information.
  26994. */
  26995. metadata: any;
  26996. /**
  26997. * For internal use only. Please do not use.
  26998. */
  26999. reservedDataStore: any;
  27000. private _hasAlpha;
  27001. /**
  27002. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27003. */
  27004. hasAlpha: boolean;
  27005. /**
  27006. * Defines if the alpha value should be determined via the rgb values.
  27007. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27008. */
  27009. getAlphaFromRGB: boolean;
  27010. /**
  27011. * Intensity or strength of the texture.
  27012. * It is commonly used by materials to fine tune the intensity of the texture
  27013. */
  27014. level: number;
  27015. /**
  27016. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27017. * This is part of the texture as textures usually maps to one uv set.
  27018. */
  27019. coordinatesIndex: number;
  27020. private _coordinatesMode;
  27021. /**
  27022. * How a texture is mapped.
  27023. *
  27024. * | Value | Type | Description |
  27025. * | ----- | ----------------------------------- | ----------- |
  27026. * | 0 | EXPLICIT_MODE | |
  27027. * | 1 | SPHERICAL_MODE | |
  27028. * | 2 | PLANAR_MODE | |
  27029. * | 3 | CUBIC_MODE | |
  27030. * | 4 | PROJECTION_MODE | |
  27031. * | 5 | SKYBOX_MODE | |
  27032. * | 6 | INVCUBIC_MODE | |
  27033. * | 7 | EQUIRECTANGULAR_MODE | |
  27034. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27035. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27036. */
  27037. coordinatesMode: number;
  27038. /**
  27039. * | Value | Type | Description |
  27040. * | ----- | ------------------ | ----------- |
  27041. * | 0 | CLAMP_ADDRESSMODE | |
  27042. * | 1 | WRAP_ADDRESSMODE | |
  27043. * | 2 | MIRROR_ADDRESSMODE | |
  27044. */
  27045. wrapU: number;
  27046. /**
  27047. * | Value | Type | Description |
  27048. * | ----- | ------------------ | ----------- |
  27049. * | 0 | CLAMP_ADDRESSMODE | |
  27050. * | 1 | WRAP_ADDRESSMODE | |
  27051. * | 2 | MIRROR_ADDRESSMODE | |
  27052. */
  27053. wrapV: number;
  27054. /**
  27055. * | Value | Type | Description |
  27056. * | ----- | ------------------ | ----------- |
  27057. * | 0 | CLAMP_ADDRESSMODE | |
  27058. * | 1 | WRAP_ADDRESSMODE | |
  27059. * | 2 | MIRROR_ADDRESSMODE | |
  27060. */
  27061. wrapR: number;
  27062. /**
  27063. * With compliant hardware and browser (supporting anisotropic filtering)
  27064. * this defines the level of anisotropic filtering in the texture.
  27065. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27066. */
  27067. anisotropicFilteringLevel: number;
  27068. /**
  27069. * Define if the texture is a cube texture or if false a 2d texture.
  27070. */
  27071. isCube: boolean;
  27072. /**
  27073. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27074. */
  27075. is3D: boolean;
  27076. /**
  27077. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27078. * HDR texture are usually stored in linear space.
  27079. * This only impacts the PBR and Background materials
  27080. */
  27081. gammaSpace: boolean;
  27082. /**
  27083. * Gets whether or not the texture contains RGBD data.
  27084. */
  27085. readonly isRGBD: boolean;
  27086. /**
  27087. * Is Z inverted in the texture (useful in a cube texture).
  27088. */
  27089. invertZ: boolean;
  27090. /**
  27091. * Are mip maps generated for this texture or not.
  27092. */
  27093. readonly noMipmap: boolean;
  27094. /**
  27095. * @hidden
  27096. */
  27097. lodLevelInAlpha: boolean;
  27098. /**
  27099. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27100. */
  27101. lodGenerationOffset: number;
  27102. /**
  27103. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27104. */
  27105. lodGenerationScale: number;
  27106. /**
  27107. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27108. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27109. * average roughness values.
  27110. */
  27111. linearSpecularLOD: boolean;
  27112. /**
  27113. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27114. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27115. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27116. */
  27117. irradianceTexture: Nullable<BaseTexture>;
  27118. /**
  27119. * Define if the texture is a render target.
  27120. */
  27121. isRenderTarget: boolean;
  27122. /**
  27123. * Define the unique id of the texture in the scene.
  27124. */
  27125. readonly uid: string;
  27126. /**
  27127. * Return a string representation of the texture.
  27128. * @returns the texture as a string
  27129. */
  27130. toString(): string;
  27131. /**
  27132. * Get the class name of the texture.
  27133. * @returns "BaseTexture"
  27134. */
  27135. getClassName(): string;
  27136. /**
  27137. * Define the list of animation attached to the texture.
  27138. */
  27139. animations: import("babylonjs/Animations/animation").Animation[];
  27140. /**
  27141. * An event triggered when the texture is disposed.
  27142. */
  27143. onDisposeObservable: Observable<BaseTexture>;
  27144. private _onDisposeObserver;
  27145. /**
  27146. * Callback triggered when the texture has been disposed.
  27147. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27148. */
  27149. onDispose: () => void;
  27150. /**
  27151. * Define the current state of the loading sequence when in delayed load mode.
  27152. */
  27153. delayLoadState: number;
  27154. private _scene;
  27155. /** @hidden */
  27156. _texture: Nullable<InternalTexture>;
  27157. private _uid;
  27158. /**
  27159. * Define if the texture is preventinga material to render or not.
  27160. * If not and the texture is not ready, the engine will use a default black texture instead.
  27161. */
  27162. readonly isBlocking: boolean;
  27163. /**
  27164. * Instantiates a new BaseTexture.
  27165. * Base class of all the textures in babylon.
  27166. * It groups all the common properties the materials, post process, lights... might need
  27167. * in order to make a correct use of the texture.
  27168. * @param scene Define the scene the texture blongs to
  27169. */
  27170. constructor(scene: Nullable<Scene>);
  27171. /**
  27172. * Get the scene the texture belongs to.
  27173. * @returns the scene or null if undefined
  27174. */
  27175. getScene(): Nullable<Scene>;
  27176. /**
  27177. * Get the texture transform matrix used to offset tile the texture for istance.
  27178. * @returns the transformation matrix
  27179. */
  27180. getTextureMatrix(): Matrix;
  27181. /**
  27182. * Get the texture reflection matrix used to rotate/transform the reflection.
  27183. * @returns the reflection matrix
  27184. */
  27185. getReflectionTextureMatrix(): Matrix;
  27186. /**
  27187. * Get the underlying lower level texture from Babylon.
  27188. * @returns the insternal texture
  27189. */
  27190. getInternalTexture(): Nullable<InternalTexture>;
  27191. /**
  27192. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27193. * @returns true if ready or not blocking
  27194. */
  27195. isReadyOrNotBlocking(): boolean;
  27196. /**
  27197. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27198. * @returns true if fully ready
  27199. */
  27200. isReady(): boolean;
  27201. private _cachedSize;
  27202. /**
  27203. * Get the size of the texture.
  27204. * @returns the texture size.
  27205. */
  27206. getSize(): ISize;
  27207. /**
  27208. * Get the base size of the texture.
  27209. * It can be different from the size if the texture has been resized for POT for instance
  27210. * @returns the base size
  27211. */
  27212. getBaseSize(): ISize;
  27213. /**
  27214. * Update the sampling mode of the texture.
  27215. * Default is Trilinear mode.
  27216. *
  27217. * | Value | Type | Description |
  27218. * | ----- | ------------------ | ----------- |
  27219. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27220. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27221. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27222. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27223. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27224. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27225. * | 7 | NEAREST_LINEAR | |
  27226. * | 8 | NEAREST_NEAREST | |
  27227. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27228. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27229. * | 11 | LINEAR_LINEAR | |
  27230. * | 12 | LINEAR_NEAREST | |
  27231. *
  27232. * > _mag_: magnification filter (close to the viewer)
  27233. * > _min_: minification filter (far from the viewer)
  27234. * > _mip_: filter used between mip map levels
  27235. *@param samplingMode Define the new sampling mode of the texture
  27236. */
  27237. updateSamplingMode(samplingMode: number): void;
  27238. /**
  27239. * Scales the texture if is `canRescale()`
  27240. * @param ratio the resize factor we want to use to rescale
  27241. */
  27242. scale(ratio: number): void;
  27243. /**
  27244. * Get if the texture can rescale.
  27245. */
  27246. readonly canRescale: boolean;
  27247. /** @hidden */
  27248. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27249. /** @hidden */
  27250. _rebuild(): void;
  27251. /**
  27252. * Triggers the load sequence in delayed load mode.
  27253. */
  27254. delayLoad(): void;
  27255. /**
  27256. * Clones the texture.
  27257. * @returns the cloned texture
  27258. */
  27259. clone(): Nullable<BaseTexture>;
  27260. /**
  27261. * Get the texture underlying type (INT, FLOAT...)
  27262. */
  27263. readonly textureType: number;
  27264. /**
  27265. * Get the texture underlying format (RGB, RGBA...)
  27266. */
  27267. readonly textureFormat: number;
  27268. /**
  27269. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27270. * This will returns an RGBA array buffer containing either in values (0-255) or
  27271. * float values (0-1) depending of the underlying buffer type.
  27272. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27273. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27274. * @param buffer defines a user defined buffer to fill with data (can be null)
  27275. * @returns The Array buffer containing the pixels data.
  27276. */
  27277. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27278. /**
  27279. * Release and destroy the underlying lower level texture aka internalTexture.
  27280. */
  27281. releaseInternalTexture(): void;
  27282. /**
  27283. * Get the polynomial representation of the texture data.
  27284. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27285. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27286. */
  27287. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27288. /** @hidden */
  27289. readonly _lodTextureHigh: Nullable<BaseTexture>;
  27290. /** @hidden */
  27291. readonly _lodTextureMid: Nullable<BaseTexture>;
  27292. /** @hidden */
  27293. readonly _lodTextureLow: Nullable<BaseTexture>;
  27294. /**
  27295. * Dispose the texture and release its associated resources.
  27296. */
  27297. dispose(): void;
  27298. /**
  27299. * Serialize the texture into a JSON representation that can be parsed later on.
  27300. * @returns the JSON representation of the texture
  27301. */
  27302. serialize(): any;
  27303. /**
  27304. * Helper function to be called back once a list of texture contains only ready textures.
  27305. * @param textures Define the list of textures to wait for
  27306. * @param callback Define the callback triggered once the entire list will be ready
  27307. */
  27308. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27309. }
  27310. }
  27311. declare module "babylonjs/Materials/uniformBuffer" {
  27312. import { Nullable, FloatArray } from "babylonjs/types";
  27313. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  27314. import { Engine } from "babylonjs/Engines/engine";
  27315. import { Effect } from "babylonjs/Materials/effect";
  27316. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27317. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27318. /**
  27319. * Uniform buffer objects.
  27320. *
  27321. * Handles blocks of uniform on the GPU.
  27322. *
  27323. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27324. *
  27325. * For more information, please refer to :
  27326. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27327. */
  27328. export class UniformBuffer {
  27329. private _engine;
  27330. private _buffer;
  27331. private _data;
  27332. private _bufferData;
  27333. private _dynamic?;
  27334. private _uniformLocations;
  27335. private _uniformSizes;
  27336. private _uniformLocationPointer;
  27337. private _needSync;
  27338. private _noUBO;
  27339. private _currentEffect;
  27340. private static _MAX_UNIFORM_SIZE;
  27341. private static _tempBuffer;
  27342. /**
  27343. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  27344. * This is dynamic to allow compat with webgl 1 and 2.
  27345. * You will need to pass the name of the uniform as well as the value.
  27346. */
  27347. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  27348. /**
  27349. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  27350. * This is dynamic to allow compat with webgl 1 and 2.
  27351. * You will need to pass the name of the uniform as well as the value.
  27352. */
  27353. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  27354. /**
  27355. * Lambda to Update a single float in a uniform buffer.
  27356. * This is dynamic to allow compat with webgl 1 and 2.
  27357. * You will need to pass the name of the uniform as well as the value.
  27358. */
  27359. updateFloat: (name: string, x: number) => void;
  27360. /**
  27361. * Lambda to Update a vec2 of float in a uniform buffer.
  27362. * This is dynamic to allow compat with webgl 1 and 2.
  27363. * You will need to pass the name of the uniform as well as the value.
  27364. */
  27365. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  27366. /**
  27367. * Lambda to Update a vec3 of float in a uniform buffer.
  27368. * This is dynamic to allow compat with webgl 1 and 2.
  27369. * You will need to pass the name of the uniform as well as the value.
  27370. */
  27371. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  27372. /**
  27373. * Lambda to Update a vec4 of float in a uniform buffer.
  27374. * This is dynamic to allow compat with webgl 1 and 2.
  27375. * You will need to pass the name of the uniform as well as the value.
  27376. */
  27377. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  27378. /**
  27379. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  27380. * This is dynamic to allow compat with webgl 1 and 2.
  27381. * You will need to pass the name of the uniform as well as the value.
  27382. */
  27383. updateMatrix: (name: string, mat: Matrix) => void;
  27384. /**
  27385. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  27386. * This is dynamic to allow compat with webgl 1 and 2.
  27387. * You will need to pass the name of the uniform as well as the value.
  27388. */
  27389. updateVector3: (name: string, vector: Vector3) => void;
  27390. /**
  27391. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  27392. * This is dynamic to allow compat with webgl 1 and 2.
  27393. * You will need to pass the name of the uniform as well as the value.
  27394. */
  27395. updateVector4: (name: string, vector: Vector4) => void;
  27396. /**
  27397. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  27398. * This is dynamic to allow compat with webgl 1 and 2.
  27399. * You will need to pass the name of the uniform as well as the value.
  27400. */
  27401. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  27402. /**
  27403. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  27404. * This is dynamic to allow compat with webgl 1 and 2.
  27405. * You will need to pass the name of the uniform as well as the value.
  27406. */
  27407. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  27408. /**
  27409. * Instantiates a new Uniform buffer objects.
  27410. *
  27411. * Handles blocks of uniform on the GPU.
  27412. *
  27413. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27414. *
  27415. * For more information, please refer to :
  27416. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27417. * @param engine Define the engine the buffer is associated with
  27418. * @param data Define the data contained in the buffer
  27419. * @param dynamic Define if the buffer is updatable
  27420. */
  27421. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  27422. /**
  27423. * Indicates if the buffer is using the WebGL2 UBO implementation,
  27424. * or just falling back on setUniformXXX calls.
  27425. */
  27426. readonly useUbo: boolean;
  27427. /**
  27428. * Indicates if the WebGL underlying uniform buffer is in sync
  27429. * with the javascript cache data.
  27430. */
  27431. readonly isSync: boolean;
  27432. /**
  27433. * Indicates if the WebGL underlying uniform buffer is dynamic.
  27434. * Also, a dynamic UniformBuffer will disable cache verification and always
  27435. * update the underlying WebGL uniform buffer to the GPU.
  27436. * @returns if Dynamic, otherwise false
  27437. */
  27438. isDynamic(): boolean;
  27439. /**
  27440. * The data cache on JS side.
  27441. * @returns the underlying data as a float array
  27442. */
  27443. getData(): Float32Array;
  27444. /**
  27445. * The underlying WebGL Uniform buffer.
  27446. * @returns the webgl buffer
  27447. */
  27448. getBuffer(): Nullable<DataBuffer>;
  27449. /**
  27450. * std140 layout specifies how to align data within an UBO structure.
  27451. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  27452. * for specs.
  27453. */
  27454. private _fillAlignment;
  27455. /**
  27456. * Adds an uniform in the buffer.
  27457. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  27458. * for the layout to be correct !
  27459. * @param name Name of the uniform, as used in the uniform block in the shader.
  27460. * @param size Data size, or data directly.
  27461. */
  27462. addUniform(name: string, size: number | number[]): void;
  27463. /**
  27464. * Adds a Matrix 4x4 to the uniform buffer.
  27465. * @param name Name of the uniform, as used in the uniform block in the shader.
  27466. * @param mat A 4x4 matrix.
  27467. */
  27468. addMatrix(name: string, mat: Matrix): void;
  27469. /**
  27470. * Adds a vec2 to the uniform buffer.
  27471. * @param name Name of the uniform, as used in the uniform block in the shader.
  27472. * @param x Define the x component value of the vec2
  27473. * @param y Define the y component value of the vec2
  27474. */
  27475. addFloat2(name: string, x: number, y: number): void;
  27476. /**
  27477. * Adds a vec3 to the uniform buffer.
  27478. * @param name Name of the uniform, as used in the uniform block in the shader.
  27479. * @param x Define the x component value of the vec3
  27480. * @param y Define the y component value of the vec3
  27481. * @param z Define the z component value of the vec3
  27482. */
  27483. addFloat3(name: string, x: number, y: number, z: number): void;
  27484. /**
  27485. * Adds a vec3 to the uniform buffer.
  27486. * @param name Name of the uniform, as used in the uniform block in the shader.
  27487. * @param color Define the vec3 from a Color
  27488. */
  27489. addColor3(name: string, color: Color3): void;
  27490. /**
  27491. * Adds a vec4 to the uniform buffer.
  27492. * @param name Name of the uniform, as used in the uniform block in the shader.
  27493. * @param color Define the rgb components from a Color
  27494. * @param alpha Define the a component of the vec4
  27495. */
  27496. addColor4(name: string, color: Color3, alpha: number): void;
  27497. /**
  27498. * Adds a vec3 to the uniform buffer.
  27499. * @param name Name of the uniform, as used in the uniform block in the shader.
  27500. * @param vector Define the vec3 components from a Vector
  27501. */
  27502. addVector3(name: string, vector: Vector3): void;
  27503. /**
  27504. * Adds a Matrix 3x3 to the uniform buffer.
  27505. * @param name Name of the uniform, as used in the uniform block in the shader.
  27506. */
  27507. addMatrix3x3(name: string): void;
  27508. /**
  27509. * Adds a Matrix 2x2 to the uniform buffer.
  27510. * @param name Name of the uniform, as used in the uniform block in the shader.
  27511. */
  27512. addMatrix2x2(name: string): void;
  27513. /**
  27514. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  27515. */
  27516. create(): void;
  27517. /** @hidden */
  27518. _rebuild(): void;
  27519. /**
  27520. * Updates the WebGL Uniform Buffer on the GPU.
  27521. * If the `dynamic` flag is set to true, no cache comparison is done.
  27522. * Otherwise, the buffer will be updated only if the cache differs.
  27523. */
  27524. update(): void;
  27525. /**
  27526. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  27527. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27528. * @param data Define the flattened data
  27529. * @param size Define the size of the data.
  27530. */
  27531. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  27532. private _updateMatrix3x3ForUniform;
  27533. private _updateMatrix3x3ForEffect;
  27534. private _updateMatrix2x2ForEffect;
  27535. private _updateMatrix2x2ForUniform;
  27536. private _updateFloatForEffect;
  27537. private _updateFloatForUniform;
  27538. private _updateFloat2ForEffect;
  27539. private _updateFloat2ForUniform;
  27540. private _updateFloat3ForEffect;
  27541. private _updateFloat3ForUniform;
  27542. private _updateFloat4ForEffect;
  27543. private _updateFloat4ForUniform;
  27544. private _updateMatrixForEffect;
  27545. private _updateMatrixForUniform;
  27546. private _updateVector3ForEffect;
  27547. private _updateVector3ForUniform;
  27548. private _updateVector4ForEffect;
  27549. private _updateVector4ForUniform;
  27550. private _updateColor3ForEffect;
  27551. private _updateColor3ForUniform;
  27552. private _updateColor4ForEffect;
  27553. private _updateColor4ForUniform;
  27554. /**
  27555. * Sets a sampler uniform on the effect.
  27556. * @param name Define the name of the sampler.
  27557. * @param texture Define the texture to set in the sampler
  27558. */
  27559. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  27560. /**
  27561. * Directly updates the value of the uniform in the cache AND on the GPU.
  27562. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27563. * @param data Define the flattened data
  27564. */
  27565. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  27566. /**
  27567. * Binds this uniform buffer to an effect.
  27568. * @param effect Define the effect to bind the buffer to
  27569. * @param name Name of the uniform block in the shader.
  27570. */
  27571. bindToEffect(effect: Effect, name: string): void;
  27572. /**
  27573. * Disposes the uniform buffer.
  27574. */
  27575. dispose(): void;
  27576. }
  27577. }
  27578. declare module "babylonjs/Audio/analyser" {
  27579. import { Scene } from "babylonjs/scene";
  27580. /**
  27581. * Class used to work with sound analyzer using fast fourier transform (FFT)
  27582. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27583. */
  27584. export class Analyser {
  27585. /**
  27586. * Gets or sets the smoothing
  27587. * @ignorenaming
  27588. */
  27589. SMOOTHING: number;
  27590. /**
  27591. * Gets or sets the FFT table size
  27592. * @ignorenaming
  27593. */
  27594. FFT_SIZE: number;
  27595. /**
  27596. * Gets or sets the bar graph amplitude
  27597. * @ignorenaming
  27598. */
  27599. BARGRAPHAMPLITUDE: number;
  27600. /**
  27601. * Gets or sets the position of the debug canvas
  27602. * @ignorenaming
  27603. */
  27604. DEBUGCANVASPOS: {
  27605. x: number;
  27606. y: number;
  27607. };
  27608. /**
  27609. * Gets or sets the debug canvas size
  27610. * @ignorenaming
  27611. */
  27612. DEBUGCANVASSIZE: {
  27613. width: number;
  27614. height: number;
  27615. };
  27616. private _byteFreqs;
  27617. private _byteTime;
  27618. private _floatFreqs;
  27619. private _webAudioAnalyser;
  27620. private _debugCanvas;
  27621. private _debugCanvasContext;
  27622. private _scene;
  27623. private _registerFunc;
  27624. private _audioEngine;
  27625. /**
  27626. * Creates a new analyser
  27627. * @param scene defines hosting scene
  27628. */
  27629. constructor(scene: Scene);
  27630. /**
  27631. * Get the number of data values you will have to play with for the visualization
  27632. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  27633. * @returns a number
  27634. */
  27635. getFrequencyBinCount(): number;
  27636. /**
  27637. * Gets the current frequency data as a byte array
  27638. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27639. * @returns a Uint8Array
  27640. */
  27641. getByteFrequencyData(): Uint8Array;
  27642. /**
  27643. * Gets the current waveform as a byte array
  27644. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27645. * @returns a Uint8Array
  27646. */
  27647. getByteTimeDomainData(): Uint8Array;
  27648. /**
  27649. * Gets the current frequency data as a float array
  27650. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27651. * @returns a Float32Array
  27652. */
  27653. getFloatFrequencyData(): Float32Array;
  27654. /**
  27655. * Renders the debug canvas
  27656. */
  27657. drawDebugCanvas(): void;
  27658. /**
  27659. * Stops rendering the debug canvas and removes it
  27660. */
  27661. stopDebugCanvas(): void;
  27662. /**
  27663. * Connects two audio nodes
  27664. * @param inputAudioNode defines first node to connect
  27665. * @param outputAudioNode defines second node to connect
  27666. */
  27667. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27668. /**
  27669. * Releases all associated resources
  27670. */
  27671. dispose(): void;
  27672. }
  27673. }
  27674. declare module "babylonjs/Audio/audioEngine" {
  27675. import { IDisposable } from "babylonjs/scene";
  27676. import { Analyser } from "babylonjs/Audio/analyser";
  27677. import { Nullable } from "babylonjs/types";
  27678. import { Observable } from "babylonjs/Misc/observable";
  27679. /**
  27680. * This represents an audio engine and it is responsible
  27681. * to play, synchronize and analyse sounds throughout the application.
  27682. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27683. */
  27684. export interface IAudioEngine extends IDisposable {
  27685. /**
  27686. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27687. */
  27688. readonly canUseWebAudio: boolean;
  27689. /**
  27690. * Gets the current AudioContext if available.
  27691. */
  27692. readonly audioContext: Nullable<AudioContext>;
  27693. /**
  27694. * The master gain node defines the global audio volume of your audio engine.
  27695. */
  27696. readonly masterGain: GainNode;
  27697. /**
  27698. * Gets whether or not mp3 are supported by your browser.
  27699. */
  27700. readonly isMP3supported: boolean;
  27701. /**
  27702. * Gets whether or not ogg are supported by your browser.
  27703. */
  27704. readonly isOGGsupported: boolean;
  27705. /**
  27706. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27707. * @ignoreNaming
  27708. */
  27709. WarnedWebAudioUnsupported: boolean;
  27710. /**
  27711. * Defines if the audio engine relies on a custom unlocked button.
  27712. * In this case, the embedded button will not be displayed.
  27713. */
  27714. useCustomUnlockedButton: boolean;
  27715. /**
  27716. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27717. */
  27718. readonly unlocked: boolean;
  27719. /**
  27720. * Event raised when audio has been unlocked on the browser.
  27721. */
  27722. onAudioUnlockedObservable: Observable<AudioEngine>;
  27723. /**
  27724. * Event raised when audio has been locked on the browser.
  27725. */
  27726. onAudioLockedObservable: Observable<AudioEngine>;
  27727. /**
  27728. * Flags the audio engine in Locked state.
  27729. * This happens due to new browser policies preventing audio to autoplay.
  27730. */
  27731. lock(): void;
  27732. /**
  27733. * Unlocks the audio engine once a user action has been done on the dom.
  27734. * This is helpful to resume play once browser policies have been satisfied.
  27735. */
  27736. unlock(): void;
  27737. }
  27738. /**
  27739. * This represents the default audio engine used in babylon.
  27740. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27741. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27742. */
  27743. export class AudioEngine implements IAudioEngine {
  27744. private _audioContext;
  27745. private _audioContextInitialized;
  27746. private _muteButton;
  27747. private _hostElement;
  27748. /**
  27749. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27750. */
  27751. canUseWebAudio: boolean;
  27752. /**
  27753. * The master gain node defines the global audio volume of your audio engine.
  27754. */
  27755. masterGain: GainNode;
  27756. /**
  27757. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27758. * @ignoreNaming
  27759. */
  27760. WarnedWebAudioUnsupported: boolean;
  27761. /**
  27762. * Gets whether or not mp3 are supported by your browser.
  27763. */
  27764. isMP3supported: boolean;
  27765. /**
  27766. * Gets whether or not ogg are supported by your browser.
  27767. */
  27768. isOGGsupported: boolean;
  27769. /**
  27770. * Gets whether audio has been unlocked on the device.
  27771. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27772. * a user interaction has happened.
  27773. */
  27774. unlocked: boolean;
  27775. /**
  27776. * Defines if the audio engine relies on a custom unlocked button.
  27777. * In this case, the embedded button will not be displayed.
  27778. */
  27779. useCustomUnlockedButton: boolean;
  27780. /**
  27781. * Event raised when audio has been unlocked on the browser.
  27782. */
  27783. onAudioUnlockedObservable: Observable<AudioEngine>;
  27784. /**
  27785. * Event raised when audio has been locked on the browser.
  27786. */
  27787. onAudioLockedObservable: Observable<AudioEngine>;
  27788. /**
  27789. * Gets the current AudioContext if available.
  27790. */
  27791. readonly audioContext: Nullable<AudioContext>;
  27792. private _connectedAnalyser;
  27793. /**
  27794. * Instantiates a new audio engine.
  27795. *
  27796. * There should be only one per page as some browsers restrict the number
  27797. * of audio contexts you can create.
  27798. * @param hostElement defines the host element where to display the mute icon if necessary
  27799. */
  27800. constructor(hostElement?: Nullable<HTMLElement>);
  27801. /**
  27802. * Flags the audio engine in Locked state.
  27803. * This happens due to new browser policies preventing audio to autoplay.
  27804. */
  27805. lock(): void;
  27806. /**
  27807. * Unlocks the audio engine once a user action has been done on the dom.
  27808. * This is helpful to resume play once browser policies have been satisfied.
  27809. */
  27810. unlock(): void;
  27811. private _resumeAudioContext;
  27812. private _initializeAudioContext;
  27813. private _tryToRun;
  27814. private _triggerRunningState;
  27815. private _triggerSuspendedState;
  27816. private _displayMuteButton;
  27817. private _moveButtonToTopLeft;
  27818. private _onResize;
  27819. private _hideMuteButton;
  27820. /**
  27821. * Destroy and release the resources associated with the audio ccontext.
  27822. */
  27823. dispose(): void;
  27824. /**
  27825. * Gets the global volume sets on the master gain.
  27826. * @returns the global volume if set or -1 otherwise
  27827. */
  27828. getGlobalVolume(): number;
  27829. /**
  27830. * Sets the global volume of your experience (sets on the master gain).
  27831. * @param newVolume Defines the new global volume of the application
  27832. */
  27833. setGlobalVolume(newVolume: number): void;
  27834. /**
  27835. * Connect the audio engine to an audio analyser allowing some amazing
  27836. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27837. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27838. * @param analyser The analyser to connect to the engine
  27839. */
  27840. connectToAnalyser(analyser: Analyser): void;
  27841. }
  27842. }
  27843. declare module "babylonjs/Loading/loadingScreen" {
  27844. /**
  27845. * Interface used to present a loading screen while loading a scene
  27846. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27847. */
  27848. export interface ILoadingScreen {
  27849. /**
  27850. * Function called to display the loading screen
  27851. */
  27852. displayLoadingUI: () => void;
  27853. /**
  27854. * Function called to hide the loading screen
  27855. */
  27856. hideLoadingUI: () => void;
  27857. /**
  27858. * Gets or sets the color to use for the background
  27859. */
  27860. loadingUIBackgroundColor: string;
  27861. /**
  27862. * Gets or sets the text to display while loading
  27863. */
  27864. loadingUIText: string;
  27865. }
  27866. /**
  27867. * Class used for the default loading screen
  27868. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27869. */
  27870. export class DefaultLoadingScreen implements ILoadingScreen {
  27871. private _renderingCanvas;
  27872. private _loadingText;
  27873. private _loadingDivBackgroundColor;
  27874. private _loadingDiv;
  27875. private _loadingTextDiv;
  27876. /** Gets or sets the logo url to use for the default loading screen */
  27877. static DefaultLogoUrl: string;
  27878. /** Gets or sets the spinner url to use for the default loading screen */
  27879. static DefaultSpinnerUrl: string;
  27880. /**
  27881. * Creates a new default loading screen
  27882. * @param _renderingCanvas defines the canvas used to render the scene
  27883. * @param _loadingText defines the default text to display
  27884. * @param _loadingDivBackgroundColor defines the default background color
  27885. */
  27886. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27887. /**
  27888. * Function called to display the loading screen
  27889. */
  27890. displayLoadingUI(): void;
  27891. /**
  27892. * Function called to hide the loading screen
  27893. */
  27894. hideLoadingUI(): void;
  27895. /**
  27896. * Gets or sets the text to display while loading
  27897. */
  27898. loadingUIText: string;
  27899. /**
  27900. * Gets or sets the color to use for the background
  27901. */
  27902. loadingUIBackgroundColor: string;
  27903. private _resizeLoadingUI;
  27904. }
  27905. }
  27906. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  27907. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27908. import { Engine } from "babylonjs/Engines/engine";
  27909. import { Nullable } from "babylonjs/types";
  27910. /** @hidden */
  27911. export class WebGLPipelineContext implements IPipelineContext {
  27912. engine: Engine;
  27913. program: Nullable<WebGLProgram>;
  27914. context?: WebGLRenderingContext;
  27915. vertexShader?: WebGLShader;
  27916. fragmentShader?: WebGLShader;
  27917. isParallelCompiled: boolean;
  27918. onCompiled?: () => void;
  27919. transformFeedback?: WebGLTransformFeedback | null;
  27920. readonly isAsync: boolean;
  27921. readonly isReady: boolean;
  27922. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  27923. }
  27924. }
  27925. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  27926. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27927. /** @hidden */
  27928. export class WebGLDataBuffer extends DataBuffer {
  27929. private _buffer;
  27930. constructor(resource: WebGLBuffer);
  27931. readonly underlyingResource: any;
  27932. }
  27933. }
  27934. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  27935. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  27936. /** @hidden */
  27937. export class WebGL2ShaderProcessor implements IShaderProcessor {
  27938. attributeProcessor(attribute: string): string;
  27939. varyingProcessor(varying: string, isFragment: boolean): string;
  27940. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  27941. }
  27942. }
  27943. declare module "babylonjs/Materials/Textures/videoTexture" {
  27944. import { Observable } from "babylonjs/Misc/observable";
  27945. import { Nullable } from "babylonjs/types";
  27946. import { Scene } from "babylonjs/scene";
  27947. import { Texture } from "babylonjs/Materials/Textures/texture";
  27948. /**
  27949. * Settings for finer control over video usage
  27950. */
  27951. export interface VideoTextureSettings {
  27952. /**
  27953. * Applies `autoplay` to video, if specified
  27954. */
  27955. autoPlay?: boolean;
  27956. /**
  27957. * Applies `loop` to video, if specified
  27958. */
  27959. loop?: boolean;
  27960. /**
  27961. * Automatically updates internal texture from video at every frame in the render loop
  27962. */
  27963. autoUpdateTexture: boolean;
  27964. /**
  27965. * Image src displayed during the video loading or until the user interacts with the video.
  27966. */
  27967. poster?: string;
  27968. }
  27969. /**
  27970. * If you want to display a video in your scene, this is the special texture for that.
  27971. * This special texture works similar to other textures, with the exception of a few parameters.
  27972. * @see https://doc.babylonjs.com/how_to/video_texture
  27973. */
  27974. export class VideoTexture extends Texture {
  27975. /**
  27976. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27977. */
  27978. readonly autoUpdateTexture: boolean;
  27979. /**
  27980. * The video instance used by the texture internally
  27981. */
  27982. readonly video: HTMLVideoElement;
  27983. private _onUserActionRequestedObservable;
  27984. /**
  27985. * Event triggerd when a dom action is required by the user to play the video.
  27986. * This happens due to recent changes in browser policies preventing video to auto start.
  27987. */
  27988. readonly onUserActionRequestedObservable: Observable<Texture>;
  27989. private _generateMipMaps;
  27990. private _engine;
  27991. private _stillImageCaptured;
  27992. private _displayingPosterTexture;
  27993. private _settings;
  27994. private _createInternalTextureOnEvent;
  27995. /**
  27996. * Creates a video texture.
  27997. * If you want to display a video in your scene, this is the special texture for that.
  27998. * This special texture works similar to other textures, with the exception of a few parameters.
  27999. * @see https://doc.babylonjs.com/how_to/video_texture
  28000. * @param name optional name, will detect from video source, if not defined
  28001. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  28002. * @param scene is obviously the current scene.
  28003. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  28004. * @param invertY is false by default but can be used to invert video on Y axis
  28005. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  28006. * @param settings allows finer control over video usage
  28007. */
  28008. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  28009. private _getName;
  28010. private _getVideo;
  28011. private _createInternalTexture;
  28012. private reset;
  28013. /**
  28014. * @hidden Internal method to initiate `update`.
  28015. */
  28016. _rebuild(): void;
  28017. /**
  28018. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  28019. */
  28020. update(): void;
  28021. /**
  28022. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  28023. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  28024. */
  28025. updateTexture(isVisible: boolean): void;
  28026. protected _updateInternalTexture: () => void;
  28027. /**
  28028. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  28029. * @param url New url.
  28030. */
  28031. updateURL(url: string): void;
  28032. /**
  28033. * Dispose the texture and release its associated resources.
  28034. */
  28035. dispose(): void;
  28036. /**
  28037. * Creates a video texture straight from a stream.
  28038. * @param scene Define the scene the texture should be created in
  28039. * @param stream Define the stream the texture should be created from
  28040. * @returns The created video texture as a promise
  28041. */
  28042. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  28043. /**
  28044. * Creates a video texture straight from your WebCam video feed.
  28045. * @param scene Define the scene the texture should be created in
  28046. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28047. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28048. * @returns The created video texture as a promise
  28049. */
  28050. static CreateFromWebCamAsync(scene: Scene, constraints: {
  28051. minWidth: number;
  28052. maxWidth: number;
  28053. minHeight: number;
  28054. maxHeight: number;
  28055. deviceId: string;
  28056. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  28057. /**
  28058. * Creates a video texture straight from your WebCam video feed.
  28059. * @param scene Define the scene the texture should be created in
  28060. * @param onReady Define a callback to triggered once the texture will be ready
  28061. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28062. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28063. */
  28064. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  28065. minWidth: number;
  28066. maxWidth: number;
  28067. minHeight: number;
  28068. maxHeight: number;
  28069. deviceId: string;
  28070. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  28071. }
  28072. }
  28073. declare module "babylonjs/Engines/engine" {
  28074. import { Observable } from "babylonjs/Misc/observable";
  28075. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  28076. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  28077. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  28078. import { Camera } from "babylonjs/Cameras/camera";
  28079. import { Scene } from "babylonjs/scene";
  28080. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  28081. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  28082. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  28083. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  28084. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  28085. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28086. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28087. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  28088. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  28089. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  28090. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  28091. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  28092. import { WebRequest } from "babylonjs/Misc/webRequest";
  28093. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  28094. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28095. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28096. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  28097. import { Material } from "babylonjs/Materials/material";
  28098. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28099. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28100. /**
  28101. * Interface for attribute information associated with buffer instanciation
  28102. */
  28103. export class InstancingAttributeInfo {
  28104. /**
  28105. * Index/offset of the attribute in the vertex shader
  28106. */
  28107. index: number;
  28108. /**
  28109. * size of the attribute, 1, 2, 3 or 4
  28110. */
  28111. attributeSize: number;
  28112. /**
  28113. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  28114. * default is FLOAT
  28115. */
  28116. attribyteType: number;
  28117. /**
  28118. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  28119. */
  28120. normalized: boolean;
  28121. /**
  28122. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  28123. */
  28124. offset: number;
  28125. /**
  28126. * Name of the GLSL attribute, for debugging purpose only
  28127. */
  28128. attributeName: string;
  28129. }
  28130. /**
  28131. * Define options used to create a depth texture
  28132. */
  28133. export class DepthTextureCreationOptions {
  28134. /** Specifies whether or not a stencil should be allocated in the texture */
  28135. generateStencil?: boolean;
  28136. /** Specifies whether or not bilinear filtering is enable on the texture */
  28137. bilinearFiltering?: boolean;
  28138. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  28139. comparisonFunction?: number;
  28140. /** Specifies if the created texture is a cube texture */
  28141. isCube?: boolean;
  28142. }
  28143. /**
  28144. * Class used to describe the capabilities of the engine relatively to the current browser
  28145. */
  28146. export class EngineCapabilities {
  28147. /** Maximum textures units per fragment shader */
  28148. maxTexturesImageUnits: number;
  28149. /** Maximum texture units per vertex shader */
  28150. maxVertexTextureImageUnits: number;
  28151. /** Maximum textures units in the entire pipeline */
  28152. maxCombinedTexturesImageUnits: number;
  28153. /** Maximum texture size */
  28154. maxTextureSize: number;
  28155. /** Maximum cube texture size */
  28156. maxCubemapTextureSize: number;
  28157. /** Maximum render texture size */
  28158. maxRenderTextureSize: number;
  28159. /** Maximum number of vertex attributes */
  28160. maxVertexAttribs: number;
  28161. /** Maximum number of varyings */
  28162. maxVaryingVectors: number;
  28163. /** Maximum number of uniforms per vertex shader */
  28164. maxVertexUniformVectors: number;
  28165. /** Maximum number of uniforms per fragment shader */
  28166. maxFragmentUniformVectors: number;
  28167. /** Defines if standard derivates (dx/dy) are supported */
  28168. standardDerivatives: boolean;
  28169. /** Defines if s3tc texture compression is supported */
  28170. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  28171. /** Defines if pvrtc texture compression is supported */
  28172. pvrtc: any;
  28173. /** Defines if etc1 texture compression is supported */
  28174. etc1: any;
  28175. /** Defines if etc2 texture compression is supported */
  28176. etc2: any;
  28177. /** Defines if astc texture compression is supported */
  28178. astc: any;
  28179. /** Defines if float textures are supported */
  28180. textureFloat: boolean;
  28181. /** Defines if vertex array objects are supported */
  28182. vertexArrayObject: boolean;
  28183. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  28184. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  28185. /** Gets the maximum level of anisotropy supported */
  28186. maxAnisotropy: number;
  28187. /** Defines if instancing is supported */
  28188. instancedArrays: boolean;
  28189. /** Defines if 32 bits indices are supported */
  28190. uintIndices: boolean;
  28191. /** Defines if high precision shaders are supported */
  28192. highPrecisionShaderSupported: boolean;
  28193. /** Defines if depth reading in the fragment shader is supported */
  28194. fragmentDepthSupported: boolean;
  28195. /** Defines if float texture linear filtering is supported*/
  28196. textureFloatLinearFiltering: boolean;
  28197. /** Defines if rendering to float textures is supported */
  28198. textureFloatRender: boolean;
  28199. /** Defines if half float textures are supported*/
  28200. textureHalfFloat: boolean;
  28201. /** Defines if half float texture linear filtering is supported*/
  28202. textureHalfFloatLinearFiltering: boolean;
  28203. /** Defines if rendering to half float textures is supported */
  28204. textureHalfFloatRender: boolean;
  28205. /** Defines if textureLOD shader command is supported */
  28206. textureLOD: boolean;
  28207. /** Defines if draw buffers extension is supported */
  28208. drawBuffersExtension: boolean;
  28209. /** Defines if depth textures are supported */
  28210. depthTextureExtension: boolean;
  28211. /** Defines if float color buffer are supported */
  28212. colorBufferFloat: boolean;
  28213. /** Gets disjoint timer query extension (null if not supported) */
  28214. timerQuery: EXT_disjoint_timer_query;
  28215. /** Defines if timestamp can be used with timer query */
  28216. canUseTimestampForTimerQuery: boolean;
  28217. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  28218. multiview: any;
  28219. /** Function used to let the system compiles shaders in background */
  28220. parallelShaderCompile: {
  28221. COMPLETION_STATUS_KHR: number;
  28222. };
  28223. }
  28224. /** Interface defining initialization parameters for Engine class */
  28225. export interface EngineOptions extends WebGLContextAttributes {
  28226. /**
  28227. * Defines if the engine should no exceed a specified device ratio
  28228. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  28229. */
  28230. limitDeviceRatio?: number;
  28231. /**
  28232. * Defines if webvr should be enabled automatically
  28233. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28234. */
  28235. autoEnableWebVR?: boolean;
  28236. /**
  28237. * Defines if webgl2 should be turned off even if supported
  28238. * @see http://doc.babylonjs.com/features/webgl2
  28239. */
  28240. disableWebGL2Support?: boolean;
  28241. /**
  28242. * Defines if webaudio should be initialized as well
  28243. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28244. */
  28245. audioEngine?: boolean;
  28246. /**
  28247. * Defines if animations should run using a deterministic lock step
  28248. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28249. */
  28250. deterministicLockstep?: boolean;
  28251. /** Defines the maximum steps to use with deterministic lock step mode */
  28252. lockstepMaxSteps?: number;
  28253. /**
  28254. * Defines that engine should ignore context lost events
  28255. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  28256. */
  28257. doNotHandleContextLost?: boolean;
  28258. /**
  28259. * Defines that engine should ignore modifying touch action attribute and style
  28260. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  28261. */
  28262. doNotHandleTouchAction?: boolean;
  28263. /**
  28264. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  28265. */
  28266. useHighPrecisionFloats?: boolean;
  28267. }
  28268. /**
  28269. * Defines the interface used by display changed events
  28270. */
  28271. export interface IDisplayChangedEventArgs {
  28272. /** Gets the vrDisplay object (if any) */
  28273. vrDisplay: Nullable<any>;
  28274. /** Gets a boolean indicating if webVR is supported */
  28275. vrSupported: boolean;
  28276. }
  28277. /**
  28278. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  28279. */
  28280. export class Engine {
  28281. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  28282. static ExceptionList: ({
  28283. key: string;
  28284. capture: string;
  28285. captureConstraint: number;
  28286. targets: string[];
  28287. } | {
  28288. key: string;
  28289. capture: null;
  28290. captureConstraint: null;
  28291. targets: string[];
  28292. })[];
  28293. /** Gets the list of created engines */
  28294. static readonly Instances: Engine[];
  28295. /**
  28296. * Gets the latest created engine
  28297. */
  28298. static readonly LastCreatedEngine: Nullable<Engine>;
  28299. /**
  28300. * Gets the latest created scene
  28301. */
  28302. static readonly LastCreatedScene: Nullable<Scene>;
  28303. /**
  28304. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  28305. * @param flag defines which part of the materials must be marked as dirty
  28306. * @param predicate defines a predicate used to filter which materials should be affected
  28307. */
  28308. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  28309. /** @hidden */
  28310. static _TextureLoaders: IInternalTextureLoader[];
  28311. /** Defines that alpha blending is disabled */
  28312. static readonly ALPHA_DISABLE: number;
  28313. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  28314. static readonly ALPHA_ADD: number;
  28315. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  28316. static readonly ALPHA_COMBINE: number;
  28317. /** Defines that alpha blending to DEST - SRC * DEST */
  28318. static readonly ALPHA_SUBTRACT: number;
  28319. /** Defines that alpha blending to SRC * DEST */
  28320. static readonly ALPHA_MULTIPLY: number;
  28321. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  28322. static readonly ALPHA_MAXIMIZED: number;
  28323. /** Defines that alpha blending to SRC + DEST */
  28324. static readonly ALPHA_ONEONE: number;
  28325. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  28326. static readonly ALPHA_PREMULTIPLIED: number;
  28327. /**
  28328. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  28329. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  28330. */
  28331. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  28332. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  28333. static readonly ALPHA_INTERPOLATE: number;
  28334. /**
  28335. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  28336. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  28337. */
  28338. static readonly ALPHA_SCREENMODE: number;
  28339. /** Defines that the ressource is not delayed*/
  28340. static readonly DELAYLOADSTATE_NONE: number;
  28341. /** Defines that the ressource was successfully delay loaded */
  28342. static readonly DELAYLOADSTATE_LOADED: number;
  28343. /** Defines that the ressource is currently delay loading */
  28344. static readonly DELAYLOADSTATE_LOADING: number;
  28345. /** Defines that the ressource is delayed and has not started loading */
  28346. static readonly DELAYLOADSTATE_NOTLOADED: number;
  28347. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  28348. static readonly NEVER: number;
  28349. /** 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 */
  28350. static readonly ALWAYS: number;
  28351. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  28352. static readonly LESS: number;
  28353. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  28354. static readonly EQUAL: number;
  28355. /** 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 */
  28356. static readonly LEQUAL: number;
  28357. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  28358. static readonly GREATER: number;
  28359. /** 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 */
  28360. static readonly GEQUAL: number;
  28361. /** 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 */
  28362. static readonly NOTEQUAL: number;
  28363. /** Passed to stencilOperation to specify that stencil value must be kept */
  28364. static readonly KEEP: number;
  28365. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28366. static readonly REPLACE: number;
  28367. /** Passed to stencilOperation to specify that stencil value must be incremented */
  28368. static readonly INCR: number;
  28369. /** Passed to stencilOperation to specify that stencil value must be decremented */
  28370. static readonly DECR: number;
  28371. /** Passed to stencilOperation to specify that stencil value must be inverted */
  28372. static readonly INVERT: number;
  28373. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  28374. static readonly INCR_WRAP: number;
  28375. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  28376. static readonly DECR_WRAP: number;
  28377. /** Texture is not repeating outside of 0..1 UVs */
  28378. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  28379. /** Texture is repeating outside of 0..1 UVs */
  28380. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  28381. /** Texture is repeating and mirrored */
  28382. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  28383. /** ALPHA */
  28384. static readonly TEXTUREFORMAT_ALPHA: number;
  28385. /** LUMINANCE */
  28386. static readonly TEXTUREFORMAT_LUMINANCE: number;
  28387. /** LUMINANCE_ALPHA */
  28388. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  28389. /** RGB */
  28390. static readonly TEXTUREFORMAT_RGB: number;
  28391. /** RGBA */
  28392. static readonly TEXTUREFORMAT_RGBA: number;
  28393. /** RED */
  28394. static readonly TEXTUREFORMAT_RED: number;
  28395. /** RED (2nd reference) */
  28396. static readonly TEXTUREFORMAT_R: number;
  28397. /** RG */
  28398. static readonly TEXTUREFORMAT_RG: number;
  28399. /** RED_INTEGER */
  28400. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  28401. /** RED_INTEGER (2nd reference) */
  28402. static readonly TEXTUREFORMAT_R_INTEGER: number;
  28403. /** RG_INTEGER */
  28404. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  28405. /** RGB_INTEGER */
  28406. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  28407. /** RGBA_INTEGER */
  28408. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  28409. /** UNSIGNED_BYTE */
  28410. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  28411. /** UNSIGNED_BYTE (2nd reference) */
  28412. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  28413. /** FLOAT */
  28414. static readonly TEXTURETYPE_FLOAT: number;
  28415. /** HALF_FLOAT */
  28416. static readonly TEXTURETYPE_HALF_FLOAT: number;
  28417. /** BYTE */
  28418. static readonly TEXTURETYPE_BYTE: number;
  28419. /** SHORT */
  28420. static readonly TEXTURETYPE_SHORT: number;
  28421. /** UNSIGNED_SHORT */
  28422. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  28423. /** INT */
  28424. static readonly TEXTURETYPE_INT: number;
  28425. /** UNSIGNED_INT */
  28426. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  28427. /** UNSIGNED_SHORT_4_4_4_4 */
  28428. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  28429. /** UNSIGNED_SHORT_5_5_5_1 */
  28430. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  28431. /** UNSIGNED_SHORT_5_6_5 */
  28432. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  28433. /** UNSIGNED_INT_2_10_10_10_REV */
  28434. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  28435. /** UNSIGNED_INT_24_8 */
  28436. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  28437. /** UNSIGNED_INT_10F_11F_11F_REV */
  28438. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  28439. /** UNSIGNED_INT_5_9_9_9_REV */
  28440. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  28441. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  28442. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  28443. /** nearest is mag = nearest and min = nearest and mip = linear */
  28444. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  28445. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28446. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  28447. /** Trilinear is mag = linear and min = linear and mip = linear */
  28448. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  28449. /** nearest is mag = nearest and min = nearest and mip = linear */
  28450. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  28451. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28452. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  28453. /** Trilinear is mag = linear and min = linear and mip = linear */
  28454. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  28455. /** mag = nearest and min = nearest and mip = nearest */
  28456. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  28457. /** mag = nearest and min = linear and mip = nearest */
  28458. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  28459. /** mag = nearest and min = linear and mip = linear */
  28460. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  28461. /** mag = nearest and min = linear and mip = none */
  28462. static readonly TEXTURE_NEAREST_LINEAR: number;
  28463. /** mag = nearest and min = nearest and mip = none */
  28464. static readonly TEXTURE_NEAREST_NEAREST: number;
  28465. /** mag = linear and min = nearest and mip = nearest */
  28466. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  28467. /** mag = linear and min = nearest and mip = linear */
  28468. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  28469. /** mag = linear and min = linear and mip = none */
  28470. static readonly TEXTURE_LINEAR_LINEAR: number;
  28471. /** mag = linear and min = nearest and mip = none */
  28472. static readonly TEXTURE_LINEAR_NEAREST: number;
  28473. /** Explicit coordinates mode */
  28474. static readonly TEXTURE_EXPLICIT_MODE: number;
  28475. /** Spherical coordinates mode */
  28476. static readonly TEXTURE_SPHERICAL_MODE: number;
  28477. /** Planar coordinates mode */
  28478. static readonly TEXTURE_PLANAR_MODE: number;
  28479. /** Cubic coordinates mode */
  28480. static readonly TEXTURE_CUBIC_MODE: number;
  28481. /** Projection coordinates mode */
  28482. static readonly TEXTURE_PROJECTION_MODE: number;
  28483. /** Skybox coordinates mode */
  28484. static readonly TEXTURE_SKYBOX_MODE: number;
  28485. /** Inverse Cubic coordinates mode */
  28486. static readonly TEXTURE_INVCUBIC_MODE: number;
  28487. /** Equirectangular coordinates mode */
  28488. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  28489. /** Equirectangular Fixed coordinates mode */
  28490. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  28491. /** Equirectangular Fixed Mirrored coordinates mode */
  28492. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28493. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  28494. static readonly SCALEMODE_FLOOR: number;
  28495. /** Defines that texture rescaling will look for the nearest power of 2 size */
  28496. static readonly SCALEMODE_NEAREST: number;
  28497. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  28498. static readonly SCALEMODE_CEILING: number;
  28499. /**
  28500. * Returns the current npm package of the sdk
  28501. */
  28502. static readonly NpmPackage: string;
  28503. /**
  28504. * Returns the current version of the framework
  28505. */
  28506. static readonly Version: string;
  28507. /**
  28508. * Returns a string describing the current engine
  28509. */
  28510. readonly description: string;
  28511. /**
  28512. * Gets or sets the epsilon value used by collision engine
  28513. */
  28514. static CollisionsEpsilon: number;
  28515. /**
  28516. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28517. */
  28518. static ShadersRepository: string;
  28519. /**
  28520. * Method called to create the default loading screen.
  28521. * This can be overriden in your own app.
  28522. * @param canvas The rendering canvas element
  28523. * @returns The loading screen
  28524. */
  28525. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  28526. /**
  28527. * Method called to create the default rescale post process on each engine.
  28528. */
  28529. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  28530. /** @hidden */
  28531. _shaderProcessor: IShaderProcessor;
  28532. /**
  28533. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28534. */
  28535. forcePOTTextures: boolean;
  28536. /**
  28537. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28538. */
  28539. isFullscreen: boolean;
  28540. /**
  28541. * Gets a boolean indicating if the pointer is currently locked
  28542. */
  28543. isPointerLock: boolean;
  28544. /**
  28545. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28546. */
  28547. cullBackFaces: boolean;
  28548. /**
  28549. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28550. */
  28551. renderEvenInBackground: boolean;
  28552. /**
  28553. * Gets or sets a boolean indicating that cache can be kept between frames
  28554. */
  28555. preventCacheWipeBetweenFrames: boolean;
  28556. /**
  28557. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28558. **/
  28559. enableOfflineSupport: boolean;
  28560. /**
  28561. * 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)
  28562. **/
  28563. disableManifestCheck: boolean;
  28564. /**
  28565. * Gets the list of created scenes
  28566. */
  28567. scenes: Scene[];
  28568. /**
  28569. * Event raised when a new scene is created
  28570. */
  28571. onNewSceneAddedObservable: Observable<Scene>;
  28572. /**
  28573. * Gets the list of created postprocesses
  28574. */
  28575. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  28576. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28577. validateShaderPrograms: boolean;
  28578. /**
  28579. * Observable event triggered each time the rendering canvas is resized
  28580. */
  28581. onResizeObservable: Observable<Engine>;
  28582. /**
  28583. * Observable event triggered each time the canvas loses focus
  28584. */
  28585. onCanvasBlurObservable: Observable<Engine>;
  28586. /**
  28587. * Observable event triggered each time the canvas gains focus
  28588. */
  28589. onCanvasFocusObservable: Observable<Engine>;
  28590. /**
  28591. * Observable event triggered each time the canvas receives pointerout event
  28592. */
  28593. onCanvasPointerOutObservable: Observable<PointerEvent>;
  28594. /**
  28595. * Observable event triggered before each texture is initialized
  28596. */
  28597. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  28598. /**
  28599. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28600. */
  28601. disableUniformBuffers: boolean;
  28602. /** @hidden */
  28603. _uniformBuffers: UniformBuffer[];
  28604. /**
  28605. * Gets a boolean indicating that the engine supports uniform buffers
  28606. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28607. */
  28608. readonly supportsUniformBuffers: boolean;
  28609. /**
  28610. * Observable raised when the engine begins a new frame
  28611. */
  28612. onBeginFrameObservable: Observable<Engine>;
  28613. /**
  28614. * If set, will be used to request the next animation frame for the render loop
  28615. */
  28616. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  28617. /**
  28618. * Observable raised when the engine ends the current frame
  28619. */
  28620. onEndFrameObservable: Observable<Engine>;
  28621. /**
  28622. * Observable raised when the engine is about to compile a shader
  28623. */
  28624. onBeforeShaderCompilationObservable: Observable<Engine>;
  28625. /**
  28626. * Observable raised when the engine has jsut compiled a shader
  28627. */
  28628. onAfterShaderCompilationObservable: Observable<Engine>;
  28629. /** @hidden */
  28630. _gl: WebGLRenderingContext;
  28631. private _renderingCanvas;
  28632. private _windowIsBackground;
  28633. private _webGLVersion;
  28634. protected _highPrecisionShadersAllowed: boolean;
  28635. /** @hidden */
  28636. readonly _shouldUseHighPrecisionShader: boolean;
  28637. /**
  28638. * Gets a boolean indicating that only power of 2 textures are supported
  28639. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28640. */
  28641. readonly needPOTTextures: boolean;
  28642. /** @hidden */
  28643. _badOS: boolean;
  28644. /** @hidden */
  28645. _badDesktopOS: boolean;
  28646. /**
  28647. * Gets the audio engine
  28648. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28649. * @ignorenaming
  28650. */
  28651. static audioEngine: IAudioEngine;
  28652. /**
  28653. * Default AudioEngine factory responsible of creating the Audio Engine.
  28654. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  28655. */
  28656. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  28657. /**
  28658. * Default offline support factory responsible of creating a tool used to store data locally.
  28659. * By default, this will create a Database object if the workload has been embedded.
  28660. */
  28661. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  28662. private _onFocus;
  28663. private _onBlur;
  28664. private _onCanvasPointerOut;
  28665. private _onCanvasBlur;
  28666. private _onCanvasFocus;
  28667. private _onFullscreenChange;
  28668. private _onPointerLockChange;
  28669. private _hardwareScalingLevel;
  28670. /** @hidden */
  28671. _caps: EngineCapabilities;
  28672. private _pointerLockRequested;
  28673. private _isStencilEnable;
  28674. private _colorWrite;
  28675. private _loadingScreen;
  28676. /** @hidden */
  28677. _drawCalls: PerfCounter;
  28678. private _glVersion;
  28679. private _glRenderer;
  28680. private _glVendor;
  28681. private _videoTextureSupported;
  28682. private _renderingQueueLaunched;
  28683. private _activeRenderLoops;
  28684. private _deterministicLockstep;
  28685. private _lockstepMaxSteps;
  28686. /**
  28687. * Observable signaled when a context lost event is raised
  28688. */
  28689. onContextLostObservable: Observable<Engine>;
  28690. /**
  28691. * Observable signaled when a context restored event is raised
  28692. */
  28693. onContextRestoredObservable: Observable<Engine>;
  28694. private _onContextLost;
  28695. private _onContextRestored;
  28696. private _contextWasLost;
  28697. /** @hidden */
  28698. _doNotHandleContextLost: boolean;
  28699. /**
  28700. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28701. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28702. */
  28703. doNotHandleContextLost: boolean;
  28704. private _performanceMonitor;
  28705. private _fps;
  28706. private _deltaTime;
  28707. /**
  28708. * Turn this value on if you want to pause FPS computation when in background
  28709. */
  28710. disablePerformanceMonitorInBackground: boolean;
  28711. /**
  28712. * Gets the performance monitor attached to this engine
  28713. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28714. */
  28715. readonly performanceMonitor: PerformanceMonitor;
  28716. /**
  28717. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28718. */
  28719. disableVertexArrayObjects: boolean;
  28720. /** @hidden */
  28721. protected _depthCullingState: _DepthCullingState;
  28722. /** @hidden */
  28723. protected _stencilState: _StencilState;
  28724. /** @hidden */
  28725. protected _alphaState: _AlphaState;
  28726. /** @hidden */
  28727. protected _alphaMode: number;
  28728. /** @hidden */
  28729. _internalTexturesCache: InternalTexture[];
  28730. /** @hidden */
  28731. protected _activeChannel: number;
  28732. private _currentTextureChannel;
  28733. /** @hidden */
  28734. protected _boundTexturesCache: {
  28735. [key: string]: Nullable<InternalTexture>;
  28736. };
  28737. /** @hidden */
  28738. protected _currentEffect: Nullable<Effect>;
  28739. /** @hidden */
  28740. protected _currentProgram: Nullable<WebGLProgram>;
  28741. private _compiledEffects;
  28742. private _vertexAttribArraysEnabled;
  28743. /** @hidden */
  28744. protected _cachedViewport: Nullable<Viewport>;
  28745. private _cachedVertexArrayObject;
  28746. /** @hidden */
  28747. protected _cachedVertexBuffers: any;
  28748. /** @hidden */
  28749. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  28750. /** @hidden */
  28751. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28752. /** @hidden */
  28753. _currentRenderTarget: Nullable<InternalTexture>;
  28754. private _uintIndicesCurrentlySet;
  28755. private _currentBoundBuffer;
  28756. /** @hidden */
  28757. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28758. private _currentBufferPointers;
  28759. private _currentInstanceLocations;
  28760. private _currentInstanceBuffers;
  28761. private _textureUnits;
  28762. /** @hidden */
  28763. _workingCanvas: Nullable<HTMLCanvasElement>;
  28764. /** @hidden */
  28765. _workingContext: Nullable<CanvasRenderingContext2D>;
  28766. private _rescalePostProcess;
  28767. private _dummyFramebuffer;
  28768. private _externalData;
  28769. /** @hidden */
  28770. _bindedRenderFunction: any;
  28771. private _vaoRecordInProgress;
  28772. private _mustWipeVertexAttributes;
  28773. private _emptyTexture;
  28774. private _emptyCubeTexture;
  28775. private _emptyTexture3D;
  28776. /** @hidden */
  28777. _frameHandler: number;
  28778. private _nextFreeTextureSlots;
  28779. private _maxSimultaneousTextures;
  28780. private _activeRequests;
  28781. private _texturesSupported;
  28782. /** @hidden */
  28783. _textureFormatInUse: Nullable<string>;
  28784. /**
  28785. * Gets the list of texture formats supported
  28786. */
  28787. readonly texturesSupported: Array<string>;
  28788. /**
  28789. * Gets the list of texture formats in use
  28790. */
  28791. readonly textureFormatInUse: Nullable<string>;
  28792. /**
  28793. * Gets the current viewport
  28794. */
  28795. readonly currentViewport: Nullable<Viewport>;
  28796. /**
  28797. * Gets the default empty texture
  28798. */
  28799. readonly emptyTexture: InternalTexture;
  28800. /**
  28801. * Gets the default empty 3D texture
  28802. */
  28803. readonly emptyTexture3D: InternalTexture;
  28804. /**
  28805. * Gets the default empty cube texture
  28806. */
  28807. readonly emptyCubeTexture: InternalTexture;
  28808. /**
  28809. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28810. */
  28811. readonly premultipliedAlpha: boolean;
  28812. /**
  28813. * Creates a new engine
  28814. * @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
  28815. * @param antialias defines enable antialiasing (default: false)
  28816. * @param options defines further options to be sent to the getContext() function
  28817. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28818. */
  28819. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28820. /**
  28821. * Initializes a webVR display and starts listening to display change events
  28822. * The onVRDisplayChangedObservable will be notified upon these changes
  28823. * @returns The onVRDisplayChangedObservable
  28824. */
  28825. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28826. /** @hidden */
  28827. _prepareVRComponent(): void;
  28828. /** @hidden */
  28829. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  28830. /** @hidden */
  28831. _submitVRFrame(): void;
  28832. /**
  28833. * Call this function to leave webVR mode
  28834. * Will do nothing if webVR is not supported or if there is no webVR device
  28835. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28836. */
  28837. disableVR(): void;
  28838. /**
  28839. * Gets a boolean indicating that the system is in VR mode and is presenting
  28840. * @returns true if VR mode is engaged
  28841. */
  28842. isVRPresenting(): boolean;
  28843. /** @hidden */
  28844. _requestVRFrame(): void;
  28845. private _disableTouchAction;
  28846. private _rebuildInternalTextures;
  28847. private _rebuildEffects;
  28848. /**
  28849. * Gets a boolean indicating if all created effects are ready
  28850. * @returns true if all effects are ready
  28851. */
  28852. areAllEffectsReady(): boolean;
  28853. private _rebuildBuffers;
  28854. private _initGLContext;
  28855. /**
  28856. * Gets version of the current webGL context
  28857. */
  28858. readonly webGLVersion: number;
  28859. /**
  28860. * Gets a string idenfifying the name of the class
  28861. * @returns "Engine" string
  28862. */
  28863. getClassName(): string;
  28864. /**
  28865. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28866. */
  28867. readonly isStencilEnable: boolean;
  28868. /** @hidden */
  28869. _prepareWorkingCanvas(): void;
  28870. /**
  28871. * Reset the texture cache to empty state
  28872. */
  28873. resetTextureCache(): void;
  28874. /**
  28875. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28876. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28877. * @returns true if engine is in deterministic lock step mode
  28878. */
  28879. isDeterministicLockStep(): boolean;
  28880. /**
  28881. * Gets the max steps when engine is running in deterministic lock step
  28882. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28883. * @returns the max steps
  28884. */
  28885. getLockstepMaxSteps(): number;
  28886. /**
  28887. * Gets an object containing information about the current webGL context
  28888. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28889. */
  28890. getGlInfo(): {
  28891. vendor: string;
  28892. renderer: string;
  28893. version: string;
  28894. };
  28895. /**
  28896. * Gets current aspect ratio
  28897. * @param camera defines the camera to use to get the aspect ratio
  28898. * @param useScreen defines if screen size must be used (or the current render target if any)
  28899. * @returns a number defining the aspect ratio
  28900. */
  28901. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28902. /**
  28903. * Gets current screen aspect ratio
  28904. * @returns a number defining the aspect ratio
  28905. */
  28906. getScreenAspectRatio(): number;
  28907. /**
  28908. * Gets the current render width
  28909. * @param useScreen defines if screen size must be used (or the current render target if any)
  28910. * @returns a number defining the current render width
  28911. */
  28912. getRenderWidth(useScreen?: boolean): number;
  28913. /**
  28914. * Gets the current render height
  28915. * @param useScreen defines if screen size must be used (or the current render target if any)
  28916. * @returns a number defining the current render height
  28917. */
  28918. getRenderHeight(useScreen?: boolean): number;
  28919. /**
  28920. * Gets the HTML canvas attached with the current webGL context
  28921. * @returns a HTML canvas
  28922. */
  28923. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28924. /**
  28925. * Gets the client rect of the HTML canvas attached with the current webGL context
  28926. * @returns a client rectanglee
  28927. */
  28928. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28929. /**
  28930. * Defines the hardware scaling level.
  28931. * By default the hardware scaling level is computed from the window device ratio.
  28932. * 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.
  28933. * @param level defines the level to use
  28934. */
  28935. setHardwareScalingLevel(level: number): void;
  28936. /**
  28937. * Gets the current hardware scaling level.
  28938. * By default the hardware scaling level is computed from the window device ratio.
  28939. * 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.
  28940. * @returns a number indicating the current hardware scaling level
  28941. */
  28942. getHardwareScalingLevel(): number;
  28943. /**
  28944. * Gets the list of loaded textures
  28945. * @returns an array containing all loaded textures
  28946. */
  28947. getLoadedTexturesCache(): InternalTexture[];
  28948. /**
  28949. * Gets the object containing all engine capabilities
  28950. * @returns the EngineCapabilities object
  28951. */
  28952. getCaps(): EngineCapabilities;
  28953. /**
  28954. * Gets the current depth function
  28955. * @returns a number defining the depth function
  28956. */
  28957. getDepthFunction(): Nullable<number>;
  28958. /**
  28959. * Sets the current depth function
  28960. * @param depthFunc defines the function to use
  28961. */
  28962. setDepthFunction(depthFunc: number): void;
  28963. /**
  28964. * Sets the current depth function to GREATER
  28965. */
  28966. setDepthFunctionToGreater(): void;
  28967. /**
  28968. * Sets the current depth function to GEQUAL
  28969. */
  28970. setDepthFunctionToGreaterOrEqual(): void;
  28971. /**
  28972. * Sets the current depth function to LESS
  28973. */
  28974. setDepthFunctionToLess(): void;
  28975. private _cachedStencilBuffer;
  28976. private _cachedStencilFunction;
  28977. private _cachedStencilMask;
  28978. private _cachedStencilOperationPass;
  28979. private _cachedStencilOperationFail;
  28980. private _cachedStencilOperationDepthFail;
  28981. private _cachedStencilReference;
  28982. /**
  28983. * Caches the the state of the stencil buffer
  28984. */
  28985. cacheStencilState(): void;
  28986. /**
  28987. * Restores the state of the stencil buffer
  28988. */
  28989. restoreStencilState(): void;
  28990. /**
  28991. * Sets the current depth function to LEQUAL
  28992. */
  28993. setDepthFunctionToLessOrEqual(): void;
  28994. /**
  28995. * Gets a boolean indicating if stencil buffer is enabled
  28996. * @returns the current stencil buffer state
  28997. */
  28998. getStencilBuffer(): boolean;
  28999. /**
  29000. * Enable or disable the stencil buffer
  29001. * @param enable defines if the stencil buffer must be enabled or disabled
  29002. */
  29003. setStencilBuffer(enable: boolean): void;
  29004. /**
  29005. * Gets the current stencil mask
  29006. * @returns a number defining the new stencil mask to use
  29007. */
  29008. getStencilMask(): number;
  29009. /**
  29010. * Sets the current stencil mask
  29011. * @param mask defines the new stencil mask to use
  29012. */
  29013. setStencilMask(mask: number): void;
  29014. /**
  29015. * Gets the current stencil function
  29016. * @returns a number defining the stencil function to use
  29017. */
  29018. getStencilFunction(): number;
  29019. /**
  29020. * Gets the current stencil reference value
  29021. * @returns a number defining the stencil reference value to use
  29022. */
  29023. getStencilFunctionReference(): number;
  29024. /**
  29025. * Gets the current stencil mask
  29026. * @returns a number defining the stencil mask to use
  29027. */
  29028. getStencilFunctionMask(): number;
  29029. /**
  29030. * Sets the current stencil function
  29031. * @param stencilFunc defines the new stencil function to use
  29032. */
  29033. setStencilFunction(stencilFunc: number): void;
  29034. /**
  29035. * Sets the current stencil reference
  29036. * @param reference defines the new stencil reference to use
  29037. */
  29038. setStencilFunctionReference(reference: number): void;
  29039. /**
  29040. * Sets the current stencil mask
  29041. * @param mask defines the new stencil mask to use
  29042. */
  29043. setStencilFunctionMask(mask: number): void;
  29044. /**
  29045. * Gets the current stencil operation when stencil fails
  29046. * @returns a number defining stencil operation to use when stencil fails
  29047. */
  29048. getStencilOperationFail(): number;
  29049. /**
  29050. * Gets the current stencil operation when depth fails
  29051. * @returns a number defining stencil operation to use when depth fails
  29052. */
  29053. getStencilOperationDepthFail(): number;
  29054. /**
  29055. * Gets the current stencil operation when stencil passes
  29056. * @returns a number defining stencil operation to use when stencil passes
  29057. */
  29058. getStencilOperationPass(): number;
  29059. /**
  29060. * Sets the stencil operation to use when stencil fails
  29061. * @param operation defines the stencil operation to use when stencil fails
  29062. */
  29063. setStencilOperationFail(operation: number): void;
  29064. /**
  29065. * Sets the stencil operation to use when depth fails
  29066. * @param operation defines the stencil operation to use when depth fails
  29067. */
  29068. setStencilOperationDepthFail(operation: number): void;
  29069. /**
  29070. * Sets the stencil operation to use when stencil passes
  29071. * @param operation defines the stencil operation to use when stencil passes
  29072. */
  29073. setStencilOperationPass(operation: number): void;
  29074. /**
  29075. * Sets a boolean indicating if the dithering state is enabled or disabled
  29076. * @param value defines the dithering state
  29077. */
  29078. setDitheringState(value: boolean): void;
  29079. /**
  29080. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  29081. * @param value defines the rasterizer state
  29082. */
  29083. setRasterizerState(value: boolean): void;
  29084. /**
  29085. * stop executing a render loop function and remove it from the execution array
  29086. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29087. */
  29088. stopRenderLoop(renderFunction?: () => void): void;
  29089. /** @hidden */
  29090. _renderLoop(): void;
  29091. /**
  29092. * Register and execute a render loop. The engine can have more than one render function
  29093. * @param renderFunction defines the function to continuously execute
  29094. */
  29095. runRenderLoop(renderFunction: () => void): void;
  29096. /**
  29097. * Toggle full screen mode
  29098. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29099. */
  29100. switchFullscreen(requestPointerLock: boolean): void;
  29101. /**
  29102. * Enters full screen mode
  29103. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29104. */
  29105. enterFullscreen(requestPointerLock: boolean): void;
  29106. /**
  29107. * Exits full screen mode
  29108. */
  29109. exitFullscreen(): void;
  29110. /**
  29111. * Enters Pointerlock mode
  29112. */
  29113. enterPointerlock(): void;
  29114. /**
  29115. * Exits Pointerlock mode
  29116. */
  29117. exitPointerlock(): void;
  29118. /**
  29119. * Clear the current render buffer or the current render target (if any is set up)
  29120. * @param color defines the color to use
  29121. * @param backBuffer defines if the back buffer must be cleared
  29122. * @param depth defines if the depth buffer must be cleared
  29123. * @param stencil defines if the stencil buffer must be cleared
  29124. */
  29125. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  29126. /**
  29127. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  29128. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29129. * @param y defines the y-coordinate of the corner of the clear rectangle
  29130. * @param width defines the width of the clear rectangle
  29131. * @param height defines the height of the clear rectangle
  29132. * @param clearColor defines the clear color
  29133. */
  29134. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  29135. /**
  29136. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  29137. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29138. * @param y defines the y-coordinate of the corner of the clear rectangle
  29139. * @param width defines the width of the clear rectangle
  29140. * @param height defines the height of the clear rectangle
  29141. */
  29142. enableScissor(x: number, y: number, width: number, height: number): void;
  29143. /**
  29144. * Disable previously set scissor test rectangle
  29145. */
  29146. disableScissor(): void;
  29147. private _viewportCached;
  29148. /** @hidden */
  29149. _viewport(x: number, y: number, width: number, height: number): void;
  29150. /**
  29151. * Set the WebGL's viewport
  29152. * @param viewport defines the viewport element to be used
  29153. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  29154. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  29155. */
  29156. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  29157. /**
  29158. * Directly set the WebGL Viewport
  29159. * @param x defines the x coordinate of the viewport (in screen space)
  29160. * @param y defines the y coordinate of the viewport (in screen space)
  29161. * @param width defines the width of the viewport (in screen space)
  29162. * @param height defines the height of the viewport (in screen space)
  29163. * @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
  29164. */
  29165. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  29166. /**
  29167. * Begin a new frame
  29168. */
  29169. beginFrame(): void;
  29170. /**
  29171. * Enf the current frame
  29172. */
  29173. endFrame(): void;
  29174. /**
  29175. * Resize the view according to the canvas' size
  29176. */
  29177. resize(): void;
  29178. /**
  29179. * Force a specific size of the canvas
  29180. * @param width defines the new canvas' width
  29181. * @param height defines the new canvas' height
  29182. */
  29183. setSize(width: number, height: number): void;
  29184. /**
  29185. * Binds the frame buffer to the specified texture.
  29186. * @param texture The texture to render to or null for the default canvas
  29187. * @param faceIndex The face of the texture to render to in case of cube texture
  29188. * @param requiredWidth The width of the target to render to
  29189. * @param requiredHeight The height of the target to render to
  29190. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29191. * @param depthStencilTexture The depth stencil texture to use to render
  29192. * @param lodLevel defines le lod level to bind to the frame buffer
  29193. */
  29194. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  29195. /** @hidden */
  29196. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  29197. /**
  29198. * Unbind the current render target texture from the webGL context
  29199. * @param texture defines the render target texture to unbind
  29200. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29201. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29202. */
  29203. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  29204. /**
  29205. * Force the mipmap generation for the given render target texture
  29206. * @param texture defines the render target texture to use
  29207. */
  29208. generateMipMapsForCubemap(texture: InternalTexture): void;
  29209. /**
  29210. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29211. */
  29212. flushFramebuffer(): void;
  29213. /**
  29214. * Unbind the current render target and bind the default framebuffer
  29215. */
  29216. restoreDefaultFramebuffer(): void;
  29217. /**
  29218. * Create an uniform buffer
  29219. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29220. * @param elements defines the content of the uniform buffer
  29221. * @returns the webGL uniform buffer
  29222. */
  29223. createUniformBuffer(elements: FloatArray): DataBuffer;
  29224. /**
  29225. * Create a dynamic uniform buffer
  29226. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29227. * @param elements defines the content of the uniform buffer
  29228. * @returns the webGL uniform buffer
  29229. */
  29230. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  29231. /**
  29232. * Update an existing uniform buffer
  29233. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29234. * @param uniformBuffer defines the target uniform buffer
  29235. * @param elements defines the content to update
  29236. * @param offset defines the offset in the uniform buffer where update should start
  29237. * @param count defines the size of the data to update
  29238. */
  29239. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  29240. private _resetVertexBufferBinding;
  29241. /**
  29242. * Creates a vertex buffer
  29243. * @param data the data for the vertex buffer
  29244. * @returns the new WebGL static buffer
  29245. */
  29246. createVertexBuffer(data: DataArray): DataBuffer;
  29247. /**
  29248. * Creates a dynamic vertex buffer
  29249. * @param data the data for the dynamic vertex buffer
  29250. * @returns the new WebGL dynamic buffer
  29251. */
  29252. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  29253. /**
  29254. * Update a dynamic index buffer
  29255. * @param indexBuffer defines the target index buffer
  29256. * @param indices defines the data to update
  29257. * @param offset defines the offset in the target index buffer where update should start
  29258. */
  29259. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  29260. /**
  29261. * Updates a dynamic vertex buffer.
  29262. * @param vertexBuffer the vertex buffer to update
  29263. * @param data the data used to update the vertex buffer
  29264. * @param byteOffset the byte offset of the data
  29265. * @param byteLength the byte length of the data
  29266. */
  29267. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  29268. private _resetIndexBufferBinding;
  29269. /**
  29270. * Creates a new index buffer
  29271. * @param indices defines the content of the index buffer
  29272. * @param updatable defines if the index buffer must be updatable
  29273. * @returns a new webGL buffer
  29274. */
  29275. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  29276. /**
  29277. * Bind a webGL buffer to the webGL context
  29278. * @param buffer defines the buffer to bind
  29279. */
  29280. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  29281. /**
  29282. * Bind an uniform buffer to the current webGL context
  29283. * @param buffer defines the buffer to bind
  29284. */
  29285. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  29286. /**
  29287. * Bind a buffer to the current webGL context at a given location
  29288. * @param buffer defines the buffer to bind
  29289. * @param location defines the index where to bind the buffer
  29290. */
  29291. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  29292. /**
  29293. * Bind a specific block at a given index in a specific shader program
  29294. * @param pipelineContext defines the pipeline context to use
  29295. * @param blockName defines the block name
  29296. * @param index defines the index where to bind the block
  29297. */
  29298. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  29299. private bindIndexBuffer;
  29300. private bindBuffer;
  29301. /**
  29302. * update the bound buffer with the given data
  29303. * @param data defines the data to update
  29304. */
  29305. updateArrayBuffer(data: Float32Array): void;
  29306. private _vertexAttribPointer;
  29307. private _bindIndexBufferWithCache;
  29308. private _bindVertexBuffersAttributes;
  29309. /**
  29310. * Records a vertex array object
  29311. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29312. * @param vertexBuffers defines the list of vertex buffers to store
  29313. * @param indexBuffer defines the index buffer to store
  29314. * @param effect defines the effect to store
  29315. * @returns the new vertex array object
  29316. */
  29317. recordVertexArrayObject(vertexBuffers: {
  29318. [key: string]: VertexBuffer;
  29319. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29320. /**
  29321. * Bind a specific vertex array object
  29322. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29323. * @param vertexArrayObject defines the vertex array object to bind
  29324. * @param indexBuffer defines the index buffer to bind
  29325. */
  29326. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29327. /**
  29328. * Bind webGl buffers directly to the webGL context
  29329. * @param vertexBuffer defines the vertex buffer to bind
  29330. * @param indexBuffer defines the index buffer to bind
  29331. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29332. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29333. * @param effect defines the effect associated with the vertex buffer
  29334. */
  29335. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29336. private _unbindVertexArrayObject;
  29337. /**
  29338. * Bind a list of vertex buffers to the webGL context
  29339. * @param vertexBuffers defines the list of vertex buffers to bind
  29340. * @param indexBuffer defines the index buffer to bind
  29341. * @param effect defines the effect associated with the vertex buffers
  29342. */
  29343. bindBuffers(vertexBuffers: {
  29344. [key: string]: Nullable<VertexBuffer>;
  29345. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29346. /**
  29347. * Unbind all instance attributes
  29348. */
  29349. unbindInstanceAttributes(): void;
  29350. /**
  29351. * Release and free the memory of a vertex array object
  29352. * @param vao defines the vertex array object to delete
  29353. */
  29354. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29355. /** @hidden */
  29356. _releaseBuffer(buffer: DataBuffer): boolean;
  29357. /**
  29358. * Creates a webGL buffer to use with instanciation
  29359. * @param capacity defines the size of the buffer
  29360. * @returns the webGL buffer
  29361. */
  29362. createInstancesBuffer(capacity: number): DataBuffer;
  29363. /**
  29364. * Delete a webGL buffer used with instanciation
  29365. * @param buffer defines the webGL buffer to delete
  29366. */
  29367. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29368. /**
  29369. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29370. * @param instancesBuffer defines the webGL buffer to update and bind
  29371. * @param data defines the data to store in the buffer
  29372. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29373. */
  29374. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29375. /**
  29376. * Apply all cached states (depth, culling, stencil and alpha)
  29377. */
  29378. applyStates(): void;
  29379. /**
  29380. * Send a draw order
  29381. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29382. * @param indexStart defines the starting index
  29383. * @param indexCount defines the number of index to draw
  29384. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29385. */
  29386. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29387. /**
  29388. * Draw a list of points
  29389. * @param verticesStart defines the index of first vertex to draw
  29390. * @param verticesCount defines the count of vertices to draw
  29391. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29392. */
  29393. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29394. /**
  29395. * Draw a list of unindexed primitives
  29396. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29397. * @param verticesStart defines the index of first vertex to draw
  29398. * @param verticesCount defines the count of vertices to draw
  29399. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29400. */
  29401. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29402. /**
  29403. * Draw a list of indexed primitives
  29404. * @param fillMode defines the primitive to use
  29405. * @param indexStart defines the starting index
  29406. * @param indexCount defines the number of index to draw
  29407. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29408. */
  29409. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29410. /**
  29411. * Draw a list of unindexed primitives
  29412. * @param fillMode defines the primitive to use
  29413. * @param verticesStart defines the index of first vertex to draw
  29414. * @param verticesCount defines the count of vertices to draw
  29415. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29416. */
  29417. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29418. private _drawMode;
  29419. /** @hidden */
  29420. _releaseEffect(effect: Effect): void;
  29421. /** @hidden */
  29422. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29423. /**
  29424. * Create a new effect (used to store vertex/fragment shaders)
  29425. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29426. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29427. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29428. * @param samplers defines an array of string used to represent textures
  29429. * @param defines defines the string containing the defines to use to compile the shaders
  29430. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29431. * @param onCompiled defines a function to call when the effect creation is successful
  29432. * @param onError defines a function to call when the effect creation has failed
  29433. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29434. * @returns the new Effect
  29435. */
  29436. 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;
  29437. private _compileShader;
  29438. private _compileRawShader;
  29439. /**
  29440. * Directly creates a webGL program
  29441. * @param pipelineContext defines the pipeline context to attach to
  29442. * @param vertexCode defines the vertex shader code to use
  29443. * @param fragmentCode defines the fragment shader code to use
  29444. * @param context defines the webGL context to use (if not set, the current one will be used)
  29445. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29446. * @returns the new webGL program
  29447. */
  29448. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29449. /**
  29450. * Creates a webGL program
  29451. * @param pipelineContext defines the pipeline context to attach to
  29452. * @param vertexCode defines the vertex shader code to use
  29453. * @param fragmentCode defines the fragment shader code to use
  29454. * @param defines defines the string containing the defines to use to compile the shaders
  29455. * @param context defines the webGL context to use (if not set, the current one will be used)
  29456. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29457. * @returns the new webGL program
  29458. */
  29459. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29460. /**
  29461. * Creates a new pipeline context
  29462. * @returns the new pipeline
  29463. */
  29464. createPipelineContext(): WebGLPipelineContext;
  29465. private _createShaderProgram;
  29466. private _finalizePipelineContext;
  29467. /** @hidden */
  29468. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29469. /** @hidden */
  29470. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29471. /** @hidden */
  29472. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29473. /**
  29474. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29475. * @param pipelineContext defines the pipeline context to use
  29476. * @param uniformsNames defines the list of uniform names
  29477. * @returns an array of webGL uniform locations
  29478. */
  29479. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29480. /**
  29481. * Gets the lsit of active attributes for a given webGL program
  29482. * @param pipelineContext defines the pipeline context to use
  29483. * @param attributesNames defines the list of attribute names to get
  29484. * @returns an array of indices indicating the offset of each attribute
  29485. */
  29486. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29487. /**
  29488. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29489. * @param effect defines the effect to activate
  29490. */
  29491. enableEffect(effect: Nullable<Effect>): void;
  29492. /**
  29493. * Set the value of an uniform to an array of int32
  29494. * @param uniform defines the webGL uniform location where to store the value
  29495. * @param array defines the array of int32 to store
  29496. */
  29497. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29498. /**
  29499. * Set the value of an uniform to an array of int32 (stored as vec2)
  29500. * @param uniform defines the webGL uniform location where to store the value
  29501. * @param array defines the array of int32 to store
  29502. */
  29503. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29504. /**
  29505. * Set the value of an uniform to an array of int32 (stored as vec3)
  29506. * @param uniform defines the webGL uniform location where to store the value
  29507. * @param array defines the array of int32 to store
  29508. */
  29509. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29510. /**
  29511. * Set the value of an uniform to an array of int32 (stored as vec4)
  29512. * @param uniform defines the webGL uniform location where to store the value
  29513. * @param array defines the array of int32 to store
  29514. */
  29515. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29516. /**
  29517. * Set the value of an uniform to an array of float32
  29518. * @param uniform defines the webGL uniform location where to store the value
  29519. * @param array defines the array of float32 to store
  29520. */
  29521. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29522. /**
  29523. * Set the value of an uniform to an array of float32 (stored as vec2)
  29524. * @param uniform defines the webGL uniform location where to store the value
  29525. * @param array defines the array of float32 to store
  29526. */
  29527. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29528. /**
  29529. * Set the value of an uniform to an array of float32 (stored as vec3)
  29530. * @param uniform defines the webGL uniform location where to store the value
  29531. * @param array defines the array of float32 to store
  29532. */
  29533. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29534. /**
  29535. * Set the value of an uniform to an array of float32 (stored as vec4)
  29536. * @param uniform defines the webGL uniform location where to store the value
  29537. * @param array defines the array of float32 to store
  29538. */
  29539. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29540. /**
  29541. * Set the value of an uniform to an array of number
  29542. * @param uniform defines the webGL uniform location where to store the value
  29543. * @param array defines the array of number to store
  29544. */
  29545. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29546. /**
  29547. * Set the value of an uniform to an array of number (stored as vec2)
  29548. * @param uniform defines the webGL uniform location where to store the value
  29549. * @param array defines the array of number to store
  29550. */
  29551. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29552. /**
  29553. * Set the value of an uniform to an array of number (stored as vec3)
  29554. * @param uniform defines the webGL uniform location where to store the value
  29555. * @param array defines the array of number to store
  29556. */
  29557. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29558. /**
  29559. * Set the value of an uniform to an array of number (stored as vec4)
  29560. * @param uniform defines the webGL uniform location where to store the value
  29561. * @param array defines the array of number to store
  29562. */
  29563. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29564. /**
  29565. * Set the value of an uniform to an array of float32 (stored as matrices)
  29566. * @param uniform defines the webGL uniform location where to store the value
  29567. * @param matrices defines the array of float32 to store
  29568. */
  29569. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29570. /**
  29571. * Set the value of an uniform to a matrix
  29572. * @param uniform defines the webGL uniform location where to store the value
  29573. * @param matrix defines the matrix to store
  29574. */
  29575. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  29576. /**
  29577. * Set the value of an uniform to a matrix (3x3)
  29578. * @param uniform defines the webGL uniform location where to store the value
  29579. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29580. */
  29581. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29582. /**
  29583. * Set the value of an uniform to a matrix (2x2)
  29584. * @param uniform defines the webGL uniform location where to store the value
  29585. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29586. */
  29587. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29588. /**
  29589. * Set the value of an uniform to a number (int)
  29590. * @param uniform defines the webGL uniform location where to store the value
  29591. * @param value defines the int number to store
  29592. */
  29593. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29594. /**
  29595. * Set the value of an uniform to a number (float)
  29596. * @param uniform defines the webGL uniform location where to store the value
  29597. * @param value defines the float number to store
  29598. */
  29599. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29600. /**
  29601. * Set the value of an uniform to a vec2
  29602. * @param uniform defines the webGL uniform location where to store the value
  29603. * @param x defines the 1st component of the value
  29604. * @param y defines the 2nd component of the value
  29605. */
  29606. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29607. /**
  29608. * Set the value of an uniform to a vec3
  29609. * @param uniform defines the webGL uniform location where to store the value
  29610. * @param x defines the 1st component of the value
  29611. * @param y defines the 2nd component of the value
  29612. * @param z defines the 3rd component of the value
  29613. */
  29614. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29615. /**
  29616. * Set the value of an uniform to a boolean
  29617. * @param uniform defines the webGL uniform location where to store the value
  29618. * @param bool defines the boolean to store
  29619. */
  29620. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29621. /**
  29622. * Set the value of an uniform to a vec4
  29623. * @param uniform defines the webGL uniform location where to store the value
  29624. * @param x defines the 1st component of the value
  29625. * @param y defines the 2nd component of the value
  29626. * @param z defines the 3rd component of the value
  29627. * @param w defines the 4th component of the value
  29628. */
  29629. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29630. /**
  29631. * Set the value of an uniform to a Color3
  29632. * @param uniform defines the webGL uniform location where to store the value
  29633. * @param color3 defines the color to store
  29634. */
  29635. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  29636. /**
  29637. * Set the value of an uniform to a Color3 and an alpha value
  29638. * @param uniform defines the webGL uniform location where to store the value
  29639. * @param color3 defines the color to store
  29640. * @param alpha defines the alpha component to store
  29641. */
  29642. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  29643. /**
  29644. * Sets a Color4 on a uniform variable
  29645. * @param uniform defines the uniform location
  29646. * @param color4 defines the value to be set
  29647. */
  29648. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  29649. /**
  29650. * Set various states to the webGL context
  29651. * @param culling defines backface culling state
  29652. * @param zOffset defines the value to apply to zOffset (0 by default)
  29653. * @param force defines if states must be applied even if cache is up to date
  29654. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29655. */
  29656. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  29657. /**
  29658. * Set the z offset to apply to current rendering
  29659. * @param value defines the offset to apply
  29660. */
  29661. setZOffset(value: number): void;
  29662. /**
  29663. * Gets the current value of the zOffset
  29664. * @returns the current zOffset state
  29665. */
  29666. getZOffset(): number;
  29667. /**
  29668. * Enable or disable depth buffering
  29669. * @param enable defines the state to set
  29670. */
  29671. setDepthBuffer(enable: boolean): void;
  29672. /**
  29673. * Gets a boolean indicating if depth writing is enabled
  29674. * @returns the current depth writing state
  29675. */
  29676. getDepthWrite(): boolean;
  29677. /**
  29678. * Enable or disable depth writing
  29679. * @param enable defines the state to set
  29680. */
  29681. setDepthWrite(enable: boolean): void;
  29682. /**
  29683. * Enable or disable color writing
  29684. * @param enable defines the state to set
  29685. */
  29686. setColorWrite(enable: boolean): void;
  29687. /**
  29688. * Gets a boolean indicating if color writing is enabled
  29689. * @returns the current color writing state
  29690. */
  29691. getColorWrite(): boolean;
  29692. /**
  29693. * Sets alpha constants used by some alpha blending modes
  29694. * @param r defines the red component
  29695. * @param g defines the green component
  29696. * @param b defines the blue component
  29697. * @param a defines the alpha component
  29698. */
  29699. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29700. /**
  29701. * Sets the current alpha mode
  29702. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29703. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29704. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29705. */
  29706. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29707. /**
  29708. * Gets the current alpha mode
  29709. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29710. * @returns the current alpha mode
  29711. */
  29712. getAlphaMode(): number;
  29713. /**
  29714. * Clears the list of texture accessible through engine.
  29715. * This can help preventing texture load conflict due to name collision.
  29716. */
  29717. clearInternalTexturesCache(): void;
  29718. /**
  29719. * Force the entire cache to be cleared
  29720. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29721. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29722. */
  29723. wipeCaches(bruteForce?: boolean): void;
  29724. /**
  29725. * Set the compressed texture format to use, based on the formats you have, and the formats
  29726. * supported by the hardware / browser.
  29727. *
  29728. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29729. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29730. * to API arguments needed to compressed textures. This puts the burden on the container
  29731. * generator to house the arcane code for determining these for current & future formats.
  29732. *
  29733. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29734. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29735. *
  29736. * Note: The result of this call is not taken into account when a texture is base64.
  29737. *
  29738. * @param formatsAvailable defines the list of those format families you have created
  29739. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29740. *
  29741. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29742. * @returns The extension selected.
  29743. */
  29744. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29745. /** @hidden */
  29746. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29747. min: number;
  29748. mag: number;
  29749. };
  29750. /** @hidden */
  29751. _createTexture(): WebGLTexture;
  29752. /**
  29753. * Usually called from Texture.ts.
  29754. * Passed information to create a WebGLTexture
  29755. * @param urlArg defines a value which contains one of the following:
  29756. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29757. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29758. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29759. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29760. * @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)
  29761. * @param scene needed for loading to the correct scene
  29762. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29763. * @param onLoad optional callback to be called upon successful completion
  29764. * @param onError optional callback to be called upon failure
  29765. * @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
  29766. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29767. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29768. * @param forcedExtension defines the extension to use to pick the right loader
  29769. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29770. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29771. */
  29772. 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;
  29773. /**
  29774. * @hidden
  29775. * Rescales a texture
  29776. * @param source input texutre
  29777. * @param destination destination texture
  29778. * @param scene scene to use to render the resize
  29779. * @param internalFormat format to use when resizing
  29780. * @param onComplete callback to be called when resize has completed
  29781. */
  29782. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  29783. private _unpackFlipYCached;
  29784. /**
  29785. * In case you are sharing the context with other applications, it might
  29786. * be interested to not cache the unpack flip y state to ensure a consistent
  29787. * value would be set.
  29788. */
  29789. enableUnpackFlipYCached: boolean;
  29790. /** @hidden */
  29791. _unpackFlipY(value: boolean): void;
  29792. /** @hidden */
  29793. _getUnpackAlignement(): number;
  29794. /**
  29795. * Creates a dynamic texture
  29796. * @param width defines the width of the texture
  29797. * @param height defines the height of the texture
  29798. * @param generateMipMaps defines if the engine should generate the mip levels
  29799. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29800. * @returns the dynamic texture inside an InternalTexture
  29801. */
  29802. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29803. /**
  29804. * Update the sampling mode of a given texture
  29805. * @param samplingMode defines the required sampling mode
  29806. * @param texture defines the texture to update
  29807. */
  29808. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29809. /**
  29810. * Update the content of a dynamic texture
  29811. * @param texture defines the texture to update
  29812. * @param canvas defines the canvas containing the source
  29813. * @param invertY defines if data must be stored with Y axis inverted
  29814. * @param premulAlpha defines if alpha is stored as premultiplied
  29815. * @param format defines the format of the data
  29816. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29817. */
  29818. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29819. /**
  29820. * Update a video texture
  29821. * @param texture defines the texture to update
  29822. * @param video defines the video element to use
  29823. * @param invertY defines if data must be stored with Y axis inverted
  29824. */
  29825. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29826. /**
  29827. * Updates a depth texture Comparison Mode and Function.
  29828. * If the comparison Function is equal to 0, the mode will be set to none.
  29829. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29830. * @param texture The texture to set the comparison function for
  29831. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29832. */
  29833. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29834. /** @hidden */
  29835. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29836. width: number;
  29837. height: number;
  29838. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29839. /**
  29840. * Creates a depth stencil texture.
  29841. * This is only available in WebGL 2 or with the depth texture extension available.
  29842. * @param size The size of face edge in the texture.
  29843. * @param options The options defining the texture.
  29844. * @returns The texture
  29845. */
  29846. createDepthStencilTexture(size: number | {
  29847. width: number;
  29848. height: number;
  29849. }, options: DepthTextureCreationOptions): InternalTexture;
  29850. /**
  29851. * Creates a depth stencil texture.
  29852. * This is only available in WebGL 2 or with the depth texture extension available.
  29853. * @param size The size of face edge in the texture.
  29854. * @param options The options defining the texture.
  29855. * @returns The texture
  29856. */
  29857. private _createDepthStencilTexture;
  29858. /**
  29859. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29860. * @param renderTarget The render target to set the frame buffer for
  29861. */
  29862. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29863. /**
  29864. * Creates a new render target texture
  29865. * @param size defines the size of the texture
  29866. * @param options defines the options used to create the texture
  29867. * @returns a new render target texture stored in an InternalTexture
  29868. */
  29869. createRenderTargetTexture(size: number | {
  29870. width: number;
  29871. height: number;
  29872. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29873. /** @hidden */
  29874. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29875. /**
  29876. * Updates the sample count of a render target texture
  29877. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29878. * @param texture defines the texture to update
  29879. * @param samples defines the sample count to set
  29880. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29881. */
  29882. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29883. /** @hidden */
  29884. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29885. /** @hidden */
  29886. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  29887. /** @hidden */
  29888. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29889. /** @hidden */
  29890. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29891. /**
  29892. * @hidden
  29893. */
  29894. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29895. private _prepareWebGLTextureContinuation;
  29896. private _prepareWebGLTexture;
  29897. /** @hidden */
  29898. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29899. /** @hidden */
  29900. _releaseFramebufferObjects(texture: InternalTexture): void;
  29901. /** @hidden */
  29902. _releaseTexture(texture: InternalTexture): void;
  29903. private setProgram;
  29904. private _boundUniforms;
  29905. /**
  29906. * Binds an effect to the webGL context
  29907. * @param effect defines the effect to bind
  29908. */
  29909. bindSamplers(effect: Effect): void;
  29910. private _activateCurrentTexture;
  29911. /** @hidden */
  29912. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29913. /** @hidden */
  29914. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29915. /**
  29916. * Sets a texture to the webGL context from a postprocess
  29917. * @param channel defines the channel to use
  29918. * @param postProcess defines the source postprocess
  29919. */
  29920. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29921. /**
  29922. * Binds the output of the passed in post process to the texture channel specified
  29923. * @param channel The channel the texture should be bound to
  29924. * @param postProcess The post process which's output should be bound
  29925. */
  29926. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29927. /**
  29928. * Unbind all textures from the webGL context
  29929. */
  29930. unbindAllTextures(): void;
  29931. /**
  29932. * Sets a texture to the according uniform.
  29933. * @param channel The texture channel
  29934. * @param uniform The uniform to set
  29935. * @param texture The texture to apply
  29936. */
  29937. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29938. /**
  29939. * Sets a depth stencil texture from a render target to the according uniform.
  29940. * @param channel The texture channel
  29941. * @param uniform The uniform to set
  29942. * @param texture The render target texture containing the depth stencil texture to apply
  29943. */
  29944. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29945. private _bindSamplerUniformToChannel;
  29946. private _getTextureWrapMode;
  29947. private _setTexture;
  29948. /**
  29949. * Sets an array of texture to the webGL context
  29950. * @param channel defines the channel where the texture array must be set
  29951. * @param uniform defines the associated uniform location
  29952. * @param textures defines the array of textures to bind
  29953. */
  29954. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29955. /** @hidden */
  29956. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29957. private _setTextureParameterFloat;
  29958. private _setTextureParameterInteger;
  29959. /**
  29960. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29961. * @param x defines the x coordinate of the rectangle where pixels must be read
  29962. * @param y defines the y coordinate of the rectangle where pixels must be read
  29963. * @param width defines the width of the rectangle where pixels must be read
  29964. * @param height defines the height of the rectangle where pixels must be read
  29965. * @returns a Uint8Array containing RGBA colors
  29966. */
  29967. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29968. /**
  29969. * Add an externaly attached data from its key.
  29970. * This method call will fail and return false, if such key already exists.
  29971. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29972. * @param key the unique key that identifies the data
  29973. * @param data the data object to associate to the key for this Engine instance
  29974. * @return true if no such key were already present and the data was added successfully, false otherwise
  29975. */
  29976. addExternalData<T>(key: string, data: T): boolean;
  29977. /**
  29978. * Get an externaly attached data from its key
  29979. * @param key the unique key that identifies the data
  29980. * @return the associated data, if present (can be null), or undefined if not present
  29981. */
  29982. getExternalData<T>(key: string): T;
  29983. /**
  29984. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29985. * @param key the unique key that identifies the data
  29986. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29987. * @return the associated data, can be null if the factory returned null.
  29988. */
  29989. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29990. /**
  29991. * Remove an externaly attached data from the Engine instance
  29992. * @param key the unique key that identifies the data
  29993. * @return true if the data was successfully removed, false if it doesn't exist
  29994. */
  29995. removeExternalData(key: string): boolean;
  29996. /**
  29997. * Unbind all vertex attributes from the webGL context
  29998. */
  29999. unbindAllAttributes(): void;
  30000. /**
  30001. * 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
  30002. */
  30003. releaseEffects(): void;
  30004. /**
  30005. * Dispose and release all associated resources
  30006. */
  30007. dispose(): void;
  30008. /**
  30009. * Display the loading screen
  30010. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30011. */
  30012. displayLoadingUI(): void;
  30013. /**
  30014. * Hide the loading screen
  30015. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30016. */
  30017. hideLoadingUI(): void;
  30018. /**
  30019. * Gets the current loading screen object
  30020. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30021. */
  30022. /**
  30023. * Sets the current loading screen object
  30024. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30025. */
  30026. loadingScreen: ILoadingScreen;
  30027. /**
  30028. * Sets the current loading screen text
  30029. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30030. */
  30031. loadingUIText: string;
  30032. /**
  30033. * Sets the current loading screen background color
  30034. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30035. */
  30036. loadingUIBackgroundColor: string;
  30037. /**
  30038. * Attach a new callback raised when context lost event is fired
  30039. * @param callback defines the callback to call
  30040. */
  30041. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30042. /**
  30043. * Attach a new callback raised when context restored event is fired
  30044. * @param callback defines the callback to call
  30045. */
  30046. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30047. /**
  30048. * Gets the source code of the vertex shader associated with a specific webGL program
  30049. * @param program defines the program to use
  30050. * @returns a string containing the source code of the vertex shader associated with the program
  30051. */
  30052. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  30053. /**
  30054. * Gets the source code of the fragment shader associated with a specific webGL program
  30055. * @param program defines the program to use
  30056. * @returns a string containing the source code of the fragment shader associated with the program
  30057. */
  30058. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  30059. /**
  30060. * Get the current error code of the webGL context
  30061. * @returns the error code
  30062. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30063. */
  30064. getError(): number;
  30065. /**
  30066. * Gets the current framerate
  30067. * @returns a number representing the framerate
  30068. */
  30069. getFps(): number;
  30070. /**
  30071. * Gets the time spent between current and previous frame
  30072. * @returns a number representing the delta time in ms
  30073. */
  30074. getDeltaTime(): number;
  30075. private _measureFps;
  30076. /** @hidden */
  30077. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  30078. private _canRenderToFloatFramebuffer;
  30079. private _canRenderToHalfFloatFramebuffer;
  30080. private _canRenderToFramebuffer;
  30081. /** @hidden */
  30082. _getWebGLTextureType(type: number): number;
  30083. /** @hidden */
  30084. _getInternalFormat(format: number): number;
  30085. /** @hidden */
  30086. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30087. /** @hidden */
  30088. _getRGBAMultiSampleBufferFormat(type: number): number;
  30089. /** @hidden */
  30090. _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;
  30091. /** @hidden */
  30092. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  30093. /**
  30094. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30095. * @returns true if the engine can be created
  30096. * @ignorenaming
  30097. */
  30098. static isSupported(): boolean;
  30099. }
  30100. }
  30101. declare module "babylonjs/Materials/effect" {
  30102. import { Observable } from "babylonjs/Misc/observable";
  30103. import { Nullable } from "babylonjs/types";
  30104. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  30105. import { IDisposable } from "babylonjs/scene";
  30106. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30107. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30108. import { Engine } from "babylonjs/Engines/engine";
  30109. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30110. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30111. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30112. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30114. /**
  30115. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  30116. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  30117. */
  30118. export class EffectFallbacks {
  30119. private _defines;
  30120. private _currentRank;
  30121. private _maxRank;
  30122. private _mesh;
  30123. /**
  30124. * Removes the fallback from the bound mesh.
  30125. */
  30126. unBindMesh(): void;
  30127. /**
  30128. * Adds a fallback on the specified property.
  30129. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  30130. * @param define The name of the define in the shader
  30131. */
  30132. addFallback(rank: number, define: string): void;
  30133. /**
  30134. * Sets the mesh to use CPU skinning when needing to fallback.
  30135. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  30136. * @param mesh The mesh to use the fallbacks.
  30137. */
  30138. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  30139. /**
  30140. * Checks to see if more fallbacks are still availible.
  30141. */
  30142. readonly isMoreFallbacks: boolean;
  30143. /**
  30144. * Removes the defines that should be removed when falling back.
  30145. * @param currentDefines defines the current define statements for the shader.
  30146. * @param effect defines the current effect we try to compile
  30147. * @returns The resulting defines with defines of the current rank removed.
  30148. */
  30149. reduce(currentDefines: string, effect: Effect): string;
  30150. }
  30151. /**
  30152. * Options to be used when creating an effect.
  30153. */
  30154. export class EffectCreationOptions {
  30155. /**
  30156. * Atrributes that will be used in the shader.
  30157. */
  30158. attributes: string[];
  30159. /**
  30160. * Uniform varible names that will be set in the shader.
  30161. */
  30162. uniformsNames: string[];
  30163. /**
  30164. * Uniform buffer varible names that will be set in the shader.
  30165. */
  30166. uniformBuffersNames: string[];
  30167. /**
  30168. * Sampler texture variable names that will be set in the shader.
  30169. */
  30170. samplers: string[];
  30171. /**
  30172. * Define statements that will be set in the shader.
  30173. */
  30174. defines: any;
  30175. /**
  30176. * Possible fallbacks for this effect to improve performance when needed.
  30177. */
  30178. fallbacks: Nullable<EffectFallbacks>;
  30179. /**
  30180. * Callback that will be called when the shader is compiled.
  30181. */
  30182. onCompiled: Nullable<(effect: Effect) => void>;
  30183. /**
  30184. * Callback that will be called if an error occurs during shader compilation.
  30185. */
  30186. onError: Nullable<(effect: Effect, errors: string) => void>;
  30187. /**
  30188. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30189. */
  30190. indexParameters: any;
  30191. /**
  30192. * Max number of lights that can be used in the shader.
  30193. */
  30194. maxSimultaneousLights: number;
  30195. /**
  30196. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30197. */
  30198. transformFeedbackVaryings: Nullable<string[]>;
  30199. }
  30200. /**
  30201. * Effect containing vertex and fragment shader that can be executed on an object.
  30202. */
  30203. export class Effect implements IDisposable {
  30204. /**
  30205. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30206. */
  30207. static ShadersRepository: string;
  30208. /**
  30209. * Name of the effect.
  30210. */
  30211. name: any;
  30212. /**
  30213. * String container all the define statements that should be set on the shader.
  30214. */
  30215. defines: string;
  30216. /**
  30217. * Callback that will be called when the shader is compiled.
  30218. */
  30219. onCompiled: Nullable<(effect: Effect) => void>;
  30220. /**
  30221. * Callback that will be called if an error occurs during shader compilation.
  30222. */
  30223. onError: Nullable<(effect: Effect, errors: string) => void>;
  30224. /**
  30225. * Callback that will be called when effect is bound.
  30226. */
  30227. onBind: Nullable<(effect: Effect) => void>;
  30228. /**
  30229. * Unique ID of the effect.
  30230. */
  30231. uniqueId: number;
  30232. /**
  30233. * Observable that will be called when the shader is compiled.
  30234. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30235. */
  30236. onCompileObservable: Observable<Effect>;
  30237. /**
  30238. * Observable that will be called if an error occurs during shader compilation.
  30239. */
  30240. onErrorObservable: Observable<Effect>;
  30241. /** @hidden */
  30242. _onBindObservable: Nullable<Observable<Effect>>;
  30243. /**
  30244. * Observable that will be called when effect is bound.
  30245. */
  30246. readonly onBindObservable: Observable<Effect>;
  30247. /** @hidden */
  30248. _bonesComputationForcedToCPU: boolean;
  30249. private static _uniqueIdSeed;
  30250. private _engine;
  30251. private _uniformBuffersNames;
  30252. private _uniformsNames;
  30253. private _samplerList;
  30254. private _samplers;
  30255. private _isReady;
  30256. private _compilationError;
  30257. private _attributesNames;
  30258. private _attributes;
  30259. private _uniforms;
  30260. /**
  30261. * Key for the effect.
  30262. * @hidden
  30263. */
  30264. _key: string;
  30265. private _indexParameters;
  30266. private _fallbacks;
  30267. private _vertexSourceCode;
  30268. private _fragmentSourceCode;
  30269. private _vertexSourceCodeOverride;
  30270. private _fragmentSourceCodeOverride;
  30271. private _transformFeedbackVaryings;
  30272. /**
  30273. * Compiled shader to webGL program.
  30274. * @hidden
  30275. */
  30276. _pipelineContext: Nullable<IPipelineContext>;
  30277. private _valueCache;
  30278. private static _baseCache;
  30279. /**
  30280. * Instantiates an effect.
  30281. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30282. * @param baseName Name of the effect.
  30283. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30284. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30285. * @param samplers List of sampler variables that will be passed to the shader.
  30286. * @param engine Engine to be used to render the effect
  30287. * @param defines Define statements to be added to the shader.
  30288. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30289. * @param onCompiled Callback that will be called when the shader is compiled.
  30290. * @param onError Callback that will be called if an error occurs during shader compilation.
  30291. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30292. */
  30293. 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);
  30294. private _useFinalCode;
  30295. /**
  30296. * Unique key for this effect
  30297. */
  30298. readonly key: string;
  30299. /**
  30300. * If the effect has been compiled and prepared.
  30301. * @returns if the effect is compiled and prepared.
  30302. */
  30303. isReady(): boolean;
  30304. /**
  30305. * The engine the effect was initialized with.
  30306. * @returns the engine.
  30307. */
  30308. getEngine(): Engine;
  30309. /**
  30310. * The pipeline context for this effect
  30311. * @returns the associated pipeline context
  30312. */
  30313. getPipelineContext(): Nullable<IPipelineContext>;
  30314. /**
  30315. * The set of names of attribute variables for the shader.
  30316. * @returns An array of attribute names.
  30317. */
  30318. getAttributesNames(): string[];
  30319. /**
  30320. * Returns the attribute at the given index.
  30321. * @param index The index of the attribute.
  30322. * @returns The location of the attribute.
  30323. */
  30324. getAttributeLocation(index: number): number;
  30325. /**
  30326. * Returns the attribute based on the name of the variable.
  30327. * @param name of the attribute to look up.
  30328. * @returns the attribute location.
  30329. */
  30330. getAttributeLocationByName(name: string): number;
  30331. /**
  30332. * The number of attributes.
  30333. * @returns the numnber of attributes.
  30334. */
  30335. getAttributesCount(): number;
  30336. /**
  30337. * Gets the index of a uniform variable.
  30338. * @param uniformName of the uniform to look up.
  30339. * @returns the index.
  30340. */
  30341. getUniformIndex(uniformName: string): number;
  30342. /**
  30343. * Returns the attribute based on the name of the variable.
  30344. * @param uniformName of the uniform to look up.
  30345. * @returns the location of the uniform.
  30346. */
  30347. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30348. /**
  30349. * Returns an array of sampler variable names
  30350. * @returns The array of sampler variable neames.
  30351. */
  30352. getSamplers(): string[];
  30353. /**
  30354. * The error from the last compilation.
  30355. * @returns the error string.
  30356. */
  30357. getCompilationError(): string;
  30358. /**
  30359. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30360. * @param func The callback to be used.
  30361. */
  30362. executeWhenCompiled(func: (effect: Effect) => void): void;
  30363. private _checkIsReady;
  30364. /** @hidden */
  30365. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  30366. /** @hidden */
  30367. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  30368. /** @hidden */
  30369. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  30370. /**
  30371. * Recompiles the webGL program
  30372. * @param vertexSourceCode The source code for the vertex shader.
  30373. * @param fragmentSourceCode The source code for the fragment shader.
  30374. * @param onCompiled Callback called when completed.
  30375. * @param onError Callback called on error.
  30376. * @hidden
  30377. */
  30378. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30379. /**
  30380. * Prepares the effect
  30381. * @hidden
  30382. */
  30383. _prepareEffect(): void;
  30384. /**
  30385. * Checks if the effect is supported. (Must be called after compilation)
  30386. */
  30387. readonly isSupported: boolean;
  30388. /**
  30389. * Binds a texture to the engine to be used as output of the shader.
  30390. * @param channel Name of the output variable.
  30391. * @param texture Texture to bind.
  30392. * @hidden
  30393. */
  30394. _bindTexture(channel: string, texture: InternalTexture): void;
  30395. /**
  30396. * Sets a texture on the engine to be used in the shader.
  30397. * @param channel Name of the sampler variable.
  30398. * @param texture Texture to set.
  30399. */
  30400. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30401. /**
  30402. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30403. * @param channel Name of the sampler variable.
  30404. * @param texture Texture to set.
  30405. */
  30406. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30407. /**
  30408. * Sets an array of textures on the engine to be used in the shader.
  30409. * @param channel Name of the variable.
  30410. * @param textures Textures to set.
  30411. */
  30412. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30413. /**
  30414. * 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)
  30415. * @param channel Name of the sampler variable.
  30416. * @param postProcess Post process to get the input texture from.
  30417. */
  30418. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30419. /**
  30420. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30421. * 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)
  30422. * @param channel Name of the sampler variable.
  30423. * @param postProcess Post process to get the output texture from.
  30424. */
  30425. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30426. /** @hidden */
  30427. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  30428. /** @hidden */
  30429. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30430. /** @hidden */
  30431. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30432. /** @hidden */
  30433. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30434. /**
  30435. * Binds a buffer to a uniform.
  30436. * @param buffer Buffer to bind.
  30437. * @param name Name of the uniform variable to bind to.
  30438. */
  30439. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30440. /**
  30441. * Binds block to a uniform.
  30442. * @param blockName Name of the block to bind.
  30443. * @param index Index to bind.
  30444. */
  30445. bindUniformBlock(blockName: string, index: number): void;
  30446. /**
  30447. * Sets an interger value on a uniform variable.
  30448. * @param uniformName Name of the variable.
  30449. * @param value Value to be set.
  30450. * @returns this effect.
  30451. */
  30452. setInt(uniformName: string, value: number): Effect;
  30453. /**
  30454. * Sets an int array on a uniform variable.
  30455. * @param uniformName Name of the variable.
  30456. * @param array array to be set.
  30457. * @returns this effect.
  30458. */
  30459. setIntArray(uniformName: string, array: Int32Array): Effect;
  30460. /**
  30461. * 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)
  30462. * @param uniformName Name of the variable.
  30463. * @param array array to be set.
  30464. * @returns this effect.
  30465. */
  30466. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30467. /**
  30468. * 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)
  30469. * @param uniformName Name of the variable.
  30470. * @param array array to be set.
  30471. * @returns this effect.
  30472. */
  30473. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30474. /**
  30475. * 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)
  30476. * @param uniformName Name of the variable.
  30477. * @param array array to be set.
  30478. * @returns this effect.
  30479. */
  30480. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30481. /**
  30482. * Sets an float array on a uniform variable.
  30483. * @param uniformName Name of the variable.
  30484. * @param array array to be set.
  30485. * @returns this effect.
  30486. */
  30487. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30488. /**
  30489. * 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)
  30490. * @param uniformName Name of the variable.
  30491. * @param array array to be set.
  30492. * @returns this effect.
  30493. */
  30494. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30495. /**
  30496. * 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)
  30497. * @param uniformName Name of the variable.
  30498. * @param array array to be set.
  30499. * @returns this effect.
  30500. */
  30501. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30502. /**
  30503. * 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)
  30504. * @param uniformName Name of the variable.
  30505. * @param array array to be set.
  30506. * @returns this effect.
  30507. */
  30508. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30509. /**
  30510. * Sets an array on a uniform variable.
  30511. * @param uniformName Name of the variable.
  30512. * @param array array to be set.
  30513. * @returns this effect.
  30514. */
  30515. setArray(uniformName: string, array: number[]): Effect;
  30516. /**
  30517. * 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)
  30518. * @param uniformName Name of the variable.
  30519. * @param array array to be set.
  30520. * @returns this effect.
  30521. */
  30522. setArray2(uniformName: string, array: number[]): Effect;
  30523. /**
  30524. * 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)
  30525. * @param uniformName Name of the variable.
  30526. * @param array array to be set.
  30527. * @returns this effect.
  30528. */
  30529. setArray3(uniformName: string, array: number[]): Effect;
  30530. /**
  30531. * 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)
  30532. * @param uniformName Name of the variable.
  30533. * @param array array to be set.
  30534. * @returns this effect.
  30535. */
  30536. setArray4(uniformName: string, array: number[]): Effect;
  30537. /**
  30538. * Sets matrices on a uniform variable.
  30539. * @param uniformName Name of the variable.
  30540. * @param matrices matrices to be set.
  30541. * @returns this effect.
  30542. */
  30543. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30544. /**
  30545. * Sets matrix on a uniform variable.
  30546. * @param uniformName Name of the variable.
  30547. * @param matrix matrix to be set.
  30548. * @returns this effect.
  30549. */
  30550. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30551. /**
  30552. * 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)
  30553. * @param uniformName Name of the variable.
  30554. * @param matrix matrix to be set.
  30555. * @returns this effect.
  30556. */
  30557. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30558. /**
  30559. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30560. * @param uniformName Name of the variable.
  30561. * @param matrix matrix to be set.
  30562. * @returns this effect.
  30563. */
  30564. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30565. /**
  30566. * Sets a float on a uniform variable.
  30567. * @param uniformName Name of the variable.
  30568. * @param value value to be set.
  30569. * @returns this effect.
  30570. */
  30571. setFloat(uniformName: string, value: number): Effect;
  30572. /**
  30573. * Sets a boolean on a uniform variable.
  30574. * @param uniformName Name of the variable.
  30575. * @param bool value to be set.
  30576. * @returns this effect.
  30577. */
  30578. setBool(uniformName: string, bool: boolean): Effect;
  30579. /**
  30580. * Sets a Vector2 on a uniform variable.
  30581. * @param uniformName Name of the variable.
  30582. * @param vector2 vector2 to be set.
  30583. * @returns this effect.
  30584. */
  30585. setVector2(uniformName: string, vector2: Vector2): Effect;
  30586. /**
  30587. * Sets a float2 on a uniform variable.
  30588. * @param uniformName Name of the variable.
  30589. * @param x First float in float2.
  30590. * @param y Second float in float2.
  30591. * @returns this effect.
  30592. */
  30593. setFloat2(uniformName: string, x: number, y: number): Effect;
  30594. /**
  30595. * Sets a Vector3 on a uniform variable.
  30596. * @param uniformName Name of the variable.
  30597. * @param vector3 Value to be set.
  30598. * @returns this effect.
  30599. */
  30600. setVector3(uniformName: string, vector3: Vector3): Effect;
  30601. /**
  30602. * Sets a float3 on a uniform variable.
  30603. * @param uniformName Name of the variable.
  30604. * @param x First float in float3.
  30605. * @param y Second float in float3.
  30606. * @param z Third float in float3.
  30607. * @returns this effect.
  30608. */
  30609. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30610. /**
  30611. * Sets a Vector4 on a uniform variable.
  30612. * @param uniformName Name of the variable.
  30613. * @param vector4 Value to be set.
  30614. * @returns this effect.
  30615. */
  30616. setVector4(uniformName: string, vector4: Vector4): Effect;
  30617. /**
  30618. * Sets a float4 on a uniform variable.
  30619. * @param uniformName Name of the variable.
  30620. * @param x First float in float4.
  30621. * @param y Second float in float4.
  30622. * @param z Third float in float4.
  30623. * @param w Fourth float in float4.
  30624. * @returns this effect.
  30625. */
  30626. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30627. /**
  30628. * Sets a Color3 on a uniform variable.
  30629. * @param uniformName Name of the variable.
  30630. * @param color3 Value to be set.
  30631. * @returns this effect.
  30632. */
  30633. setColor3(uniformName: string, color3: Color3): Effect;
  30634. /**
  30635. * Sets a Color4 on a uniform variable.
  30636. * @param uniformName Name of the variable.
  30637. * @param color3 Value to be set.
  30638. * @param alpha Alpha value to be set.
  30639. * @returns this effect.
  30640. */
  30641. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30642. /**
  30643. * Sets a Color4 on a uniform variable
  30644. * @param uniformName defines the name of the variable
  30645. * @param color4 defines the value to be set
  30646. * @returns this effect.
  30647. */
  30648. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30649. /** Release all associated resources */
  30650. dispose(): void;
  30651. /**
  30652. * This function will add a new shader to the shader store
  30653. * @param name the name of the shader
  30654. * @param pixelShader optional pixel shader content
  30655. * @param vertexShader optional vertex shader content
  30656. */
  30657. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30658. /**
  30659. * Store of each shader (The can be looked up using effect.key)
  30660. */
  30661. static ShadersStore: {
  30662. [key: string]: string;
  30663. };
  30664. /**
  30665. * Store of each included file for a shader (The can be looked up using effect.key)
  30666. */
  30667. static IncludesShadersStore: {
  30668. [key: string]: string;
  30669. };
  30670. /**
  30671. * Resets the cache of effects.
  30672. */
  30673. static ResetCache(): void;
  30674. }
  30675. }
  30676. declare module "babylonjs/Materials/colorCurves" {
  30677. import { Effect } from "babylonjs/Materials/effect";
  30678. /**
  30679. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30680. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30681. * 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;
  30682. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30683. */
  30684. export class ColorCurves {
  30685. private _dirty;
  30686. private _tempColor;
  30687. private _globalCurve;
  30688. private _highlightsCurve;
  30689. private _midtonesCurve;
  30690. private _shadowsCurve;
  30691. private _positiveCurve;
  30692. private _negativeCurve;
  30693. private _globalHue;
  30694. private _globalDensity;
  30695. private _globalSaturation;
  30696. private _globalExposure;
  30697. /**
  30698. * Gets the global Hue value.
  30699. * 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).
  30700. */
  30701. /**
  30702. * Sets the global Hue value.
  30703. * 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).
  30704. */
  30705. globalHue: number;
  30706. /**
  30707. * Gets the global Density value.
  30708. * 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.
  30709. * Values less than zero provide a filter of opposite hue.
  30710. */
  30711. /**
  30712. * Sets the global Density value.
  30713. * 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.
  30714. * Values less than zero provide a filter of opposite hue.
  30715. */
  30716. globalDensity: number;
  30717. /**
  30718. * Gets the global Saturation value.
  30719. * 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.
  30720. */
  30721. /**
  30722. * Sets the global Saturation value.
  30723. * 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.
  30724. */
  30725. globalSaturation: number;
  30726. /**
  30727. * Gets the global Exposure value.
  30728. * 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.
  30729. */
  30730. /**
  30731. * Sets the global Exposure value.
  30732. * 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.
  30733. */
  30734. globalExposure: number;
  30735. private _highlightsHue;
  30736. private _highlightsDensity;
  30737. private _highlightsSaturation;
  30738. private _highlightsExposure;
  30739. /**
  30740. * Gets the highlights Hue value.
  30741. * 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).
  30742. */
  30743. /**
  30744. * Sets the highlights Hue value.
  30745. * 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).
  30746. */
  30747. highlightsHue: number;
  30748. /**
  30749. * Gets the highlights Density value.
  30750. * 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.
  30751. * Values less than zero provide a filter of opposite hue.
  30752. */
  30753. /**
  30754. * Sets the highlights Density value.
  30755. * 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.
  30756. * Values less than zero provide a filter of opposite hue.
  30757. */
  30758. highlightsDensity: number;
  30759. /**
  30760. * Gets the highlights Saturation value.
  30761. * 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.
  30762. */
  30763. /**
  30764. * Sets the highlights Saturation value.
  30765. * 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.
  30766. */
  30767. highlightsSaturation: number;
  30768. /**
  30769. * Gets the highlights Exposure value.
  30770. * 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.
  30771. */
  30772. /**
  30773. * Sets the highlights Exposure value.
  30774. * 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.
  30775. */
  30776. highlightsExposure: number;
  30777. private _midtonesHue;
  30778. private _midtonesDensity;
  30779. private _midtonesSaturation;
  30780. private _midtonesExposure;
  30781. /**
  30782. * Gets the midtones Hue value.
  30783. * 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).
  30784. */
  30785. /**
  30786. * Sets the midtones Hue value.
  30787. * 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).
  30788. */
  30789. midtonesHue: number;
  30790. /**
  30791. * Gets the midtones Density value.
  30792. * 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.
  30793. * Values less than zero provide a filter of opposite hue.
  30794. */
  30795. /**
  30796. * Sets the midtones Density value.
  30797. * 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.
  30798. * Values less than zero provide a filter of opposite hue.
  30799. */
  30800. midtonesDensity: number;
  30801. /**
  30802. * Gets the midtones Saturation value.
  30803. * 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.
  30804. */
  30805. /**
  30806. * Sets the midtones Saturation value.
  30807. * 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.
  30808. */
  30809. midtonesSaturation: number;
  30810. /**
  30811. * Gets the midtones Exposure value.
  30812. * 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.
  30813. */
  30814. /**
  30815. * Sets the midtones Exposure value.
  30816. * 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.
  30817. */
  30818. midtonesExposure: number;
  30819. private _shadowsHue;
  30820. private _shadowsDensity;
  30821. private _shadowsSaturation;
  30822. private _shadowsExposure;
  30823. /**
  30824. * Gets the shadows Hue value.
  30825. * 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).
  30826. */
  30827. /**
  30828. * Sets the shadows Hue value.
  30829. * 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).
  30830. */
  30831. shadowsHue: number;
  30832. /**
  30833. * Gets the shadows Density value.
  30834. * 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.
  30835. * Values less than zero provide a filter of opposite hue.
  30836. */
  30837. /**
  30838. * Sets the shadows Density value.
  30839. * 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.
  30840. * Values less than zero provide a filter of opposite hue.
  30841. */
  30842. shadowsDensity: number;
  30843. /**
  30844. * Gets the shadows Saturation value.
  30845. * 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.
  30846. */
  30847. /**
  30848. * Sets the shadows Saturation value.
  30849. * 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.
  30850. */
  30851. shadowsSaturation: number;
  30852. /**
  30853. * Gets the shadows Exposure value.
  30854. * 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.
  30855. */
  30856. /**
  30857. * Sets the shadows Exposure value.
  30858. * 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.
  30859. */
  30860. shadowsExposure: number;
  30861. /**
  30862. * Returns the class name
  30863. * @returns The class name
  30864. */
  30865. getClassName(): string;
  30866. /**
  30867. * Binds the color curves to the shader.
  30868. * @param colorCurves The color curve to bind
  30869. * @param effect The effect to bind to
  30870. * @param positiveUniform The positive uniform shader parameter
  30871. * @param neutralUniform The neutral uniform shader parameter
  30872. * @param negativeUniform The negative uniform shader parameter
  30873. */
  30874. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30875. /**
  30876. * Prepare the list of uniforms associated with the ColorCurves effects.
  30877. * @param uniformsList The list of uniforms used in the effect
  30878. */
  30879. static PrepareUniforms(uniformsList: string[]): void;
  30880. /**
  30881. * Returns color grading data based on a hue, density, saturation and exposure value.
  30882. * @param filterHue The hue of the color filter.
  30883. * @param filterDensity The density of the color filter.
  30884. * @param saturation The saturation.
  30885. * @param exposure The exposure.
  30886. * @param result The result data container.
  30887. */
  30888. private getColorGradingDataToRef;
  30889. /**
  30890. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30891. * @param value The input slider value in range [-100,100].
  30892. * @returns Adjusted value.
  30893. */
  30894. private static applyColorGradingSliderNonlinear;
  30895. /**
  30896. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30897. * @param hue The hue (H) input.
  30898. * @param saturation The saturation (S) input.
  30899. * @param brightness The brightness (B) input.
  30900. * @result An RGBA color represented as Vector4.
  30901. */
  30902. private static fromHSBToRef;
  30903. /**
  30904. * Returns a value clamped between min and max
  30905. * @param value The value to clamp
  30906. * @param min The minimum of value
  30907. * @param max The maximum of value
  30908. * @returns The clamped value.
  30909. */
  30910. private static clamp;
  30911. /**
  30912. * Clones the current color curve instance.
  30913. * @return The cloned curves
  30914. */
  30915. clone(): ColorCurves;
  30916. /**
  30917. * Serializes the current color curve instance to a json representation.
  30918. * @return a JSON representation
  30919. */
  30920. serialize(): any;
  30921. /**
  30922. * Parses the color curve from a json representation.
  30923. * @param source the JSON source to parse
  30924. * @return The parsed curves
  30925. */
  30926. static Parse(source: any): ColorCurves;
  30927. }
  30928. }
  30929. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30930. import { Observable } from "babylonjs/Misc/observable";
  30931. import { Nullable } from "babylonjs/types";
  30932. import { Color4 } from "babylonjs/Maths/math";
  30933. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30934. import { Effect } from "babylonjs/Materials/effect";
  30935. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30936. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30937. /**
  30938. * Interface to follow in your material defines to integrate easily the
  30939. * Image proccessing functions.
  30940. * @hidden
  30941. */
  30942. export interface IImageProcessingConfigurationDefines {
  30943. IMAGEPROCESSING: boolean;
  30944. VIGNETTE: boolean;
  30945. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30946. VIGNETTEBLENDMODEOPAQUE: boolean;
  30947. TONEMAPPING: boolean;
  30948. TONEMAPPING_ACES: boolean;
  30949. CONTRAST: boolean;
  30950. EXPOSURE: boolean;
  30951. COLORCURVES: boolean;
  30952. COLORGRADING: boolean;
  30953. COLORGRADING3D: boolean;
  30954. SAMPLER3DGREENDEPTH: boolean;
  30955. SAMPLER3DBGRMAP: boolean;
  30956. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30957. }
  30958. /**
  30959. * @hidden
  30960. */
  30961. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30962. IMAGEPROCESSING: boolean;
  30963. VIGNETTE: boolean;
  30964. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30965. VIGNETTEBLENDMODEOPAQUE: boolean;
  30966. TONEMAPPING: boolean;
  30967. TONEMAPPING_ACES: boolean;
  30968. CONTRAST: boolean;
  30969. COLORCURVES: boolean;
  30970. COLORGRADING: boolean;
  30971. COLORGRADING3D: boolean;
  30972. SAMPLER3DGREENDEPTH: boolean;
  30973. SAMPLER3DBGRMAP: boolean;
  30974. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30975. EXPOSURE: boolean;
  30976. constructor();
  30977. }
  30978. /**
  30979. * This groups together the common properties used for image processing either in direct forward pass
  30980. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30981. * or not.
  30982. */
  30983. export class ImageProcessingConfiguration {
  30984. /**
  30985. * Default tone mapping applied in BabylonJS.
  30986. */
  30987. static readonly TONEMAPPING_STANDARD: number;
  30988. /**
  30989. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30990. * to other engines rendering to increase portability.
  30991. */
  30992. static readonly TONEMAPPING_ACES: number;
  30993. /**
  30994. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30995. */
  30996. colorCurves: Nullable<ColorCurves>;
  30997. private _colorCurvesEnabled;
  30998. /**
  30999. * Gets wether the color curves effect is enabled.
  31000. */
  31001. /**
  31002. * Sets wether the color curves effect is enabled.
  31003. */
  31004. colorCurvesEnabled: boolean;
  31005. private _colorGradingTexture;
  31006. /**
  31007. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  31008. */
  31009. /**
  31010. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  31011. */
  31012. colorGradingTexture: Nullable<BaseTexture>;
  31013. private _colorGradingEnabled;
  31014. /**
  31015. * Gets wether the color grading effect is enabled.
  31016. */
  31017. /**
  31018. * Sets wether the color grading effect is enabled.
  31019. */
  31020. colorGradingEnabled: boolean;
  31021. private _colorGradingWithGreenDepth;
  31022. /**
  31023. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  31024. */
  31025. /**
  31026. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  31027. */
  31028. colorGradingWithGreenDepth: boolean;
  31029. private _colorGradingBGR;
  31030. /**
  31031. * Gets wether the color grading texture contains BGR values.
  31032. */
  31033. /**
  31034. * Sets wether the color grading texture contains BGR values.
  31035. */
  31036. colorGradingBGR: boolean;
  31037. /** @hidden */
  31038. _exposure: number;
  31039. /**
  31040. * Gets the Exposure used in the effect.
  31041. */
  31042. /**
  31043. * Sets the Exposure used in the effect.
  31044. */
  31045. exposure: number;
  31046. private _toneMappingEnabled;
  31047. /**
  31048. * Gets wether the tone mapping effect is enabled.
  31049. */
  31050. /**
  31051. * Sets wether the tone mapping effect is enabled.
  31052. */
  31053. toneMappingEnabled: boolean;
  31054. private _toneMappingType;
  31055. /**
  31056. * Gets the type of tone mapping effect.
  31057. */
  31058. /**
  31059. * Sets the type of tone mapping effect used in BabylonJS.
  31060. */
  31061. toneMappingType: number;
  31062. protected _contrast: number;
  31063. /**
  31064. * Gets the contrast used in the effect.
  31065. */
  31066. /**
  31067. * Sets the contrast used in the effect.
  31068. */
  31069. contrast: number;
  31070. /**
  31071. * Vignette stretch size.
  31072. */
  31073. vignetteStretch: number;
  31074. /**
  31075. * Vignette centre X Offset.
  31076. */
  31077. vignetteCentreX: number;
  31078. /**
  31079. * Vignette centre Y Offset.
  31080. */
  31081. vignetteCentreY: number;
  31082. /**
  31083. * Vignette weight or intensity of the vignette effect.
  31084. */
  31085. vignetteWeight: number;
  31086. /**
  31087. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  31088. * if vignetteEnabled is set to true.
  31089. */
  31090. vignetteColor: Color4;
  31091. /**
  31092. * Camera field of view used by the Vignette effect.
  31093. */
  31094. vignetteCameraFov: number;
  31095. private _vignetteBlendMode;
  31096. /**
  31097. * Gets the vignette blend mode allowing different kind of effect.
  31098. */
  31099. /**
  31100. * Sets the vignette blend mode allowing different kind of effect.
  31101. */
  31102. vignetteBlendMode: number;
  31103. private _vignetteEnabled;
  31104. /**
  31105. * Gets wether the vignette effect is enabled.
  31106. */
  31107. /**
  31108. * Sets wether the vignette effect is enabled.
  31109. */
  31110. vignetteEnabled: boolean;
  31111. private _applyByPostProcess;
  31112. /**
  31113. * Gets wether the image processing is applied through a post process or not.
  31114. */
  31115. /**
  31116. * Sets wether the image processing is applied through a post process or not.
  31117. */
  31118. applyByPostProcess: boolean;
  31119. private _isEnabled;
  31120. /**
  31121. * Gets wether the image processing is enabled or not.
  31122. */
  31123. /**
  31124. * Sets wether the image processing is enabled or not.
  31125. */
  31126. isEnabled: boolean;
  31127. /**
  31128. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  31129. */
  31130. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  31131. /**
  31132. * Method called each time the image processing information changes requires to recompile the effect.
  31133. */
  31134. protected _updateParameters(): void;
  31135. /**
  31136. * Gets the current class name.
  31137. * @return "ImageProcessingConfiguration"
  31138. */
  31139. getClassName(): string;
  31140. /**
  31141. * Prepare the list of uniforms associated with the Image Processing effects.
  31142. * @param uniforms The list of uniforms used in the effect
  31143. * @param defines the list of defines currently in use
  31144. */
  31145. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  31146. /**
  31147. * Prepare the list of samplers associated with the Image Processing effects.
  31148. * @param samplersList The list of uniforms used in the effect
  31149. * @param defines the list of defines currently in use
  31150. */
  31151. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  31152. /**
  31153. * Prepare the list of defines associated to the shader.
  31154. * @param defines the list of defines to complete
  31155. * @param forPostProcess Define if we are currently in post process mode or not
  31156. */
  31157. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  31158. /**
  31159. * Returns true if all the image processing information are ready.
  31160. * @returns True if ready, otherwise, false
  31161. */
  31162. isReady(): boolean;
  31163. /**
  31164. * Binds the image processing to the shader.
  31165. * @param effect The effect to bind to
  31166. * @param aspectRatio Define the current aspect ratio of the effect
  31167. */
  31168. bind(effect: Effect, aspectRatio?: number): void;
  31169. /**
  31170. * Clones the current image processing instance.
  31171. * @return The cloned image processing
  31172. */
  31173. clone(): ImageProcessingConfiguration;
  31174. /**
  31175. * Serializes the current image processing instance to a json representation.
  31176. * @return a JSON representation
  31177. */
  31178. serialize(): any;
  31179. /**
  31180. * Parses the image processing from a json representation.
  31181. * @param source the JSON source to parse
  31182. * @return The parsed image processing
  31183. */
  31184. static Parse(source: any): ImageProcessingConfiguration;
  31185. private static _VIGNETTEMODE_MULTIPLY;
  31186. private static _VIGNETTEMODE_OPAQUE;
  31187. /**
  31188. * Used to apply the vignette as a mix with the pixel color.
  31189. */
  31190. static readonly VIGNETTEMODE_MULTIPLY: number;
  31191. /**
  31192. * Used to apply the vignette as a replacement of the pixel color.
  31193. */
  31194. static readonly VIGNETTEMODE_OPAQUE: number;
  31195. }
  31196. }
  31197. declare module "babylonjs/Materials/fresnelParameters" {
  31198. import { Color3 } from "babylonjs/Maths/math";
  31199. /**
  31200. * This represents all the required information to add a fresnel effect on a material:
  31201. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31202. */
  31203. export class FresnelParameters {
  31204. private _isEnabled;
  31205. /**
  31206. * Define if the fresnel effect is enable or not.
  31207. */
  31208. isEnabled: boolean;
  31209. /**
  31210. * Define the color used on edges (grazing angle)
  31211. */
  31212. leftColor: Color3;
  31213. /**
  31214. * Define the color used on center
  31215. */
  31216. rightColor: Color3;
  31217. /**
  31218. * Define bias applied to computed fresnel term
  31219. */
  31220. bias: number;
  31221. /**
  31222. * Defined the power exponent applied to fresnel term
  31223. */
  31224. power: number;
  31225. /**
  31226. * Clones the current fresnel and its valuues
  31227. * @returns a clone fresnel configuration
  31228. */
  31229. clone(): FresnelParameters;
  31230. /**
  31231. * Serializes the current fresnel parameters to a JSON representation.
  31232. * @return the JSON serialization
  31233. */
  31234. serialize(): any;
  31235. /**
  31236. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  31237. * @param parsedFresnelParameters Define the JSON representation
  31238. * @returns the parsed parameters
  31239. */
  31240. static Parse(parsedFresnelParameters: any): FresnelParameters;
  31241. }
  31242. }
  31243. declare module "babylonjs/Misc/decorators" {
  31244. import { Nullable } from "babylonjs/types";
  31245. import { Scene } from "babylonjs/scene";
  31246. import { IAnimatable } from "babylonjs/Misc/tools";
  31247. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  31248. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31249. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31250. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31251. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31252. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31253. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31254. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31255. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31256. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31257. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31258. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31259. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31260. /**
  31261. * Decorator used to define property that can be serialized as reference to a camera
  31262. * @param sourceName defines the name of the property to decorate
  31263. */
  31264. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  31265. /**
  31266. * Class used to help serialization objects
  31267. */
  31268. export class SerializationHelper {
  31269. /** @hidden */
  31270. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  31271. /** @hidden */
  31272. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  31273. /** @hidden */
  31274. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  31275. /** @hidden */
  31276. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  31277. /**
  31278. * Appends the serialized animations from the source animations
  31279. * @param source Source containing the animations
  31280. * @param destination Target to store the animations
  31281. */
  31282. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  31283. /**
  31284. * Static function used to serialized a specific entity
  31285. * @param entity defines the entity to serialize
  31286. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  31287. * @returns a JSON compatible object representing the serialization of the entity
  31288. */
  31289. static Serialize<T>(entity: T, serializationObject?: any): any;
  31290. /**
  31291. * Creates a new entity from a serialization data object
  31292. * @param creationFunction defines a function used to instanciated the new entity
  31293. * @param source defines the source serialization data
  31294. * @param scene defines the hosting scene
  31295. * @param rootUrl defines the root url for resources
  31296. * @returns a new entity
  31297. */
  31298. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  31299. /**
  31300. * Clones an object
  31301. * @param creationFunction defines the function used to instanciate the new object
  31302. * @param source defines the source object
  31303. * @returns the cloned object
  31304. */
  31305. static Clone<T>(creationFunction: () => T, source: T): T;
  31306. /**
  31307. * Instanciates a new object based on a source one (some data will be shared between both object)
  31308. * @param creationFunction defines the function used to instanciate the new object
  31309. * @param source defines the source object
  31310. * @returns the new object
  31311. */
  31312. static Instanciate<T>(creationFunction: () => T, source: T): T;
  31313. }
  31314. }
  31315. declare module "babylonjs/Cameras/camera" {
  31316. import { SmartArray } from "babylonjs/Misc/smartArray";
  31317. import { Observable } from "babylonjs/Misc/observable";
  31318. import { Nullable } from "babylonjs/types";
  31319. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  31320. import { Scene } from "babylonjs/scene";
  31321. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  31322. import { Node } from "babylonjs/node";
  31323. import { Mesh } from "babylonjs/Meshes/mesh";
  31324. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31325. import { ICullable } from "babylonjs/Culling/boundingInfo";
  31326. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31327. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31328. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  31329. import { Ray } from "babylonjs/Culling/ray";
  31330. /**
  31331. * This is the base class of all the camera used in the application.
  31332. * @see http://doc.babylonjs.com/features/cameras
  31333. */
  31334. export class Camera extends Node {
  31335. /** @hidden */
  31336. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  31337. /**
  31338. * This is the default projection mode used by the cameras.
  31339. * It helps recreating a feeling of perspective and better appreciate depth.
  31340. * This is the best way to simulate real life cameras.
  31341. */
  31342. static readonly PERSPECTIVE_CAMERA: number;
  31343. /**
  31344. * This helps creating camera with an orthographic mode.
  31345. * 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.
  31346. */
  31347. static readonly ORTHOGRAPHIC_CAMERA: number;
  31348. /**
  31349. * This is the default FOV mode for perspective cameras.
  31350. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  31351. */
  31352. static readonly FOVMODE_VERTICAL_FIXED: number;
  31353. /**
  31354. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  31355. */
  31356. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  31357. /**
  31358. * This specifies ther is no need for a camera rig.
  31359. * Basically only one eye is rendered corresponding to the camera.
  31360. */
  31361. static readonly RIG_MODE_NONE: number;
  31362. /**
  31363. * Simulates a camera Rig with one blue eye and one red eye.
  31364. * This can be use with 3d blue and red glasses.
  31365. */
  31366. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  31367. /**
  31368. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  31369. */
  31370. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  31371. /**
  31372. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  31373. */
  31374. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  31375. /**
  31376. * Defines that both eyes of the camera will be rendered over under each other.
  31377. */
  31378. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  31379. /**
  31380. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  31381. */
  31382. static readonly RIG_MODE_VR: number;
  31383. /**
  31384. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  31385. */
  31386. static readonly RIG_MODE_WEBVR: number;
  31387. /**
  31388. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  31389. */
  31390. static readonly RIG_MODE_CUSTOM: number;
  31391. /**
  31392. * Defines if by default attaching controls should prevent the default javascript event to continue.
  31393. */
  31394. static ForceAttachControlToAlwaysPreventDefault: boolean;
  31395. /**
  31396. * Define the input manager associated with the camera.
  31397. */
  31398. inputs: CameraInputsManager<Camera>;
  31399. /** @hidden */
  31400. _position: Vector3;
  31401. /**
  31402. * Define the current local position of the camera in the scene
  31403. */
  31404. position: Vector3;
  31405. /**
  31406. * The vector the camera should consider as up.
  31407. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  31408. */
  31409. upVector: Vector3;
  31410. /**
  31411. * Define the current limit on the left side for an orthographic camera
  31412. * In scene unit
  31413. */
  31414. orthoLeft: Nullable<number>;
  31415. /**
  31416. * Define the current limit on the right side for an orthographic camera
  31417. * In scene unit
  31418. */
  31419. orthoRight: Nullable<number>;
  31420. /**
  31421. * Define the current limit on the bottom side for an orthographic camera
  31422. * In scene unit
  31423. */
  31424. orthoBottom: Nullable<number>;
  31425. /**
  31426. * Define the current limit on the top side for an orthographic camera
  31427. * In scene unit
  31428. */
  31429. orthoTop: Nullable<number>;
  31430. /**
  31431. * Field Of View is set in Radians. (default is 0.8)
  31432. */
  31433. fov: number;
  31434. /**
  31435. * Define the minimum distance the camera can see from.
  31436. * This is important to note that the depth buffer are not infinite and the closer it starts
  31437. * the more your scene might encounter depth fighting issue.
  31438. */
  31439. minZ: number;
  31440. /**
  31441. * Define the maximum distance the camera can see to.
  31442. * This is important to note that the depth buffer are not infinite and the further it end
  31443. * the more your scene might encounter depth fighting issue.
  31444. */
  31445. maxZ: number;
  31446. /**
  31447. * Define the default inertia of the camera.
  31448. * This helps giving a smooth feeling to the camera movement.
  31449. */
  31450. inertia: number;
  31451. /**
  31452. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  31453. */
  31454. mode: number;
  31455. /**
  31456. * Define wether the camera is intermediate.
  31457. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  31458. */
  31459. isIntermediate: boolean;
  31460. /**
  31461. * Define the viewport of the camera.
  31462. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  31463. */
  31464. viewport: Viewport;
  31465. /**
  31466. * Restricts the camera to viewing objects with the same layerMask.
  31467. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  31468. */
  31469. layerMask: number;
  31470. /**
  31471. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  31472. */
  31473. fovMode: number;
  31474. /**
  31475. * Rig mode of the camera.
  31476. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  31477. * This is normally controlled byt the camera themselves as internal use.
  31478. */
  31479. cameraRigMode: number;
  31480. /**
  31481. * Defines the distance between both "eyes" in case of a RIG
  31482. */
  31483. interaxialDistance: number;
  31484. /**
  31485. * Defines if stereoscopic rendering is done side by side or over under.
  31486. */
  31487. isStereoscopicSideBySide: boolean;
  31488. /**
  31489. * 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
  31490. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  31491. * else in the scene.
  31492. */
  31493. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  31494. /**
  31495. * When set, the camera will render to this render target instead of the default canvas
  31496. */
  31497. outputRenderTarget: Nullable<RenderTargetTexture>;
  31498. /**
  31499. * Observable triggered when the camera view matrix has changed.
  31500. */
  31501. onViewMatrixChangedObservable: Observable<Camera>;
  31502. /**
  31503. * Observable triggered when the camera Projection matrix has changed.
  31504. */
  31505. onProjectionMatrixChangedObservable: Observable<Camera>;
  31506. /**
  31507. * Observable triggered when the inputs have been processed.
  31508. */
  31509. onAfterCheckInputsObservable: Observable<Camera>;
  31510. /**
  31511. * Observable triggered when reset has been called and applied to the camera.
  31512. */
  31513. onRestoreStateObservable: Observable<Camera>;
  31514. /** @hidden */
  31515. _cameraRigParams: any;
  31516. /** @hidden */
  31517. _rigCameras: Camera[];
  31518. /** @hidden */
  31519. _rigPostProcess: Nullable<PostProcess>;
  31520. protected _webvrViewMatrix: Matrix;
  31521. /** @hidden */
  31522. _skipRendering: boolean;
  31523. /** @hidden */
  31524. _projectionMatrix: Matrix;
  31525. /** @hidden */
  31526. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  31527. /** @hidden */
  31528. _activeMeshes: SmartArray<AbstractMesh>;
  31529. protected _globalPosition: Vector3;
  31530. /** @hidden */
  31531. _computedViewMatrix: Matrix;
  31532. private _doNotComputeProjectionMatrix;
  31533. private _transformMatrix;
  31534. private _frustumPlanes;
  31535. private _refreshFrustumPlanes;
  31536. private _storedFov;
  31537. private _stateStored;
  31538. /**
  31539. * Instantiates a new camera object.
  31540. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31541. * @see http://doc.babylonjs.com/features/cameras
  31542. * @param name Defines the name of the camera in the scene
  31543. * @param position Defines the position of the camera
  31544. * @param scene Defines the scene the camera belongs too
  31545. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31546. */
  31547. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31548. /**
  31549. * Store current camera state (fov, position, etc..)
  31550. * @returns the camera
  31551. */
  31552. storeState(): Camera;
  31553. /**
  31554. * Restores the camera state values if it has been stored. You must call storeState() first
  31555. */
  31556. protected _restoreStateValues(): boolean;
  31557. /**
  31558. * Restored camera state. You must call storeState() first.
  31559. * @returns true if restored and false otherwise
  31560. */
  31561. restoreState(): boolean;
  31562. /**
  31563. * Gets the class name of the camera.
  31564. * @returns the class name
  31565. */
  31566. getClassName(): string;
  31567. /** @hidden */
  31568. readonly _isCamera: boolean;
  31569. /**
  31570. * Gets a string representation of the camera useful for debug purpose.
  31571. * @param fullDetails Defines that a more verboe level of logging is required
  31572. * @returns the string representation
  31573. */
  31574. toString(fullDetails?: boolean): string;
  31575. /**
  31576. * Gets the current world space position of the camera.
  31577. */
  31578. readonly globalPosition: Vector3;
  31579. /**
  31580. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31581. * @returns the active meshe list
  31582. */
  31583. getActiveMeshes(): SmartArray<AbstractMesh>;
  31584. /**
  31585. * Check wether a mesh is part of the current active mesh list of the camera
  31586. * @param mesh Defines the mesh to check
  31587. * @returns true if active, false otherwise
  31588. */
  31589. isActiveMesh(mesh: Mesh): boolean;
  31590. /**
  31591. * Is this camera ready to be used/rendered
  31592. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31593. * @return true if the camera is ready
  31594. */
  31595. isReady(completeCheck?: boolean): boolean;
  31596. /** @hidden */
  31597. _initCache(): void;
  31598. /** @hidden */
  31599. _updateCache(ignoreParentClass?: boolean): void;
  31600. /** @hidden */
  31601. _isSynchronized(): boolean;
  31602. /** @hidden */
  31603. _isSynchronizedViewMatrix(): boolean;
  31604. /** @hidden */
  31605. _isSynchronizedProjectionMatrix(): boolean;
  31606. /**
  31607. * Attach the input controls to a specific dom element to get the input from.
  31608. * @param element Defines the element the controls should be listened from
  31609. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31610. */
  31611. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31612. /**
  31613. * Detach the current controls from the specified dom element.
  31614. * @param element Defines the element to stop listening the inputs from
  31615. */
  31616. detachControl(element: HTMLElement): void;
  31617. /**
  31618. * Update the camera state according to the different inputs gathered during the frame.
  31619. */
  31620. update(): void;
  31621. /** @hidden */
  31622. _checkInputs(): void;
  31623. /** @hidden */
  31624. readonly rigCameras: Camera[];
  31625. /**
  31626. * Gets the post process used by the rig cameras
  31627. */
  31628. readonly rigPostProcess: Nullable<PostProcess>;
  31629. /**
  31630. * Internal, gets the first post proces.
  31631. * @returns the first post process to be run on this camera.
  31632. */
  31633. _getFirstPostProcess(): Nullable<PostProcess>;
  31634. private _cascadePostProcessesToRigCams;
  31635. /**
  31636. * Attach a post process to the camera.
  31637. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31638. * @param postProcess The post process to attach to the camera
  31639. * @param insertAt The position of the post process in case several of them are in use in the scene
  31640. * @returns the position the post process has been inserted at
  31641. */
  31642. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31643. /**
  31644. * Detach a post process to the camera.
  31645. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31646. * @param postProcess The post process to detach from the camera
  31647. */
  31648. detachPostProcess(postProcess: PostProcess): void;
  31649. /**
  31650. * Gets the current world matrix of the camera
  31651. */
  31652. getWorldMatrix(): Matrix;
  31653. /** @hidden */
  31654. _getViewMatrix(): Matrix;
  31655. /**
  31656. * Gets the current view matrix of the camera.
  31657. * @param force forces the camera to recompute the matrix without looking at the cached state
  31658. * @returns the view matrix
  31659. */
  31660. getViewMatrix(force?: boolean): Matrix;
  31661. /**
  31662. * Freeze the projection matrix.
  31663. * It will prevent the cache check of the camera projection compute and can speed up perf
  31664. * if no parameter of the camera are meant to change
  31665. * @param projection Defines manually a projection if necessary
  31666. */
  31667. freezeProjectionMatrix(projection?: Matrix): void;
  31668. /**
  31669. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31670. */
  31671. unfreezeProjectionMatrix(): void;
  31672. /**
  31673. * Gets the current projection matrix of the camera.
  31674. * @param force forces the camera to recompute the matrix without looking at the cached state
  31675. * @returns the projection matrix
  31676. */
  31677. getProjectionMatrix(force?: boolean): Matrix;
  31678. /**
  31679. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31680. * @returns a Matrix
  31681. */
  31682. getTransformationMatrix(): Matrix;
  31683. private _updateFrustumPlanes;
  31684. /**
  31685. * Checks if a cullable object (mesh...) is in the camera frustum
  31686. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31687. * @param target The object to check
  31688. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  31689. * @returns true if the object is in frustum otherwise false
  31690. */
  31691. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  31692. /**
  31693. * Checks if a cullable object (mesh...) is in the camera frustum
  31694. * Unlike isInFrustum this cheks the full bounding box
  31695. * @param target The object to check
  31696. * @returns true if the object is in frustum otherwise false
  31697. */
  31698. isCompletelyInFrustum(target: ICullable): boolean;
  31699. /**
  31700. * Gets a ray in the forward direction from the camera.
  31701. * @param length Defines the length of the ray to create
  31702. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31703. * @param origin Defines the start point of the ray which defaults to the camera position
  31704. * @returns the forward ray
  31705. */
  31706. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31707. /**
  31708. * Releases resources associated with this node.
  31709. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31710. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31711. */
  31712. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31713. /** @hidden */
  31714. _isLeftCamera: boolean;
  31715. /**
  31716. * Gets the left camera of a rig setup in case of Rigged Camera
  31717. */
  31718. readonly isLeftCamera: boolean;
  31719. /** @hidden */
  31720. _isRightCamera: boolean;
  31721. /**
  31722. * Gets the right camera of a rig setup in case of Rigged Camera
  31723. */
  31724. readonly isRightCamera: boolean;
  31725. /**
  31726. * Gets the left camera of a rig setup in case of Rigged Camera
  31727. */
  31728. readonly leftCamera: Nullable<FreeCamera>;
  31729. /**
  31730. * Gets the right camera of a rig setup in case of Rigged Camera
  31731. */
  31732. readonly rightCamera: Nullable<FreeCamera>;
  31733. /**
  31734. * Gets the left camera target of a rig setup in case of Rigged Camera
  31735. * @returns the target position
  31736. */
  31737. getLeftTarget(): Nullable<Vector3>;
  31738. /**
  31739. * Gets the right camera target of a rig setup in case of Rigged Camera
  31740. * @returns the target position
  31741. */
  31742. getRightTarget(): Nullable<Vector3>;
  31743. /**
  31744. * @hidden
  31745. */
  31746. setCameraRigMode(mode: number, rigParams: any): void;
  31747. /** @hidden */
  31748. static _setStereoscopicRigMode(camera: Camera): void;
  31749. /** @hidden */
  31750. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31751. /** @hidden */
  31752. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31753. /** @hidden */
  31754. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31755. /** @hidden */
  31756. _getVRProjectionMatrix(): Matrix;
  31757. protected _updateCameraRotationMatrix(): void;
  31758. protected _updateWebVRCameraRotationMatrix(): void;
  31759. /**
  31760. * This function MUST be overwritten by the different WebVR cameras available.
  31761. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31762. * @hidden
  31763. */
  31764. _getWebVRProjectionMatrix(): Matrix;
  31765. /**
  31766. * This function MUST be overwritten by the different WebVR cameras available.
  31767. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31768. * @hidden
  31769. */
  31770. _getWebVRViewMatrix(): Matrix;
  31771. /** @hidden */
  31772. setCameraRigParameter(name: string, value: any): void;
  31773. /**
  31774. * needs to be overridden by children so sub has required properties to be copied
  31775. * @hidden
  31776. */
  31777. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31778. /**
  31779. * May need to be overridden by children
  31780. * @hidden
  31781. */
  31782. _updateRigCameras(): void;
  31783. /** @hidden */
  31784. _setupInputs(): void;
  31785. /**
  31786. * Serialiaze the camera setup to a json represention
  31787. * @returns the JSON representation
  31788. */
  31789. serialize(): any;
  31790. /**
  31791. * Clones the current camera.
  31792. * @param name The cloned camera name
  31793. * @returns the cloned camera
  31794. */
  31795. clone(name: string): Camera;
  31796. /**
  31797. * Gets the direction of the camera relative to a given local axis.
  31798. * @param localAxis Defines the reference axis to provide a relative direction.
  31799. * @return the direction
  31800. */
  31801. getDirection(localAxis: Vector3): Vector3;
  31802. /**
  31803. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31804. * @param localAxis Defines the reference axis to provide a relative direction.
  31805. * @param result Defines the vector to store the result in
  31806. */
  31807. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31808. /**
  31809. * Gets a camera constructor for a given camera type
  31810. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31811. * @param name The name of the camera the result will be able to instantiate
  31812. * @param scene The scene the result will construct the camera in
  31813. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31814. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31815. * @returns a factory method to construc the camera
  31816. */
  31817. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31818. /**
  31819. * Compute the world matrix of the camera.
  31820. * @returns the camera workd matrix
  31821. */
  31822. computeWorldMatrix(): Matrix;
  31823. /**
  31824. * Parse a JSON and creates the camera from the parsed information
  31825. * @param parsedCamera The JSON to parse
  31826. * @param scene The scene to instantiate the camera in
  31827. * @returns the newly constructed camera
  31828. */
  31829. static Parse(parsedCamera: any, scene: Scene): Camera;
  31830. }
  31831. }
  31832. declare module "babylonjs/Misc/tools" {
  31833. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31834. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31835. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31836. import { Observable } from "babylonjs/Misc/observable";
  31837. import { DomManagement } from "babylonjs/Misc/domManagement";
  31838. import { WebRequest } from "babylonjs/Misc/webRequest";
  31839. import { Camera } from "babylonjs/Cameras/camera";
  31840. import { Engine } from "babylonjs/Engines/engine";
  31841. import { Animation } from "babylonjs/Animations/animation";
  31842. /**
  31843. * Interface for any object that can request an animation frame
  31844. */
  31845. export interface ICustomAnimationFrameRequester {
  31846. /**
  31847. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31848. */
  31849. renderFunction?: Function;
  31850. /**
  31851. * Called to request the next frame to render to
  31852. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31853. */
  31854. requestAnimationFrame: Function;
  31855. /**
  31856. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31857. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31858. */
  31859. requestID?: number;
  31860. }
  31861. /**
  31862. * Interface containing an array of animations
  31863. */
  31864. export interface IAnimatable {
  31865. /**
  31866. * Array of animations
  31867. */
  31868. animations: Nullable<Array<Animation>>;
  31869. }
  31870. /** Interface used by value gradients (color, factor, ...) */
  31871. export interface IValueGradient {
  31872. /**
  31873. * Gets or sets the gradient value (between 0 and 1)
  31874. */
  31875. gradient: number;
  31876. }
  31877. /** Class used to store color4 gradient */
  31878. export class ColorGradient implements IValueGradient {
  31879. /**
  31880. * Gets or sets the gradient value (between 0 and 1)
  31881. */
  31882. gradient: number;
  31883. /**
  31884. * Gets or sets first associated color
  31885. */
  31886. color1: Color4;
  31887. /**
  31888. * Gets or sets second associated color
  31889. */
  31890. color2?: Color4;
  31891. /**
  31892. * Will get a color picked randomly between color1 and color2.
  31893. * If color2 is undefined then color1 will be used
  31894. * @param result defines the target Color4 to store the result in
  31895. */
  31896. getColorToRef(result: Color4): void;
  31897. }
  31898. /** Class used to store color 3 gradient */
  31899. export class Color3Gradient implements IValueGradient {
  31900. /**
  31901. * Gets or sets the gradient value (between 0 and 1)
  31902. */
  31903. gradient: number;
  31904. /**
  31905. * Gets or sets the associated color
  31906. */
  31907. color: Color3;
  31908. }
  31909. /** Class used to store factor gradient */
  31910. export class FactorGradient implements IValueGradient {
  31911. /**
  31912. * Gets or sets the gradient value (between 0 and 1)
  31913. */
  31914. gradient: number;
  31915. /**
  31916. * Gets or sets first associated factor
  31917. */
  31918. factor1: number;
  31919. /**
  31920. * Gets or sets second associated factor
  31921. */
  31922. factor2?: number;
  31923. /**
  31924. * Will get a number picked randomly between factor1 and factor2.
  31925. * If factor2 is undefined then factor1 will be used
  31926. * @returns the picked number
  31927. */
  31928. getFactor(): number;
  31929. }
  31930. /**
  31931. * @ignore
  31932. * Application error to support additional information when loading a file
  31933. */
  31934. export class LoadFileError extends Error {
  31935. /** defines the optional web request */
  31936. request?: WebRequest | undefined;
  31937. private static _setPrototypeOf;
  31938. /**
  31939. * Creates a new LoadFileError
  31940. * @param message defines the message of the error
  31941. * @param request defines the optional web request
  31942. */
  31943. constructor(message: string,
  31944. /** defines the optional web request */
  31945. request?: WebRequest | undefined);
  31946. }
  31947. /**
  31948. * Class used to define a retry strategy when error happens while loading assets
  31949. */
  31950. export class RetryStrategy {
  31951. /**
  31952. * Function used to defines an exponential back off strategy
  31953. * @param maxRetries defines the maximum number of retries (3 by default)
  31954. * @param baseInterval defines the interval between retries
  31955. * @returns the strategy function to use
  31956. */
  31957. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31958. }
  31959. /**
  31960. * File request interface
  31961. */
  31962. export interface IFileRequest {
  31963. /**
  31964. * Raised when the request is complete (success or error).
  31965. */
  31966. onCompleteObservable: Observable<IFileRequest>;
  31967. /**
  31968. * Aborts the request for a file.
  31969. */
  31970. abort: () => void;
  31971. }
  31972. /**
  31973. * Class containing a set of static utilities functions
  31974. */
  31975. export class Tools {
  31976. /**
  31977. * Gets or sets the base URL to use to load assets
  31978. */
  31979. static BaseUrl: string;
  31980. /**
  31981. * Enable/Disable Custom HTTP Request Headers globally.
  31982. * default = false
  31983. * @see CustomRequestHeaders
  31984. */
  31985. static UseCustomRequestHeaders: boolean;
  31986. /**
  31987. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31988. * i.e. when loading files, where the server/service expects an Authorization header
  31989. */
  31990. static CustomRequestHeaders: {
  31991. [key: string]: string;
  31992. };
  31993. /**
  31994. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31995. */
  31996. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31997. /**
  31998. * Default behaviour for cors in the application.
  31999. * It can be a string if the expected behavior is identical in the entire app.
  32000. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32001. */
  32002. static CorsBehavior: string | ((url: string | string[]) => string);
  32003. /**
  32004. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32005. * @ignorenaming
  32006. */
  32007. static UseFallbackTexture: boolean;
  32008. /**
  32009. * Use this object to register external classes like custom textures or material
  32010. * to allow the laoders to instantiate them
  32011. */
  32012. static RegisteredExternalClasses: {
  32013. [key: string]: Object;
  32014. };
  32015. /**
  32016. * Texture content used if a texture cannot loaded
  32017. * @ignorenaming
  32018. */
  32019. static fallbackTexture: string;
  32020. /**
  32021. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32022. * @param u defines the coordinate on X axis
  32023. * @param v defines the coordinate on Y axis
  32024. * @param width defines the width of the source data
  32025. * @param height defines the height of the source data
  32026. * @param pixels defines the source byte array
  32027. * @param color defines the output color
  32028. */
  32029. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  32030. /**
  32031. * Interpolates between a and b via alpha
  32032. * @param a The lower value (returned when alpha = 0)
  32033. * @param b The upper value (returned when alpha = 1)
  32034. * @param alpha The interpolation-factor
  32035. * @return The mixed value
  32036. */
  32037. static Mix(a: number, b: number, alpha: number): number;
  32038. /**
  32039. * Tries to instantiate a new object from a given class name
  32040. * @param className defines the class name to instantiate
  32041. * @returns the new object or null if the system was not able to do the instantiation
  32042. */
  32043. static Instantiate(className: string): any;
  32044. /**
  32045. * Provides a slice function that will work even on IE
  32046. * @param data defines the array to slice
  32047. * @param start defines the start of the data (optional)
  32048. * @param end defines the end of the data (optional)
  32049. * @returns the new sliced array
  32050. */
  32051. static Slice<T>(data: T, start?: number, end?: number): T;
  32052. /**
  32053. * Polyfill for setImmediate
  32054. * @param action defines the action to execute after the current execution block
  32055. */
  32056. static SetImmediate(action: () => void): void;
  32057. /**
  32058. * Function indicating if a number is an exponent of 2
  32059. * @param value defines the value to test
  32060. * @returns true if the value is an exponent of 2
  32061. */
  32062. static IsExponentOfTwo(value: number): boolean;
  32063. private static _tmpFloatArray;
  32064. /**
  32065. * Returns the nearest 32-bit single precision float representation of a Number
  32066. * @param value A Number. If the parameter is of a different type, it will get converted
  32067. * to a number or to NaN if it cannot be converted
  32068. * @returns number
  32069. */
  32070. static FloatRound(value: number): number;
  32071. /**
  32072. * Find the next highest power of two.
  32073. * @param x Number to start search from.
  32074. * @return Next highest power of two.
  32075. */
  32076. static CeilingPOT(x: number): number;
  32077. /**
  32078. * Find the next lowest power of two.
  32079. * @param x Number to start search from.
  32080. * @return Next lowest power of two.
  32081. */
  32082. static FloorPOT(x: number): number;
  32083. /**
  32084. * Find the nearest power of two.
  32085. * @param x Number to start search from.
  32086. * @return Next nearest power of two.
  32087. */
  32088. static NearestPOT(x: number): number;
  32089. /**
  32090. * Get the closest exponent of two
  32091. * @param value defines the value to approximate
  32092. * @param max defines the maximum value to return
  32093. * @param mode defines how to define the closest value
  32094. * @returns closest exponent of two of the given value
  32095. */
  32096. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32097. /**
  32098. * Extracts the filename from a path
  32099. * @param path defines the path to use
  32100. * @returns the filename
  32101. */
  32102. static GetFilename(path: string): string;
  32103. /**
  32104. * Extracts the "folder" part of a path (everything before the filename).
  32105. * @param uri The URI to extract the info from
  32106. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32107. * @returns The "folder" part of the path
  32108. */
  32109. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32110. /**
  32111. * Extracts text content from a DOM element hierarchy
  32112. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32113. */
  32114. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32115. /**
  32116. * Convert an angle in radians to degrees
  32117. * @param angle defines the angle to convert
  32118. * @returns the angle in degrees
  32119. */
  32120. static ToDegrees(angle: number): number;
  32121. /**
  32122. * Convert an angle in degrees to radians
  32123. * @param angle defines the angle to convert
  32124. * @returns the angle in radians
  32125. */
  32126. static ToRadians(angle: number): number;
  32127. /**
  32128. * Encode a buffer to a base64 string
  32129. * @param buffer defines the buffer to encode
  32130. * @returns the encoded string
  32131. */
  32132. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32133. /**
  32134. * Extracts minimum and maximum values from a list of indexed positions
  32135. * @param positions defines the positions to use
  32136. * @param indices defines the indices to the positions
  32137. * @param indexStart defines the start index
  32138. * @param indexCount defines the end index
  32139. * @param bias defines bias value to add to the result
  32140. * @return minimum and maximum values
  32141. */
  32142. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  32143. minimum: Vector3;
  32144. maximum: Vector3;
  32145. };
  32146. /**
  32147. * Extracts minimum and maximum values from a list of positions
  32148. * @param positions defines the positions to use
  32149. * @param start defines the start index in the positions array
  32150. * @param count defines the number of positions to handle
  32151. * @param bias defines bias value to add to the result
  32152. * @param stride defines the stride size to use (distance between two positions in the positions array)
  32153. * @return minimum and maximum values
  32154. */
  32155. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  32156. minimum: Vector3;
  32157. maximum: Vector3;
  32158. };
  32159. /**
  32160. * Returns an array if obj is not an array
  32161. * @param obj defines the object to evaluate as an array
  32162. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32163. * @returns either obj directly if obj is an array or a new array containing obj
  32164. */
  32165. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32166. /**
  32167. * Gets the pointer prefix to use
  32168. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32169. */
  32170. static GetPointerPrefix(): string;
  32171. /**
  32172. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32173. * @param func - the function to be called
  32174. * @param requester - the object that will request the next frame. Falls back to window.
  32175. * @returns frame number
  32176. */
  32177. static QueueNewFrame(func: () => void, requester?: any): number;
  32178. /**
  32179. * Ask the browser to promote the current element to fullscreen rendering mode
  32180. * @param element defines the DOM element to promote
  32181. */
  32182. static RequestFullscreen(element: HTMLElement): void;
  32183. /**
  32184. * Asks the browser to exit fullscreen mode
  32185. */
  32186. static ExitFullscreen(): void;
  32187. /**
  32188. * Ask the browser to promote the current element to pointerlock mode
  32189. * @param element defines the DOM element to promote
  32190. */
  32191. static RequestPointerlock(element: HTMLElement): void;
  32192. /**
  32193. * Asks the browser to exit pointerlock mode
  32194. */
  32195. static ExitPointerlock(): void;
  32196. /**
  32197. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32198. * @param url define the url we are trying
  32199. * @param element define the dom element where to configure the cors policy
  32200. */
  32201. static SetCorsBehavior(url: string | string[], element: {
  32202. crossOrigin: string | null;
  32203. }): void;
  32204. /**
  32205. * Removes unwanted characters from an url
  32206. * @param url defines the url to clean
  32207. * @returns the cleaned url
  32208. */
  32209. static CleanUrl(url: string): string;
  32210. /**
  32211. * Gets or sets a function used to pre-process url before using them to load assets
  32212. */
  32213. static PreprocessUrl: (url: string) => string;
  32214. /**
  32215. * Loads an image as an HTMLImageElement.
  32216. * @param input url string, ArrayBuffer, or Blob to load
  32217. * @param onLoad callback called when the image successfully loads
  32218. * @param onError callback called when the image fails to load
  32219. * @param offlineProvider offline provider for caching
  32220. * @returns the HTMLImageElement of the loaded image
  32221. */
  32222. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32223. /**
  32224. * Loads a file
  32225. * @param url url string, ArrayBuffer, or Blob to load
  32226. * @param onSuccess callback called when the file successfully loads
  32227. * @param onProgress callback called while file is loading (if the server supports this mode)
  32228. * @param offlineProvider defines the offline provider for caching
  32229. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32230. * @param onError callback called when the file fails to load
  32231. * @returns a file request object
  32232. */
  32233. 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;
  32234. /**
  32235. * Loads a file from a url
  32236. * @param url the file url to load
  32237. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32238. */
  32239. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32240. /**
  32241. * Load a script (identified by an url). When the url returns, the
  32242. * content of this file is added into a new script element, attached to the DOM (body element)
  32243. * @param scriptUrl defines the url of the script to laod
  32244. * @param onSuccess defines the callback called when the script is loaded
  32245. * @param onError defines the callback to call if an error occurs
  32246. * @param scriptId defines the id of the script element
  32247. */
  32248. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32249. /**
  32250. * Load an asynchronous script (identified by an url). When the url returns, the
  32251. * content of this file is added into a new script element, attached to the DOM (body element)
  32252. * @param scriptUrl defines the url of the script to laod
  32253. * @param scriptId defines the id of the script element
  32254. * @returns a promise request object
  32255. */
  32256. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32257. /**
  32258. * Loads a file from a blob
  32259. * @param fileToLoad defines the blob to use
  32260. * @param callback defines the callback to call when data is loaded
  32261. * @param progressCallback defines the callback to call during loading process
  32262. * @returns a file request object
  32263. */
  32264. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32265. /**
  32266. * Loads a file
  32267. * @param fileToLoad defines the file to load
  32268. * @param callback defines the callback to call when data is loaded
  32269. * @param progressCallBack defines the callback to call during loading process
  32270. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32271. * @returns a file request object
  32272. */
  32273. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32274. /**
  32275. * Creates a data url from a given string content
  32276. * @param content defines the content to convert
  32277. * @returns the new data url link
  32278. */
  32279. static FileAsURL(content: string): string;
  32280. /**
  32281. * Format the given number to a specific decimal format
  32282. * @param value defines the number to format
  32283. * @param decimals defines the number of decimals to use
  32284. * @returns the formatted string
  32285. */
  32286. static Format(value: number, decimals?: number): string;
  32287. /**
  32288. * Checks if a given vector is inside a specific range
  32289. * @param v defines the vector to test
  32290. * @param min defines the minimum range
  32291. * @param max defines the maximum range
  32292. */
  32293. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  32294. /**
  32295. * Tries to copy an object by duplicating every property
  32296. * @param source defines the source object
  32297. * @param destination defines the target object
  32298. * @param doNotCopyList defines a list of properties to avoid
  32299. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32300. */
  32301. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32302. /**
  32303. * Gets a boolean indicating if the given object has no own property
  32304. * @param obj defines the object to test
  32305. * @returns true if object has no own property
  32306. */
  32307. static IsEmpty(obj: any): boolean;
  32308. /**
  32309. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  32310. * @param str Source string
  32311. * @param suffix Suffix to search for in the source string
  32312. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  32313. */
  32314. static EndsWith(str: string, suffix: string): boolean;
  32315. /**
  32316. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  32317. * @param str Source string
  32318. * @param suffix Suffix to search for in the source string
  32319. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  32320. */
  32321. static StartsWith(str: string, suffix: string): boolean;
  32322. /**
  32323. * Function used to register events at window level
  32324. * @param events defines the events to register
  32325. */
  32326. static RegisterTopRootEvents(events: {
  32327. name: string;
  32328. handler: Nullable<(e: FocusEvent) => any>;
  32329. }[]): void;
  32330. /**
  32331. * Function used to unregister events from window level
  32332. * @param events defines the events to unregister
  32333. */
  32334. static UnregisterTopRootEvents(events: {
  32335. name: string;
  32336. handler: Nullable<(e: FocusEvent) => any>;
  32337. }[]): void;
  32338. /**
  32339. * @ignore
  32340. */
  32341. static _ScreenshotCanvas: HTMLCanvasElement;
  32342. /**
  32343. * Dumps the current bound framebuffer
  32344. * @param width defines the rendering width
  32345. * @param height defines the rendering height
  32346. * @param engine defines the hosting engine
  32347. * @param successCallback defines the callback triggered once the data are available
  32348. * @param mimeType defines the mime type of the result
  32349. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32350. */
  32351. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32352. /**
  32353. * Converts the canvas data to blob.
  32354. * This acts as a polyfill for browsers not supporting the to blob function.
  32355. * @param canvas Defines the canvas to extract the data from
  32356. * @param successCallback Defines the callback triggered once the data are available
  32357. * @param mimeType Defines the mime type of the result
  32358. */
  32359. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32360. /**
  32361. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32362. * @param successCallback defines the callback triggered once the data are available
  32363. * @param mimeType defines the mime type of the result
  32364. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32365. */
  32366. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32367. /**
  32368. * Downloads a blob in the browser
  32369. * @param blob defines the blob to download
  32370. * @param fileName defines the name of the downloaded file
  32371. */
  32372. static Download(blob: Blob, fileName: string): void;
  32373. /**
  32374. * Captures a screenshot of the current rendering
  32375. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32376. * @param engine defines the rendering engine
  32377. * @param camera defines the source camera
  32378. * @param size This parameter can be set to a single number or to an object with the
  32379. * following (optional) properties: precision, width, height. If a single number is passed,
  32380. * it will be used for both width and height. If an object is passed, the screenshot size
  32381. * will be derived from the parameters. The precision property is a multiplier allowing
  32382. * rendering at a higher or lower resolution
  32383. * @param successCallback defines the callback receives a single parameter which contains the
  32384. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32385. * src parameter of an <img> to display it
  32386. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32387. * Check your browser for supported MIME types
  32388. */
  32389. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  32390. /**
  32391. * Generates an image screenshot from the specified camera.
  32392. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32393. * @param engine The engine to use for rendering
  32394. * @param camera The camera to use for rendering
  32395. * @param size This parameter can be set to a single number or to an object with the
  32396. * following (optional) properties: precision, width, height. If a single number is passed,
  32397. * it will be used for both width and height. If an object is passed, the screenshot size
  32398. * will be derived from the parameters. The precision property is a multiplier allowing
  32399. * rendering at a higher or lower resolution
  32400. * @param successCallback The callback receives a single parameter which contains the
  32401. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32402. * src parameter of an <img> to display it
  32403. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32404. * Check your browser for supported MIME types
  32405. * @param samples Texture samples (default: 1)
  32406. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32407. * @param fileName A name for for the downloaded file.
  32408. */
  32409. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32410. /**
  32411. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32412. * Be aware Math.random() could cause collisions, but:
  32413. * "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"
  32414. * @returns a pseudo random id
  32415. */
  32416. static RandomId(): string;
  32417. /**
  32418. * Test if the given uri is a base64 string
  32419. * @param uri The uri to test
  32420. * @return True if the uri is a base64 string or false otherwise
  32421. */
  32422. static IsBase64(uri: string): boolean;
  32423. /**
  32424. * Decode the given base64 uri.
  32425. * @param uri The uri to decode
  32426. * @return The decoded base64 data.
  32427. */
  32428. static DecodeBase64(uri: string): ArrayBuffer;
  32429. /**
  32430. * Gets the absolute url.
  32431. * @param url the input url
  32432. * @return the absolute url
  32433. */
  32434. static GetAbsoluteUrl(url: string): string;
  32435. /**
  32436. * No log
  32437. */
  32438. static readonly NoneLogLevel: number;
  32439. /**
  32440. * Only message logs
  32441. */
  32442. static readonly MessageLogLevel: number;
  32443. /**
  32444. * Only warning logs
  32445. */
  32446. static readonly WarningLogLevel: number;
  32447. /**
  32448. * Only error logs
  32449. */
  32450. static readonly ErrorLogLevel: number;
  32451. /**
  32452. * All logs
  32453. */
  32454. static readonly AllLogLevel: number;
  32455. /**
  32456. * Gets a value indicating the number of loading errors
  32457. * @ignorenaming
  32458. */
  32459. static readonly errorsCount: number;
  32460. /**
  32461. * Callback called when a new log is added
  32462. */
  32463. static OnNewCacheEntry: (entry: string) => void;
  32464. /**
  32465. * Log a message to the console
  32466. * @param message defines the message to log
  32467. */
  32468. static Log(message: string): void;
  32469. /**
  32470. * Write a warning message to the console
  32471. * @param message defines the message to log
  32472. */
  32473. static Warn(message: string): void;
  32474. /**
  32475. * Write an error message to the console
  32476. * @param message defines the message to log
  32477. */
  32478. static Error(message: string): void;
  32479. /**
  32480. * Gets current log cache (list of logs)
  32481. */
  32482. static readonly LogCache: string;
  32483. /**
  32484. * Clears the log cache
  32485. */
  32486. static ClearLogCache(): void;
  32487. /**
  32488. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32489. */
  32490. static LogLevels: number;
  32491. /**
  32492. * Checks if the loaded document was accessed via `file:`-Protocol.
  32493. * @returns boolean
  32494. */
  32495. static IsFileURL(): boolean;
  32496. /**
  32497. * Checks if the window object exists
  32498. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32499. */
  32500. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32501. /**
  32502. * No performance log
  32503. */
  32504. static readonly PerformanceNoneLogLevel: number;
  32505. /**
  32506. * Use user marks to log performance
  32507. */
  32508. static readonly PerformanceUserMarkLogLevel: number;
  32509. /**
  32510. * Log performance to the console
  32511. */
  32512. static readonly PerformanceConsoleLogLevel: number;
  32513. private static _performance;
  32514. /**
  32515. * Sets the current performance log level
  32516. */
  32517. static PerformanceLogLevel: number;
  32518. private static _StartPerformanceCounterDisabled;
  32519. private static _EndPerformanceCounterDisabled;
  32520. private static _StartUserMark;
  32521. private static _EndUserMark;
  32522. private static _StartPerformanceConsole;
  32523. private static _EndPerformanceConsole;
  32524. /**
  32525. * Starts a performance counter
  32526. */
  32527. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32528. /**
  32529. * Ends a specific performance coutner
  32530. */
  32531. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32532. /**
  32533. * Gets either window.performance.now() if supported or Date.now() else
  32534. */
  32535. static readonly Now: number;
  32536. /**
  32537. * This method will return the name of the class used to create the instance of the given object.
  32538. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32539. * @param object the object to get the class name from
  32540. * @param isType defines if the object is actually a type
  32541. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32542. */
  32543. static GetClassName(object: any, isType?: boolean): string;
  32544. /**
  32545. * Gets the first element of an array satisfying a given predicate
  32546. * @param array defines the array to browse
  32547. * @param predicate defines the predicate to use
  32548. * @returns null if not found or the element
  32549. */
  32550. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32551. /**
  32552. * This method will return the name of the full name of the class, including its owning module (if any).
  32553. * 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).
  32554. * @param object the object to get the class name from
  32555. * @param isType defines if the object is actually a type
  32556. * @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.
  32557. * @ignorenaming
  32558. */
  32559. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32560. /**
  32561. * Returns a promise that resolves after the given amount of time.
  32562. * @param delay Number of milliseconds to delay
  32563. * @returns Promise that resolves after the given amount of time
  32564. */
  32565. static DelayAsync(delay: number): Promise<void>;
  32566. /**
  32567. * Gets the current gradient from an array of IValueGradient
  32568. * @param ratio defines the current ratio to get
  32569. * @param gradients defines the array of IValueGradient
  32570. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32571. */
  32572. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32573. }
  32574. /**
  32575. * This class is used to track a performance counter which is number based.
  32576. * The user has access to many properties which give statistics of different nature.
  32577. *
  32578. * The implementer can track two kinds of Performance Counter: time and count.
  32579. * 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.
  32580. * 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.
  32581. */
  32582. export class PerfCounter {
  32583. /**
  32584. * Gets or sets a global boolean to turn on and off all the counters
  32585. */
  32586. static Enabled: boolean;
  32587. /**
  32588. * Returns the smallest value ever
  32589. */
  32590. readonly min: number;
  32591. /**
  32592. * Returns the biggest value ever
  32593. */
  32594. readonly max: number;
  32595. /**
  32596. * Returns the average value since the performance counter is running
  32597. */
  32598. readonly average: number;
  32599. /**
  32600. * Returns the average value of the last second the counter was monitored
  32601. */
  32602. readonly lastSecAverage: number;
  32603. /**
  32604. * Returns the current value
  32605. */
  32606. readonly current: number;
  32607. /**
  32608. * Gets the accumulated total
  32609. */
  32610. readonly total: number;
  32611. /**
  32612. * Gets the total value count
  32613. */
  32614. readonly count: number;
  32615. /**
  32616. * Creates a new counter
  32617. */
  32618. constructor();
  32619. /**
  32620. * Call this method to start monitoring a new frame.
  32621. * 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.
  32622. */
  32623. fetchNewFrame(): void;
  32624. /**
  32625. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32626. * @param newCount the count value to add to the monitored count
  32627. * @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.
  32628. */
  32629. addCount(newCount: number, fetchResult: boolean): void;
  32630. /**
  32631. * Start monitoring this performance counter
  32632. */
  32633. beginMonitoring(): void;
  32634. /**
  32635. * Compute the time lapsed since the previous beginMonitoring() call.
  32636. * @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
  32637. */
  32638. endMonitoring(newFrame?: boolean): void;
  32639. private _fetchResult;
  32640. private _startMonitoringTime;
  32641. private _min;
  32642. private _max;
  32643. private _average;
  32644. private _current;
  32645. private _totalValueCount;
  32646. private _totalAccumulated;
  32647. private _lastSecAverage;
  32648. private _lastSecAccumulated;
  32649. private _lastSecTime;
  32650. private _lastSecValueCount;
  32651. }
  32652. /**
  32653. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32654. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32655. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32656. * @param name The name of the class, case should be preserved
  32657. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32658. */
  32659. export function className(name: string, module?: string): (target: Object) => void;
  32660. /**
  32661. * An implementation of a loop for asynchronous functions.
  32662. */
  32663. export class AsyncLoop {
  32664. /**
  32665. * Defines the number of iterations for the loop
  32666. */
  32667. iterations: number;
  32668. /**
  32669. * Defines the current index of the loop.
  32670. */
  32671. index: number;
  32672. private _done;
  32673. private _fn;
  32674. private _successCallback;
  32675. /**
  32676. * Constructor.
  32677. * @param iterations the number of iterations.
  32678. * @param func the function to run each iteration
  32679. * @param successCallback the callback that will be called upon succesful execution
  32680. * @param offset starting offset.
  32681. */
  32682. constructor(
  32683. /**
  32684. * Defines the number of iterations for the loop
  32685. */
  32686. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32687. /**
  32688. * Execute the next iteration. Must be called after the last iteration was finished.
  32689. */
  32690. executeNext(): void;
  32691. /**
  32692. * Break the loop and run the success callback.
  32693. */
  32694. breakLoop(): void;
  32695. /**
  32696. * Create and run an async loop.
  32697. * @param iterations the number of iterations.
  32698. * @param fn the function to run each iteration
  32699. * @param successCallback the callback that will be called upon succesful execution
  32700. * @param offset starting offset.
  32701. * @returns the created async loop object
  32702. */
  32703. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32704. /**
  32705. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32706. * @param iterations total number of iterations
  32707. * @param syncedIterations number of synchronous iterations in each async iteration.
  32708. * @param fn the function to call each iteration.
  32709. * @param callback a success call back that will be called when iterating stops.
  32710. * @param breakFunction a break condition (optional)
  32711. * @param timeout timeout settings for the setTimeout function. default - 0.
  32712. * @returns the created async loop object
  32713. */
  32714. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32715. }
  32716. }
  32717. declare module "babylonjs/Collisions/collisionCoordinator" {
  32718. import { Nullable } from "babylonjs/types";
  32719. import { Scene } from "babylonjs/scene";
  32720. import { Vector3 } from "babylonjs/Maths/math";
  32721. import { Collider } from "babylonjs/Collisions/collider";
  32722. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32723. /** @hidden */
  32724. export interface ICollisionCoordinator {
  32725. createCollider(): Collider;
  32726. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32727. init(scene: Scene): void;
  32728. }
  32729. /** @hidden */
  32730. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32731. private _scene;
  32732. private _scaledPosition;
  32733. private _scaledVelocity;
  32734. private _finalPosition;
  32735. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32736. createCollider(): Collider;
  32737. init(scene: Scene): void;
  32738. private _collideWithWorld;
  32739. }
  32740. }
  32741. declare module "babylonjs/Inputs/scene.inputManager" {
  32742. import { Nullable } from "babylonjs/types";
  32743. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32744. import { Vector2 } from "babylonjs/Maths/math";
  32745. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32746. import { Scene } from "babylonjs/scene";
  32747. /**
  32748. * Class used to manage all inputs for the scene.
  32749. */
  32750. export class InputManager {
  32751. /** The distance in pixel that you have to move to prevent some events */
  32752. static DragMovementThreshold: number;
  32753. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32754. static LongPressDelay: number;
  32755. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32756. static DoubleClickDelay: number;
  32757. /** If you need to check double click without raising a single click at first click, enable this flag */
  32758. static ExclusiveDoubleClickMode: boolean;
  32759. private _wheelEventName;
  32760. private _onPointerMove;
  32761. private _onPointerDown;
  32762. private _onPointerUp;
  32763. private _initClickEvent;
  32764. private _initActionManager;
  32765. private _delayedSimpleClick;
  32766. private _delayedSimpleClickTimeout;
  32767. private _previousDelayedSimpleClickTimeout;
  32768. private _meshPickProceed;
  32769. private _previousButtonPressed;
  32770. private _currentPickResult;
  32771. private _previousPickResult;
  32772. private _totalPointersPressed;
  32773. private _doubleClickOccured;
  32774. private _pointerOverMesh;
  32775. private _pickedDownMesh;
  32776. private _pickedUpMesh;
  32777. private _pointerX;
  32778. private _pointerY;
  32779. private _unTranslatedPointerX;
  32780. private _unTranslatedPointerY;
  32781. private _startingPointerPosition;
  32782. private _previousStartingPointerPosition;
  32783. private _startingPointerTime;
  32784. private _previousStartingPointerTime;
  32785. private _pointerCaptures;
  32786. private _onKeyDown;
  32787. private _onKeyUp;
  32788. private _onCanvasFocusObserver;
  32789. private _onCanvasBlurObserver;
  32790. private _scene;
  32791. /**
  32792. * Creates a new InputManager
  32793. * @param scene defines the hosting scene
  32794. */
  32795. constructor(scene: Scene);
  32796. /**
  32797. * Gets the mesh that is currently under the pointer
  32798. */
  32799. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32800. /**
  32801. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32802. */
  32803. readonly unTranslatedPointer: Vector2;
  32804. /**
  32805. * Gets or sets the current on-screen X position of the pointer
  32806. */
  32807. pointerX: number;
  32808. /**
  32809. * Gets or sets the current on-screen Y position of the pointer
  32810. */
  32811. pointerY: number;
  32812. private _updatePointerPosition;
  32813. private _processPointerMove;
  32814. private _setRayOnPointerInfo;
  32815. private _checkPrePointerObservable;
  32816. /**
  32817. * Use this method to simulate a pointer move on a mesh
  32818. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32819. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32820. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32821. */
  32822. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32823. /**
  32824. * Use this method to simulate a pointer down on a mesh
  32825. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32826. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32827. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32828. */
  32829. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32830. private _processPointerDown;
  32831. /** @hidden */
  32832. _isPointerSwiping(): boolean;
  32833. /**
  32834. * Use this method to simulate a pointer up on a mesh
  32835. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32836. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32837. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32838. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32839. */
  32840. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32841. private _processPointerUp;
  32842. /**
  32843. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32844. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32845. * @returns true if the pointer was captured
  32846. */
  32847. isPointerCaptured(pointerId?: number): boolean;
  32848. /**
  32849. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32850. * @param attachUp defines if you want to attach events to pointerup
  32851. * @param attachDown defines if you want to attach events to pointerdown
  32852. * @param attachMove defines if you want to attach events to pointermove
  32853. */
  32854. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32855. /**
  32856. * Detaches all event handlers
  32857. */
  32858. detachControl(): void;
  32859. /**
  32860. * Force the value of meshUnderPointer
  32861. * @param mesh defines the mesh to use
  32862. */
  32863. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32864. /**
  32865. * Gets the mesh under the pointer
  32866. * @returns a Mesh or null if no mesh is under the pointer
  32867. */
  32868. getPointerOverMesh(): Nullable<AbstractMesh>;
  32869. }
  32870. }
  32871. declare module "babylonjs/Animations/animationGroup" {
  32872. import { Animatable } from "babylonjs/Animations/animatable";
  32873. import { Animation } from "babylonjs/Animations/animation";
  32874. import { Scene, IDisposable } from "babylonjs/scene";
  32875. import { Observable } from "babylonjs/Misc/observable";
  32876. import { Nullable } from "babylonjs/types";
  32877. import "babylonjs/Animations/animatable";
  32878. /**
  32879. * This class defines the direct association between an animation and a target
  32880. */
  32881. export class TargetedAnimation {
  32882. /**
  32883. * Animation to perform
  32884. */
  32885. animation: Animation;
  32886. /**
  32887. * Target to animate
  32888. */
  32889. target: any;
  32890. /**
  32891. * Serialize the object
  32892. * @returns the JSON object representing the current entity
  32893. */
  32894. serialize(): any;
  32895. }
  32896. /**
  32897. * Use this class to create coordinated animations on multiple targets
  32898. */
  32899. export class AnimationGroup implements IDisposable {
  32900. /** The name of the animation group */
  32901. name: string;
  32902. private _scene;
  32903. private _targetedAnimations;
  32904. private _animatables;
  32905. private _from;
  32906. private _to;
  32907. private _isStarted;
  32908. private _isPaused;
  32909. private _speedRatio;
  32910. private _loopAnimation;
  32911. /**
  32912. * Gets or sets the unique id of the node
  32913. */
  32914. uniqueId: number;
  32915. /**
  32916. * This observable will notify when one animation have ended
  32917. */
  32918. onAnimationEndObservable: Observable<TargetedAnimation>;
  32919. /**
  32920. * Observer raised when one animation loops
  32921. */
  32922. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32923. /**
  32924. * This observable will notify when all animations have ended.
  32925. */
  32926. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32927. /**
  32928. * This observable will notify when all animations have paused.
  32929. */
  32930. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32931. /**
  32932. * This observable will notify when all animations are playing.
  32933. */
  32934. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32935. /**
  32936. * Gets the first frame
  32937. */
  32938. readonly from: number;
  32939. /**
  32940. * Gets the last frame
  32941. */
  32942. readonly to: number;
  32943. /**
  32944. * Define if the animations are started
  32945. */
  32946. readonly isStarted: boolean;
  32947. /**
  32948. * Gets a value indicating that the current group is playing
  32949. */
  32950. readonly isPlaying: boolean;
  32951. /**
  32952. * Gets or sets the speed ratio to use for all animations
  32953. */
  32954. /**
  32955. * Gets or sets the speed ratio to use for all animations
  32956. */
  32957. speedRatio: number;
  32958. /**
  32959. * Gets or sets if all animations should loop or not
  32960. */
  32961. loopAnimation: boolean;
  32962. /**
  32963. * Gets the targeted animations for this animation group
  32964. */
  32965. readonly targetedAnimations: Array<TargetedAnimation>;
  32966. /**
  32967. * returning the list of animatables controlled by this animation group.
  32968. */
  32969. readonly animatables: Array<Animatable>;
  32970. /**
  32971. * Instantiates a new Animation Group.
  32972. * This helps managing several animations at once.
  32973. * @see http://doc.babylonjs.com/how_to/group
  32974. * @param name Defines the name of the group
  32975. * @param scene Defines the scene the group belongs to
  32976. */
  32977. constructor(
  32978. /** The name of the animation group */
  32979. name: string, scene?: Nullable<Scene>);
  32980. /**
  32981. * Add an animation (with its target) in the group
  32982. * @param animation defines the animation we want to add
  32983. * @param target defines the target of the animation
  32984. * @returns the TargetedAnimation object
  32985. */
  32986. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32987. /**
  32988. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32989. * It can add constant keys at begin or end
  32990. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32991. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32992. * @returns the animation group
  32993. */
  32994. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32995. /**
  32996. * Start all animations on given targets
  32997. * @param loop defines if animations must loop
  32998. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32999. * @param from defines the from key (optional)
  33000. * @param to defines the to key (optional)
  33001. * @returns the current animation group
  33002. */
  33003. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33004. /**
  33005. * Pause all animations
  33006. * @returns the animation group
  33007. */
  33008. pause(): AnimationGroup;
  33009. /**
  33010. * Play all animations to initial state
  33011. * This function will start() the animations if they were not started or will restart() them if they were paused
  33012. * @param loop defines if animations must loop
  33013. * @returns the animation group
  33014. */
  33015. play(loop?: boolean): AnimationGroup;
  33016. /**
  33017. * Reset all animations to initial state
  33018. * @returns the animation group
  33019. */
  33020. reset(): AnimationGroup;
  33021. /**
  33022. * Restart animations from key 0
  33023. * @returns the animation group
  33024. */
  33025. restart(): AnimationGroup;
  33026. /**
  33027. * Stop all animations
  33028. * @returns the animation group
  33029. */
  33030. stop(): AnimationGroup;
  33031. /**
  33032. * Set animation weight for all animatables
  33033. * @param weight defines the weight to use
  33034. * @return the animationGroup
  33035. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33036. */
  33037. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33038. /**
  33039. * Synchronize and normalize all animatables with a source animatable
  33040. * @param root defines the root animatable to synchronize with
  33041. * @return the animationGroup
  33042. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33043. */
  33044. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33045. /**
  33046. * Goes to a specific frame in this animation group
  33047. * @param frame the frame number to go to
  33048. * @return the animationGroup
  33049. */
  33050. goToFrame(frame: number): AnimationGroup;
  33051. /**
  33052. * Dispose all associated resources
  33053. */
  33054. dispose(): void;
  33055. private _checkAnimationGroupEnded;
  33056. /**
  33057. * Clone the current animation group and returns a copy
  33058. * @param newName defines the name of the new group
  33059. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33060. * @returns the new aniamtion group
  33061. */
  33062. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33063. /**
  33064. * Serializes the animationGroup to an object
  33065. * @returns Serialized object
  33066. */
  33067. serialize(): any;
  33068. /**
  33069. * Returns a new AnimationGroup object parsed from the source provided.
  33070. * @param parsedAnimationGroup defines the source
  33071. * @param scene defines the scene that will receive the animationGroup
  33072. * @returns a new AnimationGroup
  33073. */
  33074. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33075. /**
  33076. * Returns the string "AnimationGroup"
  33077. * @returns "AnimationGroup"
  33078. */
  33079. getClassName(): string;
  33080. /**
  33081. * Creates a detailled string about the object
  33082. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33083. * @returns a string representing the object
  33084. */
  33085. toString(fullDetails?: boolean): string;
  33086. }
  33087. }
  33088. declare module "babylonjs/scene" {
  33089. import { Nullable } from "babylonjs/types";
  33090. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  33091. import { Observable } from "babylonjs/Misc/observable";
  33092. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33093. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  33094. import { Geometry } from "babylonjs/Meshes/geometry";
  33095. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33096. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33098. import { Mesh } from "babylonjs/Meshes/mesh";
  33099. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33100. import { Bone } from "babylonjs/Bones/bone";
  33101. import { Skeleton } from "babylonjs/Bones/skeleton";
  33102. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33103. import { Camera } from "babylonjs/Cameras/camera";
  33104. import { AbstractScene } from "babylonjs/abstractScene";
  33105. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33106. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33107. import { Material } from "babylonjs/Materials/material";
  33108. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33109. import { Effect } from "babylonjs/Materials/effect";
  33110. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33111. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33112. import { Light } from "babylonjs/Lights/light";
  33113. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33114. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33115. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33116. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33117. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33118. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33119. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33120. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33121. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33122. import { Engine } from "babylonjs/Engines/engine";
  33123. import { Node } from "babylonjs/node";
  33124. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33125. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33126. import { WebRequest } from "babylonjs/Misc/webRequest";
  33127. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33128. import { Ray } from "babylonjs/Culling/ray";
  33129. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33130. import { Animation } from "babylonjs/Animations/animation";
  33131. import { Animatable } from "babylonjs/Animations/animatable";
  33132. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33133. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33134. import { Collider } from "babylonjs/Collisions/collider";
  33135. /**
  33136. * Define an interface for all classes that will hold resources
  33137. */
  33138. export interface IDisposable {
  33139. /**
  33140. * Releases all held resources
  33141. */
  33142. dispose(): void;
  33143. }
  33144. /** Interface defining initialization parameters for Scene class */
  33145. export interface SceneOptions {
  33146. /**
  33147. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33148. * It will improve performance when the number of geometries becomes important.
  33149. */
  33150. useGeometryUniqueIdsMap?: boolean;
  33151. /**
  33152. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33153. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33154. */
  33155. useMaterialMeshMap?: boolean;
  33156. /**
  33157. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33158. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33159. */
  33160. useClonedMeshhMap?: boolean;
  33161. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33162. virtual?: boolean;
  33163. }
  33164. /**
  33165. * Represents a scene to be rendered by the engine.
  33166. * @see http://doc.babylonjs.com/features/scene
  33167. */
  33168. export class Scene extends AbstractScene implements IAnimatable {
  33169. private static _uniqueIdCounter;
  33170. /** The fog is deactivated */
  33171. static readonly FOGMODE_NONE: number;
  33172. /** The fog density is following an exponential function */
  33173. static readonly FOGMODE_EXP: number;
  33174. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33175. static readonly FOGMODE_EXP2: number;
  33176. /** The fog density is following a linear function. */
  33177. static readonly FOGMODE_LINEAR: number;
  33178. /**
  33179. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33180. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33181. */
  33182. static MinDeltaTime: number;
  33183. /**
  33184. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33185. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33186. */
  33187. static MaxDeltaTime: number;
  33188. /**
  33189. * Factory used to create the default material.
  33190. * @param name The name of the material to create
  33191. * @param scene The scene to create the material for
  33192. * @returns The default material
  33193. */
  33194. static DefaultMaterialFactory(scene: Scene): Material;
  33195. /**
  33196. * Factory used to create the a collision coordinator.
  33197. * @returns The collision coordinator
  33198. */
  33199. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33200. /** @hidden */
  33201. _inputManager: InputManager;
  33202. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33203. cameraToUseForPointers: Nullable<Camera>;
  33204. /** @hidden */
  33205. readonly _isScene: boolean;
  33206. /**
  33207. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33208. */
  33209. autoClear: boolean;
  33210. /**
  33211. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33212. */
  33213. autoClearDepthAndStencil: boolean;
  33214. /**
  33215. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33216. */
  33217. clearColor: Color4;
  33218. /**
  33219. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33220. */
  33221. ambientColor: Color3;
  33222. /**
  33223. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33224. * It should only be one of the following (if not the default embedded one):
  33225. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33226. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33227. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33228. * The material properties need to be setup according to the type of texture in use.
  33229. */
  33230. environmentBRDFTexture: BaseTexture;
  33231. /** @hidden */
  33232. protected _environmentTexture: Nullable<BaseTexture>;
  33233. /**
  33234. * Texture used in all pbr material as the reflection texture.
  33235. * As in the majority of the scene they are the same (exception for multi room and so on),
  33236. * this is easier to reference from here than from all the materials.
  33237. */
  33238. /**
  33239. * Texture used in all pbr material as the reflection texture.
  33240. * As in the majority of the scene they are the same (exception for multi room and so on),
  33241. * this is easier to set here than in all the materials.
  33242. */
  33243. environmentTexture: Nullable<BaseTexture>;
  33244. /** @hidden */
  33245. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33246. /**
  33247. * Default image processing configuration used either in the rendering
  33248. * Forward main pass or through the imageProcessingPostProcess if present.
  33249. * As in the majority of the scene they are the same (exception for multi camera),
  33250. * this is easier to reference from here than from all the materials and post process.
  33251. *
  33252. * No setter as we it is a shared configuration, you can set the values instead.
  33253. */
  33254. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  33255. private _forceWireframe;
  33256. /**
  33257. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  33258. */
  33259. forceWireframe: boolean;
  33260. private _forcePointsCloud;
  33261. /**
  33262. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  33263. */
  33264. forcePointsCloud: boolean;
  33265. /**
  33266. * Gets or sets the active clipplane 1
  33267. */
  33268. clipPlane: Nullable<Plane>;
  33269. /**
  33270. * Gets or sets the active clipplane 2
  33271. */
  33272. clipPlane2: Nullable<Plane>;
  33273. /**
  33274. * Gets or sets the active clipplane 3
  33275. */
  33276. clipPlane3: Nullable<Plane>;
  33277. /**
  33278. * Gets or sets the active clipplane 4
  33279. */
  33280. clipPlane4: Nullable<Plane>;
  33281. /**
  33282. * Gets or sets a boolean indicating if animations are enabled
  33283. */
  33284. animationsEnabled: boolean;
  33285. private _animationPropertiesOverride;
  33286. /**
  33287. * Gets or sets the animation properties override
  33288. */
  33289. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  33290. /**
  33291. * Gets or sets a boolean indicating if a constant deltatime has to be used
  33292. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  33293. */
  33294. useConstantAnimationDeltaTime: boolean;
  33295. /**
  33296. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  33297. * Please note that it requires to run a ray cast through the scene on every frame
  33298. */
  33299. constantlyUpdateMeshUnderPointer: boolean;
  33300. /**
  33301. * Defines the HTML cursor to use when hovering over interactive elements
  33302. */
  33303. hoverCursor: string;
  33304. /**
  33305. * Defines the HTML default cursor to use (empty by default)
  33306. */
  33307. defaultCursor: string;
  33308. /**
  33309. * This is used to call preventDefault() on pointer down
  33310. * in order to block unwanted artifacts like system double clicks
  33311. */
  33312. preventDefaultOnPointerDown: boolean;
  33313. /**
  33314. * This is used to call preventDefault() on pointer up
  33315. * in order to block unwanted artifacts like system double clicks
  33316. */
  33317. preventDefaultOnPointerUp: boolean;
  33318. /**
  33319. * Gets or sets user defined metadata
  33320. */
  33321. metadata: any;
  33322. /**
  33323. * For internal use only. Please do not use.
  33324. */
  33325. reservedDataStore: any;
  33326. /**
  33327. * Gets the name of the plugin used to load this scene (null by default)
  33328. */
  33329. loadingPluginName: string;
  33330. /**
  33331. * Use this array to add regular expressions used to disable offline support for specific urls
  33332. */
  33333. disableOfflineSupportExceptionRules: RegExp[];
  33334. /**
  33335. * An event triggered when the scene is disposed.
  33336. */
  33337. onDisposeObservable: Observable<Scene>;
  33338. private _onDisposeObserver;
  33339. /** Sets a function to be executed when this scene is disposed. */
  33340. onDispose: () => void;
  33341. /**
  33342. * An event triggered before rendering the scene (right after animations and physics)
  33343. */
  33344. onBeforeRenderObservable: Observable<Scene>;
  33345. private _onBeforeRenderObserver;
  33346. /** Sets a function to be executed before rendering this scene */
  33347. beforeRender: Nullable<() => void>;
  33348. /**
  33349. * An event triggered after rendering the scene
  33350. */
  33351. onAfterRenderObservable: Observable<Scene>;
  33352. /**
  33353. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  33354. */
  33355. onAfterRenderCameraObservable: Observable<Camera>;
  33356. private _onAfterRenderObserver;
  33357. /** Sets a function to be executed after rendering this scene */
  33358. afterRender: Nullable<() => void>;
  33359. /**
  33360. * An event triggered before animating the scene
  33361. */
  33362. onBeforeAnimationsObservable: Observable<Scene>;
  33363. /**
  33364. * An event triggered after animations processing
  33365. */
  33366. onAfterAnimationsObservable: Observable<Scene>;
  33367. /**
  33368. * An event triggered before draw calls are ready to be sent
  33369. */
  33370. onBeforeDrawPhaseObservable: Observable<Scene>;
  33371. /**
  33372. * An event triggered after draw calls have been sent
  33373. */
  33374. onAfterDrawPhaseObservable: Observable<Scene>;
  33375. /**
  33376. * An event triggered when the scene is ready
  33377. */
  33378. onReadyObservable: Observable<Scene>;
  33379. /**
  33380. * An event triggered before rendering a camera
  33381. */
  33382. onBeforeCameraRenderObservable: Observable<Camera>;
  33383. private _onBeforeCameraRenderObserver;
  33384. /** Sets a function to be executed before rendering a camera*/
  33385. beforeCameraRender: () => void;
  33386. /**
  33387. * An event triggered after rendering a camera
  33388. */
  33389. onAfterCameraRenderObservable: Observable<Camera>;
  33390. private _onAfterCameraRenderObserver;
  33391. /** Sets a function to be executed after rendering a camera*/
  33392. afterCameraRender: () => void;
  33393. /**
  33394. * An event triggered when active meshes evaluation is about to start
  33395. */
  33396. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33397. /**
  33398. * An event triggered when active meshes evaluation is done
  33399. */
  33400. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33401. /**
  33402. * An event triggered when particles rendering is about to start
  33403. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33404. */
  33405. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33406. /**
  33407. * An event triggered when particles rendering is done
  33408. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33409. */
  33410. onAfterParticlesRenderingObservable: Observable<Scene>;
  33411. /**
  33412. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33413. */
  33414. onDataLoadedObservable: Observable<Scene>;
  33415. /**
  33416. * An event triggered when a camera is created
  33417. */
  33418. onNewCameraAddedObservable: Observable<Camera>;
  33419. /**
  33420. * An event triggered when a camera is removed
  33421. */
  33422. onCameraRemovedObservable: Observable<Camera>;
  33423. /**
  33424. * An event triggered when a light is created
  33425. */
  33426. onNewLightAddedObservable: Observable<Light>;
  33427. /**
  33428. * An event triggered when a light is removed
  33429. */
  33430. onLightRemovedObservable: Observable<Light>;
  33431. /**
  33432. * An event triggered when a geometry is created
  33433. */
  33434. onNewGeometryAddedObservable: Observable<Geometry>;
  33435. /**
  33436. * An event triggered when a geometry is removed
  33437. */
  33438. onGeometryRemovedObservable: Observable<Geometry>;
  33439. /**
  33440. * An event triggered when a transform node is created
  33441. */
  33442. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33443. /**
  33444. * An event triggered when a transform node is removed
  33445. */
  33446. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33447. /**
  33448. * An event triggered when a mesh is created
  33449. */
  33450. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33451. /**
  33452. * An event triggered when a mesh is removed
  33453. */
  33454. onMeshRemovedObservable: Observable<AbstractMesh>;
  33455. /**
  33456. * An event triggered when a skeleton is created
  33457. */
  33458. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33459. /**
  33460. * An event triggered when a skeleton is removed
  33461. */
  33462. onSkeletonRemovedObservable: Observable<Skeleton>;
  33463. /**
  33464. * An event triggered when a material is created
  33465. */
  33466. onNewMaterialAddedObservable: Observable<Material>;
  33467. /**
  33468. * An event triggered when a material is removed
  33469. */
  33470. onMaterialRemovedObservable: Observable<Material>;
  33471. /**
  33472. * An event triggered when a texture is created
  33473. */
  33474. onNewTextureAddedObservable: Observable<BaseTexture>;
  33475. /**
  33476. * An event triggered when a texture is removed
  33477. */
  33478. onTextureRemovedObservable: Observable<BaseTexture>;
  33479. /**
  33480. * An event triggered when render targets are about to be rendered
  33481. * Can happen multiple times per frame.
  33482. */
  33483. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33484. /**
  33485. * An event triggered when render targets were rendered.
  33486. * Can happen multiple times per frame.
  33487. */
  33488. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33489. /**
  33490. * An event triggered before calculating deterministic simulation step
  33491. */
  33492. onBeforeStepObservable: Observable<Scene>;
  33493. /**
  33494. * An event triggered after calculating deterministic simulation step
  33495. */
  33496. onAfterStepObservable: Observable<Scene>;
  33497. /**
  33498. * An event triggered when the activeCamera property is updated
  33499. */
  33500. onActiveCameraChanged: Observable<Scene>;
  33501. /**
  33502. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33503. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33504. * 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)
  33505. */
  33506. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33507. /**
  33508. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33509. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33510. * 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)
  33511. */
  33512. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33513. /**
  33514. * This Observable will when a mesh has been imported into the scene.
  33515. */
  33516. onMeshImportedObservable: Observable<AbstractMesh>;
  33517. /**
  33518. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33519. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33520. */
  33521. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33522. /** @hidden */
  33523. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33524. /**
  33525. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33526. */
  33527. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33528. /**
  33529. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33530. */
  33531. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33532. /**
  33533. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33534. */
  33535. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33536. /** Callback called when a pointer move is detected */
  33537. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33538. /** Callback called when a pointer down is detected */
  33539. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33540. /** Callback called when a pointer up is detected */
  33541. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33542. /** Callback called when a pointer pick is detected */
  33543. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33544. /**
  33545. * 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).
  33546. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33547. */
  33548. onPrePointerObservable: Observable<PointerInfoPre>;
  33549. /**
  33550. * Observable event triggered each time an input event is received from the rendering canvas
  33551. */
  33552. onPointerObservable: Observable<PointerInfo>;
  33553. /**
  33554. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33555. */
  33556. readonly unTranslatedPointer: Vector2;
  33557. /**
  33558. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33559. */
  33560. static DragMovementThreshold: number;
  33561. /**
  33562. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33563. */
  33564. static LongPressDelay: number;
  33565. /**
  33566. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33567. */
  33568. static DoubleClickDelay: number;
  33569. /** If you need to check double click without raising a single click at first click, enable this flag */
  33570. static ExclusiveDoubleClickMode: boolean;
  33571. /** @hidden */
  33572. _mirroredCameraPosition: Nullable<Vector3>;
  33573. /**
  33574. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33575. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33576. */
  33577. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33578. /**
  33579. * Observable event triggered each time an keyboard event is received from the hosting window
  33580. */
  33581. onKeyboardObservable: Observable<KeyboardInfo>;
  33582. private _useRightHandedSystem;
  33583. /**
  33584. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33585. */
  33586. useRightHandedSystem: boolean;
  33587. private _timeAccumulator;
  33588. private _currentStepId;
  33589. private _currentInternalStep;
  33590. /**
  33591. * Sets the step Id used by deterministic lock step
  33592. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33593. * @param newStepId defines the step Id
  33594. */
  33595. setStepId(newStepId: number): void;
  33596. /**
  33597. * Gets the step Id used by deterministic lock step
  33598. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33599. * @returns the step Id
  33600. */
  33601. getStepId(): number;
  33602. /**
  33603. * Gets the internal step used by deterministic lock step
  33604. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33605. * @returns the internal step
  33606. */
  33607. getInternalStep(): number;
  33608. private _fogEnabled;
  33609. /**
  33610. * Gets or sets a boolean indicating if fog is enabled on this scene
  33611. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33612. * (Default is true)
  33613. */
  33614. fogEnabled: boolean;
  33615. private _fogMode;
  33616. /**
  33617. * Gets or sets the fog mode to use
  33618. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33619. * | mode | value |
  33620. * | --- | --- |
  33621. * | FOGMODE_NONE | 0 |
  33622. * | FOGMODE_EXP | 1 |
  33623. * | FOGMODE_EXP2 | 2 |
  33624. * | FOGMODE_LINEAR | 3 |
  33625. */
  33626. fogMode: number;
  33627. /**
  33628. * Gets or sets the fog color to use
  33629. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33630. * (Default is Color3(0.2, 0.2, 0.3))
  33631. */
  33632. fogColor: Color3;
  33633. /**
  33634. * Gets or sets the fog density to use
  33635. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33636. * (Default is 0.1)
  33637. */
  33638. fogDensity: number;
  33639. /**
  33640. * Gets or sets the fog start distance to use
  33641. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33642. * (Default is 0)
  33643. */
  33644. fogStart: number;
  33645. /**
  33646. * Gets or sets the fog end distance to use
  33647. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33648. * (Default is 1000)
  33649. */
  33650. fogEnd: number;
  33651. private _shadowsEnabled;
  33652. /**
  33653. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33654. */
  33655. shadowsEnabled: boolean;
  33656. private _lightsEnabled;
  33657. /**
  33658. * Gets or sets a boolean indicating if lights are enabled on this scene
  33659. */
  33660. lightsEnabled: boolean;
  33661. /** All of the active cameras added to this scene. */
  33662. activeCameras: Camera[];
  33663. /** @hidden */
  33664. _activeCamera: Nullable<Camera>;
  33665. /** Gets or sets the current active camera */
  33666. activeCamera: Nullable<Camera>;
  33667. private _defaultMaterial;
  33668. /** The default material used on meshes when no material is affected */
  33669. /** The default material used on meshes when no material is affected */
  33670. defaultMaterial: Material;
  33671. private _texturesEnabled;
  33672. /**
  33673. * Gets or sets a boolean indicating if textures are enabled on this scene
  33674. */
  33675. texturesEnabled: boolean;
  33676. /**
  33677. * Gets or sets a boolean indicating if particles are enabled on this scene
  33678. */
  33679. particlesEnabled: boolean;
  33680. /**
  33681. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33682. */
  33683. spritesEnabled: boolean;
  33684. private _skeletonsEnabled;
  33685. /**
  33686. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33687. */
  33688. skeletonsEnabled: boolean;
  33689. /**
  33690. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33691. */
  33692. lensFlaresEnabled: boolean;
  33693. /**
  33694. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33695. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33696. */
  33697. collisionsEnabled: boolean;
  33698. private _collisionCoordinator;
  33699. /** @hidden */
  33700. readonly collisionCoordinator: ICollisionCoordinator;
  33701. /**
  33702. * Defines the gravity applied to this scene (used only for collisions)
  33703. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33704. */
  33705. gravity: Vector3;
  33706. /**
  33707. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33708. */
  33709. postProcessesEnabled: boolean;
  33710. /**
  33711. * The list of postprocesses added to the scene
  33712. */
  33713. postProcesses: PostProcess[];
  33714. /**
  33715. * Gets the current postprocess manager
  33716. */
  33717. postProcessManager: PostProcessManager;
  33718. /**
  33719. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33720. */
  33721. renderTargetsEnabled: boolean;
  33722. /**
  33723. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33724. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33725. */
  33726. dumpNextRenderTargets: boolean;
  33727. /**
  33728. * The list of user defined render targets added to the scene
  33729. */
  33730. customRenderTargets: RenderTargetTexture[];
  33731. /**
  33732. * Defines if texture loading must be delayed
  33733. * If true, textures will only be loaded when they need to be rendered
  33734. */
  33735. useDelayedTextureLoading: boolean;
  33736. /**
  33737. * Gets the list of meshes imported to the scene through SceneLoader
  33738. */
  33739. importedMeshesFiles: String[];
  33740. /**
  33741. * Gets or sets a boolean indicating if probes are enabled on this scene
  33742. */
  33743. probesEnabled: boolean;
  33744. /**
  33745. * Gets or sets the current offline provider to use to store scene data
  33746. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33747. */
  33748. offlineProvider: IOfflineProvider;
  33749. /**
  33750. * Gets or sets the action manager associated with the scene
  33751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33752. */
  33753. actionManager: AbstractActionManager;
  33754. private _meshesForIntersections;
  33755. /**
  33756. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33757. */
  33758. proceduralTexturesEnabled: boolean;
  33759. private _engine;
  33760. private _totalVertices;
  33761. /** @hidden */
  33762. _activeIndices: PerfCounter;
  33763. /** @hidden */
  33764. _activeParticles: PerfCounter;
  33765. /** @hidden */
  33766. _activeBones: PerfCounter;
  33767. private _animationRatio;
  33768. /** @hidden */
  33769. _animationTimeLast: number;
  33770. /** @hidden */
  33771. _animationTime: number;
  33772. /**
  33773. * Gets or sets a general scale for animation speed
  33774. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33775. */
  33776. animationTimeScale: number;
  33777. /** @hidden */
  33778. _cachedMaterial: Nullable<Material>;
  33779. /** @hidden */
  33780. _cachedEffect: Nullable<Effect>;
  33781. /** @hidden */
  33782. _cachedVisibility: Nullable<number>;
  33783. private _renderId;
  33784. private _frameId;
  33785. private _executeWhenReadyTimeoutId;
  33786. private _intermediateRendering;
  33787. private _viewUpdateFlag;
  33788. private _projectionUpdateFlag;
  33789. /** @hidden */
  33790. _toBeDisposed: Nullable<IDisposable>[];
  33791. private _activeRequests;
  33792. /** @hidden */
  33793. _pendingData: any[];
  33794. private _isDisposed;
  33795. /**
  33796. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33797. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33798. */
  33799. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33800. private _activeMeshes;
  33801. private _processedMaterials;
  33802. private _renderTargets;
  33803. /** @hidden */
  33804. _activeParticleSystems: SmartArray<IParticleSystem>;
  33805. private _activeSkeletons;
  33806. private _softwareSkinnedMeshes;
  33807. private _renderingManager;
  33808. /** @hidden */
  33809. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33810. private _transformMatrix;
  33811. private _sceneUbo;
  33812. /** @hidden */
  33813. _viewMatrix: Matrix;
  33814. private _projectionMatrix;
  33815. /** @hidden */
  33816. _forcedViewPosition: Nullable<Vector3>;
  33817. /** @hidden */
  33818. _frustumPlanes: Plane[];
  33819. /**
  33820. * Gets the list of frustum planes (built from the active camera)
  33821. */
  33822. readonly frustumPlanes: Plane[];
  33823. /**
  33824. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33825. * This is useful if there are more lights that the maximum simulteanous authorized
  33826. */
  33827. requireLightSorting: boolean;
  33828. /** @hidden */
  33829. readonly useMaterialMeshMap: boolean;
  33830. /** @hidden */
  33831. readonly useClonedMeshhMap: boolean;
  33832. private _externalData;
  33833. private _uid;
  33834. /**
  33835. * @hidden
  33836. * Backing store of defined scene components.
  33837. */
  33838. _components: ISceneComponent[];
  33839. /**
  33840. * @hidden
  33841. * Backing store of defined scene components.
  33842. */
  33843. _serializableComponents: ISceneSerializableComponent[];
  33844. /**
  33845. * List of components to register on the next registration step.
  33846. */
  33847. private _transientComponents;
  33848. /**
  33849. * Registers the transient components if needed.
  33850. */
  33851. private _registerTransientComponents;
  33852. /**
  33853. * @hidden
  33854. * Add a component to the scene.
  33855. * Note that the ccomponent could be registered on th next frame if this is called after
  33856. * the register component stage.
  33857. * @param component Defines the component to add to the scene
  33858. */
  33859. _addComponent(component: ISceneComponent): void;
  33860. /**
  33861. * @hidden
  33862. * Gets a component from the scene.
  33863. * @param name defines the name of the component to retrieve
  33864. * @returns the component or null if not present
  33865. */
  33866. _getComponent(name: string): Nullable<ISceneComponent>;
  33867. /**
  33868. * @hidden
  33869. * Defines the actions happening before camera updates.
  33870. */
  33871. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33872. /**
  33873. * @hidden
  33874. * Defines the actions happening before clear the canvas.
  33875. */
  33876. _beforeClearStage: Stage<SimpleStageAction>;
  33877. /**
  33878. * @hidden
  33879. * Defines the actions when collecting render targets for the frame.
  33880. */
  33881. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33882. /**
  33883. * @hidden
  33884. * Defines the actions happening for one camera in the frame.
  33885. */
  33886. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33887. /**
  33888. * @hidden
  33889. * Defines the actions happening during the per mesh ready checks.
  33890. */
  33891. _isReadyForMeshStage: Stage<MeshStageAction>;
  33892. /**
  33893. * @hidden
  33894. * Defines the actions happening before evaluate active mesh checks.
  33895. */
  33896. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33897. /**
  33898. * @hidden
  33899. * Defines the actions happening during the evaluate sub mesh checks.
  33900. */
  33901. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33902. /**
  33903. * @hidden
  33904. * Defines the actions happening during the active mesh stage.
  33905. */
  33906. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33907. /**
  33908. * @hidden
  33909. * Defines the actions happening during the per camera render target step.
  33910. */
  33911. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33912. /**
  33913. * @hidden
  33914. * Defines the actions happening just before the active camera is drawing.
  33915. */
  33916. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33917. /**
  33918. * @hidden
  33919. * Defines the actions happening just before a render target is drawing.
  33920. */
  33921. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33922. /**
  33923. * @hidden
  33924. * Defines the actions happening just before a rendering group is drawing.
  33925. */
  33926. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33927. /**
  33928. * @hidden
  33929. * Defines the actions happening just before a mesh is drawing.
  33930. */
  33931. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33932. /**
  33933. * @hidden
  33934. * Defines the actions happening just after a mesh has been drawn.
  33935. */
  33936. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33937. /**
  33938. * @hidden
  33939. * Defines the actions happening just after a rendering group has been drawn.
  33940. */
  33941. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33942. /**
  33943. * @hidden
  33944. * Defines the actions happening just after the active camera has been drawn.
  33945. */
  33946. _afterCameraDrawStage: Stage<CameraStageAction>;
  33947. /**
  33948. * @hidden
  33949. * Defines the actions happening just after a render target has been drawn.
  33950. */
  33951. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33952. /**
  33953. * @hidden
  33954. * Defines the actions happening just after rendering all cameras and computing intersections.
  33955. */
  33956. _afterRenderStage: Stage<SimpleStageAction>;
  33957. /**
  33958. * @hidden
  33959. * Defines the actions happening when a pointer move event happens.
  33960. */
  33961. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33962. /**
  33963. * @hidden
  33964. * Defines the actions happening when a pointer down event happens.
  33965. */
  33966. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33967. /**
  33968. * @hidden
  33969. * Defines the actions happening when a pointer up event happens.
  33970. */
  33971. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33972. /**
  33973. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33974. */
  33975. private geometriesByUniqueId;
  33976. /**
  33977. * Creates a new Scene
  33978. * @param engine defines the engine to use to render this scene
  33979. * @param options defines the scene options
  33980. */
  33981. constructor(engine: Engine, options?: SceneOptions);
  33982. /**
  33983. * Gets a string idenfifying the name of the class
  33984. * @returns "Scene" string
  33985. */
  33986. getClassName(): string;
  33987. private _defaultMeshCandidates;
  33988. /**
  33989. * @hidden
  33990. */
  33991. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33992. private _defaultSubMeshCandidates;
  33993. /**
  33994. * @hidden
  33995. */
  33996. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33997. /**
  33998. * Sets the default candidate providers for the scene.
  33999. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34000. * and getCollidingSubMeshCandidates to their default function
  34001. */
  34002. setDefaultCandidateProviders(): void;
  34003. /**
  34004. * Gets the mesh that is currently under the pointer
  34005. */
  34006. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34007. /**
  34008. * Gets or sets the current on-screen X position of the pointer
  34009. */
  34010. pointerX: number;
  34011. /**
  34012. * Gets or sets the current on-screen Y position of the pointer
  34013. */
  34014. pointerY: number;
  34015. /**
  34016. * Gets the cached material (ie. the latest rendered one)
  34017. * @returns the cached material
  34018. */
  34019. getCachedMaterial(): Nullable<Material>;
  34020. /**
  34021. * Gets the cached effect (ie. the latest rendered one)
  34022. * @returns the cached effect
  34023. */
  34024. getCachedEffect(): Nullable<Effect>;
  34025. /**
  34026. * Gets the cached visibility state (ie. the latest rendered one)
  34027. * @returns the cached visibility state
  34028. */
  34029. getCachedVisibility(): Nullable<number>;
  34030. /**
  34031. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34032. * @param material defines the current material
  34033. * @param effect defines the current effect
  34034. * @param visibility defines the current visibility state
  34035. * @returns true if one parameter is not cached
  34036. */
  34037. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34038. /**
  34039. * Gets the engine associated with the scene
  34040. * @returns an Engine
  34041. */
  34042. getEngine(): Engine;
  34043. /**
  34044. * Gets the total number of vertices rendered per frame
  34045. * @returns the total number of vertices rendered per frame
  34046. */
  34047. getTotalVertices(): number;
  34048. /**
  34049. * Gets the performance counter for total vertices
  34050. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34051. */
  34052. readonly totalVerticesPerfCounter: PerfCounter;
  34053. /**
  34054. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34055. * @returns the total number of active indices rendered per frame
  34056. */
  34057. getActiveIndices(): number;
  34058. /**
  34059. * Gets the performance counter for active indices
  34060. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34061. */
  34062. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34063. /**
  34064. * Gets the total number of active particles rendered per frame
  34065. * @returns the total number of active particles rendered per frame
  34066. */
  34067. getActiveParticles(): number;
  34068. /**
  34069. * Gets the performance counter for active particles
  34070. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34071. */
  34072. readonly activeParticlesPerfCounter: PerfCounter;
  34073. /**
  34074. * Gets the total number of active bones rendered per frame
  34075. * @returns the total number of active bones rendered per frame
  34076. */
  34077. getActiveBones(): number;
  34078. /**
  34079. * Gets the performance counter for active bones
  34080. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34081. */
  34082. readonly activeBonesPerfCounter: PerfCounter;
  34083. /**
  34084. * Gets the array of active meshes
  34085. * @returns an array of AbstractMesh
  34086. */
  34087. getActiveMeshes(): SmartArray<AbstractMesh>;
  34088. /**
  34089. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34090. * @returns a number
  34091. */
  34092. getAnimationRatio(): number;
  34093. /**
  34094. * Gets an unique Id for the current render phase
  34095. * @returns a number
  34096. */
  34097. getRenderId(): number;
  34098. /**
  34099. * Gets an unique Id for the current frame
  34100. * @returns a number
  34101. */
  34102. getFrameId(): number;
  34103. /** Call this function if you want to manually increment the render Id*/
  34104. incrementRenderId(): void;
  34105. private _createUbo;
  34106. /**
  34107. * Use this method to simulate a pointer move on a mesh
  34108. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34109. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34110. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34111. * @returns the current scene
  34112. */
  34113. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34114. /**
  34115. * Use this method to simulate a pointer down on a mesh
  34116. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34117. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34118. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34119. * @returns the current scene
  34120. */
  34121. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34122. /**
  34123. * Use this method to simulate a pointer up on a mesh
  34124. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34125. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34126. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34127. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34128. * @returns the current scene
  34129. */
  34130. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34131. /**
  34132. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34133. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34134. * @returns true if the pointer was captured
  34135. */
  34136. isPointerCaptured(pointerId?: number): boolean;
  34137. /**
  34138. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34139. * @param attachUp defines if you want to attach events to pointerup
  34140. * @param attachDown defines if you want to attach events to pointerdown
  34141. * @param attachMove defines if you want to attach events to pointermove
  34142. */
  34143. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34144. /** Detaches all event handlers*/
  34145. detachControl(): void;
  34146. /**
  34147. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34148. * Delay loaded resources are not taking in account
  34149. * @return true if all required resources are ready
  34150. */
  34151. isReady(): boolean;
  34152. /** Resets all cached information relative to material (including effect and visibility) */
  34153. resetCachedMaterial(): void;
  34154. /**
  34155. * Registers a function to be called before every frame render
  34156. * @param func defines the function to register
  34157. */
  34158. registerBeforeRender(func: () => void): void;
  34159. /**
  34160. * Unregisters a function called before every frame render
  34161. * @param func defines the function to unregister
  34162. */
  34163. unregisterBeforeRender(func: () => void): void;
  34164. /**
  34165. * Registers a function to be called after every frame render
  34166. * @param func defines the function to register
  34167. */
  34168. registerAfterRender(func: () => void): void;
  34169. /**
  34170. * Unregisters a function called after every frame render
  34171. * @param func defines the function to unregister
  34172. */
  34173. unregisterAfterRender(func: () => void): void;
  34174. private _executeOnceBeforeRender;
  34175. /**
  34176. * The provided function will run before render once and will be disposed afterwards.
  34177. * A timeout delay can be provided so that the function will be executed in N ms.
  34178. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34179. * @param func The function to be executed.
  34180. * @param timeout optional delay in ms
  34181. */
  34182. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34183. /** @hidden */
  34184. _addPendingData(data: any): void;
  34185. /** @hidden */
  34186. _removePendingData(data: any): void;
  34187. /**
  34188. * Returns the number of items waiting to be loaded
  34189. * @returns the number of items waiting to be loaded
  34190. */
  34191. getWaitingItemsCount(): number;
  34192. /**
  34193. * Returns a boolean indicating if the scene is still loading data
  34194. */
  34195. readonly isLoading: boolean;
  34196. /**
  34197. * Registers a function to be executed when the scene is ready
  34198. * @param {Function} func - the function to be executed
  34199. */
  34200. executeWhenReady(func: () => void): void;
  34201. /**
  34202. * Returns a promise that resolves when the scene is ready
  34203. * @returns A promise that resolves when the scene is ready
  34204. */
  34205. whenReadyAsync(): Promise<void>;
  34206. /** @hidden */
  34207. _checkIsReady(): void;
  34208. /**
  34209. * Gets all animatable attached to the scene
  34210. */
  34211. readonly animatables: Animatable[];
  34212. /**
  34213. * Resets the last animation time frame.
  34214. * Useful to override when animations start running when loading a scene for the first time.
  34215. */
  34216. resetLastAnimationTimeFrame(): void;
  34217. /**
  34218. * Gets the current view matrix
  34219. * @returns a Matrix
  34220. */
  34221. getViewMatrix(): Matrix;
  34222. /**
  34223. * Gets the current projection matrix
  34224. * @returns a Matrix
  34225. */
  34226. getProjectionMatrix(): Matrix;
  34227. /**
  34228. * Gets the current transform matrix
  34229. * @returns a Matrix made of View * Projection
  34230. */
  34231. getTransformMatrix(): Matrix;
  34232. /**
  34233. * Sets the current transform matrix
  34234. * @param viewL defines the View matrix to use
  34235. * @param projectionL defines the Projection matrix to use
  34236. * @param viewR defines the right View matrix to use (if provided)
  34237. * @param projectionR defines the right Projection matrix to use (if provided)
  34238. */
  34239. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34240. /**
  34241. * Gets the uniform buffer used to store scene data
  34242. * @returns a UniformBuffer
  34243. */
  34244. getSceneUniformBuffer(): UniformBuffer;
  34245. /**
  34246. * Gets an unique (relatively to the current scene) Id
  34247. * @returns an unique number for the scene
  34248. */
  34249. getUniqueId(): number;
  34250. /**
  34251. * Add a mesh to the list of scene's meshes
  34252. * @param newMesh defines the mesh to add
  34253. * @param recursive if all child meshes should also be added to the scene
  34254. */
  34255. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  34256. /**
  34257. * Remove a mesh for the list of scene's meshes
  34258. * @param toRemove defines the mesh to remove
  34259. * @param recursive if all child meshes should also be removed from the scene
  34260. * @returns the index where the mesh was in the mesh list
  34261. */
  34262. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  34263. /**
  34264. * Add a transform node to the list of scene's transform nodes
  34265. * @param newTransformNode defines the transform node to add
  34266. */
  34267. addTransformNode(newTransformNode: TransformNode): void;
  34268. /**
  34269. * Remove a transform node for the list of scene's transform nodes
  34270. * @param toRemove defines the transform node to remove
  34271. * @returns the index where the transform node was in the transform node list
  34272. */
  34273. removeTransformNode(toRemove: TransformNode): number;
  34274. /**
  34275. * Remove a skeleton for the list of scene's skeletons
  34276. * @param toRemove defines the skeleton to remove
  34277. * @returns the index where the skeleton was in the skeleton list
  34278. */
  34279. removeSkeleton(toRemove: Skeleton): number;
  34280. /**
  34281. * Remove a morph target for the list of scene's morph targets
  34282. * @param toRemove defines the morph target to remove
  34283. * @returns the index where the morph target was in the morph target list
  34284. */
  34285. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  34286. /**
  34287. * Remove a light for the list of scene's lights
  34288. * @param toRemove defines the light to remove
  34289. * @returns the index where the light was in the light list
  34290. */
  34291. removeLight(toRemove: Light): number;
  34292. /**
  34293. * Remove a camera for the list of scene's cameras
  34294. * @param toRemove defines the camera to remove
  34295. * @returns the index where the camera was in the camera list
  34296. */
  34297. removeCamera(toRemove: Camera): number;
  34298. /**
  34299. * Remove a particle system for the list of scene's particle systems
  34300. * @param toRemove defines the particle system to remove
  34301. * @returns the index where the particle system was in the particle system list
  34302. */
  34303. removeParticleSystem(toRemove: IParticleSystem): number;
  34304. /**
  34305. * Remove a animation for the list of scene's animations
  34306. * @param toRemove defines the animation to remove
  34307. * @returns the index where the animation was in the animation list
  34308. */
  34309. removeAnimation(toRemove: Animation): number;
  34310. /**
  34311. * Will stop the animation of the given target
  34312. * @param target - the target
  34313. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  34314. * @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)
  34315. */
  34316. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  34317. /**
  34318. * Removes the given animation group from this scene.
  34319. * @param toRemove The animation group to remove
  34320. * @returns The index of the removed animation group
  34321. */
  34322. removeAnimationGroup(toRemove: AnimationGroup): number;
  34323. /**
  34324. * Removes the given multi-material from this scene.
  34325. * @param toRemove The multi-material to remove
  34326. * @returns The index of the removed multi-material
  34327. */
  34328. removeMultiMaterial(toRemove: MultiMaterial): number;
  34329. /**
  34330. * Removes the given material from this scene.
  34331. * @param toRemove The material to remove
  34332. * @returns The index of the removed material
  34333. */
  34334. removeMaterial(toRemove: Material): number;
  34335. /**
  34336. * Removes the given action manager from this scene.
  34337. * @param toRemove The action manager to remove
  34338. * @returns The index of the removed action manager
  34339. */
  34340. removeActionManager(toRemove: AbstractActionManager): number;
  34341. /**
  34342. * Removes the given texture from this scene.
  34343. * @param toRemove The texture to remove
  34344. * @returns The index of the removed texture
  34345. */
  34346. removeTexture(toRemove: BaseTexture): number;
  34347. /**
  34348. * Adds the given light to this scene
  34349. * @param newLight The light to add
  34350. */
  34351. addLight(newLight: Light): void;
  34352. /**
  34353. * Sorts the list list based on light priorities
  34354. */
  34355. sortLightsByPriority(): void;
  34356. /**
  34357. * Adds the given camera to this scene
  34358. * @param newCamera The camera to add
  34359. */
  34360. addCamera(newCamera: Camera): void;
  34361. /**
  34362. * Adds the given skeleton to this scene
  34363. * @param newSkeleton The skeleton to add
  34364. */
  34365. addSkeleton(newSkeleton: Skeleton): void;
  34366. /**
  34367. * Adds the given particle system to this scene
  34368. * @param newParticleSystem The particle system to add
  34369. */
  34370. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34371. /**
  34372. * Adds the given animation to this scene
  34373. * @param newAnimation The animation to add
  34374. */
  34375. addAnimation(newAnimation: Animation): void;
  34376. /**
  34377. * Adds the given animation group to this scene.
  34378. * @param newAnimationGroup The animation group to add
  34379. */
  34380. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34381. /**
  34382. * Adds the given multi-material to this scene
  34383. * @param newMultiMaterial The multi-material to add
  34384. */
  34385. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34386. /**
  34387. * Adds the given material to this scene
  34388. * @param newMaterial The material to add
  34389. */
  34390. addMaterial(newMaterial: Material): void;
  34391. /**
  34392. * Adds the given morph target to this scene
  34393. * @param newMorphTargetManager The morph target to add
  34394. */
  34395. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34396. /**
  34397. * Adds the given geometry to this scene
  34398. * @param newGeometry The geometry to add
  34399. */
  34400. addGeometry(newGeometry: Geometry): void;
  34401. /**
  34402. * Adds the given action manager to this scene
  34403. * @param newActionManager The action manager to add
  34404. */
  34405. addActionManager(newActionManager: AbstractActionManager): void;
  34406. /**
  34407. * Adds the given texture to this scene.
  34408. * @param newTexture The texture to add
  34409. */
  34410. addTexture(newTexture: BaseTexture): void;
  34411. /**
  34412. * Switch active camera
  34413. * @param newCamera defines the new active camera
  34414. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34415. */
  34416. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34417. /**
  34418. * sets the active camera of the scene using its ID
  34419. * @param id defines the camera's ID
  34420. * @return the new active camera or null if none found.
  34421. */
  34422. setActiveCameraByID(id: string): Nullable<Camera>;
  34423. /**
  34424. * sets the active camera of the scene using its name
  34425. * @param name defines the camera's name
  34426. * @returns the new active camera or null if none found.
  34427. */
  34428. setActiveCameraByName(name: string): Nullable<Camera>;
  34429. /**
  34430. * get an animation group using its name
  34431. * @param name defines the material's name
  34432. * @return the animation group or null if none found.
  34433. */
  34434. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34435. /**
  34436. * Get a material using its unique id
  34437. * @param uniqueId defines the material's unique id
  34438. * @return the material or null if none found.
  34439. */
  34440. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34441. /**
  34442. * get a material using its id
  34443. * @param id defines the material's ID
  34444. * @return the material or null if none found.
  34445. */
  34446. getMaterialByID(id: string): Nullable<Material>;
  34447. /**
  34448. * Gets a the last added material using a given id
  34449. * @param id defines the material's ID
  34450. * @return the last material with the given id or null if none found.
  34451. */
  34452. getLastMaterialByID(id: string): Nullable<Material>;
  34453. /**
  34454. * Gets a material using its name
  34455. * @param name defines the material's name
  34456. * @return the material or null if none found.
  34457. */
  34458. getMaterialByName(name: string): Nullable<Material>;
  34459. /**
  34460. * Gets a camera using its id
  34461. * @param id defines the id to look for
  34462. * @returns the camera or null if not found
  34463. */
  34464. getCameraByID(id: string): Nullable<Camera>;
  34465. /**
  34466. * Gets a camera using its unique id
  34467. * @param uniqueId defines the unique id to look for
  34468. * @returns the camera or null if not found
  34469. */
  34470. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34471. /**
  34472. * Gets a camera using its name
  34473. * @param name defines the camera's name
  34474. * @return the camera or null if none found.
  34475. */
  34476. getCameraByName(name: string): Nullable<Camera>;
  34477. /**
  34478. * Gets a bone using its id
  34479. * @param id defines the bone's id
  34480. * @return the bone or null if not found
  34481. */
  34482. getBoneByID(id: string): Nullable<Bone>;
  34483. /**
  34484. * Gets a bone using its id
  34485. * @param name defines the bone's name
  34486. * @return the bone or null if not found
  34487. */
  34488. getBoneByName(name: string): Nullable<Bone>;
  34489. /**
  34490. * Gets a light node using its name
  34491. * @param name defines the the light's name
  34492. * @return the light or null if none found.
  34493. */
  34494. getLightByName(name: string): Nullable<Light>;
  34495. /**
  34496. * Gets a light node using its id
  34497. * @param id defines the light's id
  34498. * @return the light or null if none found.
  34499. */
  34500. getLightByID(id: string): Nullable<Light>;
  34501. /**
  34502. * Gets a light node using its scene-generated unique ID
  34503. * @param uniqueId defines the light's unique id
  34504. * @return the light or null if none found.
  34505. */
  34506. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34507. /**
  34508. * Gets a particle system by id
  34509. * @param id defines the particle system id
  34510. * @return the corresponding system or null if none found
  34511. */
  34512. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34513. /**
  34514. * Gets a geometry using its ID
  34515. * @param id defines the geometry's id
  34516. * @return the geometry or null if none found.
  34517. */
  34518. getGeometryByID(id: string): Nullable<Geometry>;
  34519. private _getGeometryByUniqueID;
  34520. /**
  34521. * Add a new geometry to this scene
  34522. * @param geometry defines the geometry to be added to the scene.
  34523. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34524. * @return a boolean defining if the geometry was added or not
  34525. */
  34526. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34527. /**
  34528. * Removes an existing geometry
  34529. * @param geometry defines the geometry to be removed from the scene
  34530. * @return a boolean defining if the geometry was removed or not
  34531. */
  34532. removeGeometry(geometry: Geometry): boolean;
  34533. /**
  34534. * Gets the list of geometries attached to the scene
  34535. * @returns an array of Geometry
  34536. */
  34537. getGeometries(): Geometry[];
  34538. /**
  34539. * Gets the first added mesh found of a given ID
  34540. * @param id defines the id to search for
  34541. * @return the mesh found or null if not found at all
  34542. */
  34543. getMeshByID(id: string): Nullable<AbstractMesh>;
  34544. /**
  34545. * Gets a list of meshes using their id
  34546. * @param id defines the id to search for
  34547. * @returns a list of meshes
  34548. */
  34549. getMeshesByID(id: string): Array<AbstractMesh>;
  34550. /**
  34551. * Gets the first added transform node found of a given ID
  34552. * @param id defines the id to search for
  34553. * @return the found transform node or null if not found at all.
  34554. */
  34555. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34556. /**
  34557. * Gets a transform node with its auto-generated unique id
  34558. * @param uniqueId efines the unique id to search for
  34559. * @return the found transform node or null if not found at all.
  34560. */
  34561. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34562. /**
  34563. * Gets a list of transform nodes using their id
  34564. * @param id defines the id to search for
  34565. * @returns a list of transform nodes
  34566. */
  34567. getTransformNodesByID(id: string): Array<TransformNode>;
  34568. /**
  34569. * Gets a mesh with its auto-generated unique id
  34570. * @param uniqueId defines the unique id to search for
  34571. * @return the found mesh or null if not found at all.
  34572. */
  34573. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34574. /**
  34575. * Gets a the last added mesh using a given id
  34576. * @param id defines the id to search for
  34577. * @return the found mesh or null if not found at all.
  34578. */
  34579. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34580. /**
  34581. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34582. * @param id defines the id to search for
  34583. * @return the found node or null if not found at all
  34584. */
  34585. getLastEntryByID(id: string): Nullable<Node>;
  34586. /**
  34587. * Gets a node (Mesh, Camera, Light) using a given id
  34588. * @param id defines the id to search for
  34589. * @return the found node or null if not found at all
  34590. */
  34591. getNodeByID(id: string): Nullable<Node>;
  34592. /**
  34593. * Gets a node (Mesh, Camera, Light) using a given name
  34594. * @param name defines the name to search for
  34595. * @return the found node or null if not found at all.
  34596. */
  34597. getNodeByName(name: string): Nullable<Node>;
  34598. /**
  34599. * Gets a mesh using a given name
  34600. * @param name defines the name to search for
  34601. * @return the found mesh or null if not found at all.
  34602. */
  34603. getMeshByName(name: string): Nullable<AbstractMesh>;
  34604. /**
  34605. * Gets a transform node using a given name
  34606. * @param name defines the name to search for
  34607. * @return the found transform node or null if not found at all.
  34608. */
  34609. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34610. /**
  34611. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34612. * @param id defines the id to search for
  34613. * @return the found skeleton or null if not found at all.
  34614. */
  34615. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34616. /**
  34617. * Gets a skeleton using a given auto generated unique id
  34618. * @param uniqueId defines the unique id to search for
  34619. * @return the found skeleton or null if not found at all.
  34620. */
  34621. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34622. /**
  34623. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34624. * @param id defines the id to search for
  34625. * @return the found skeleton or null if not found at all.
  34626. */
  34627. getSkeletonById(id: string): Nullable<Skeleton>;
  34628. /**
  34629. * Gets a skeleton using a given name
  34630. * @param name defines the name to search for
  34631. * @return the found skeleton or null if not found at all.
  34632. */
  34633. getSkeletonByName(name: string): Nullable<Skeleton>;
  34634. /**
  34635. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34636. * @param id defines the id to search for
  34637. * @return the found morph target manager or null if not found at all.
  34638. */
  34639. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34640. /**
  34641. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34642. * @param id defines the id to search for
  34643. * @return the found morph target or null if not found at all.
  34644. */
  34645. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34646. /**
  34647. * Gets a boolean indicating if the given mesh is active
  34648. * @param mesh defines the mesh to look for
  34649. * @returns true if the mesh is in the active list
  34650. */
  34651. isActiveMesh(mesh: AbstractMesh): boolean;
  34652. /**
  34653. * Return a unique id as a string which can serve as an identifier for the scene
  34654. */
  34655. readonly uid: string;
  34656. /**
  34657. * Add an externaly attached data from its key.
  34658. * This method call will fail and return false, if such key already exists.
  34659. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34660. * @param key the unique key that identifies the data
  34661. * @param data the data object to associate to the key for this Engine instance
  34662. * @return true if no such key were already present and the data was added successfully, false otherwise
  34663. */
  34664. addExternalData<T>(key: string, data: T): boolean;
  34665. /**
  34666. * Get an externaly attached data from its key
  34667. * @param key the unique key that identifies the data
  34668. * @return the associated data, if present (can be null), or undefined if not present
  34669. */
  34670. getExternalData<T>(key: string): Nullable<T>;
  34671. /**
  34672. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34673. * @param key the unique key that identifies the data
  34674. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34675. * @return the associated data, can be null if the factory returned null.
  34676. */
  34677. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34678. /**
  34679. * Remove an externaly attached data from the Engine instance
  34680. * @param key the unique key that identifies the data
  34681. * @return true if the data was successfully removed, false if it doesn't exist
  34682. */
  34683. removeExternalData(key: string): boolean;
  34684. private _evaluateSubMesh;
  34685. /**
  34686. * Clear the processed materials smart array preventing retention point in material dispose.
  34687. */
  34688. freeProcessedMaterials(): void;
  34689. private _preventFreeActiveMeshesAndRenderingGroups;
  34690. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34691. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34692. * when disposing several meshes in a row or a hierarchy of meshes.
  34693. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34694. */
  34695. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34696. /**
  34697. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34698. */
  34699. freeActiveMeshes(): void;
  34700. /**
  34701. * Clear the info related to rendering groups preventing retention points during dispose.
  34702. */
  34703. freeRenderingGroups(): void;
  34704. /** @hidden */
  34705. _isInIntermediateRendering(): boolean;
  34706. /**
  34707. * Lambda returning the list of potentially active meshes.
  34708. */
  34709. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34710. /**
  34711. * Lambda returning the list of potentially active sub meshes.
  34712. */
  34713. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34714. /**
  34715. * Lambda returning the list of potentially intersecting sub meshes.
  34716. */
  34717. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34718. /**
  34719. * Lambda returning the list of potentially colliding sub meshes.
  34720. */
  34721. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34722. private _activeMeshesFrozen;
  34723. /**
  34724. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34725. * @returns the current scene
  34726. */
  34727. freezeActiveMeshes(): Scene;
  34728. /**
  34729. * Use this function to restart evaluating active meshes on every frame
  34730. * @returns the current scene
  34731. */
  34732. unfreezeActiveMeshes(): Scene;
  34733. private _evaluateActiveMeshes;
  34734. private _activeMesh;
  34735. /**
  34736. * Update the transform matrix to update from the current active camera
  34737. * @param force defines a boolean used to force the update even if cache is up to date
  34738. */
  34739. updateTransformMatrix(force?: boolean): void;
  34740. private _bindFrameBuffer;
  34741. /** @hidden */
  34742. _allowPostProcessClearColor: boolean;
  34743. /** @hidden */
  34744. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34745. private _processSubCameras;
  34746. private _checkIntersections;
  34747. /** @hidden */
  34748. _advancePhysicsEngineStep(step: number): void;
  34749. /**
  34750. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34751. */
  34752. getDeterministicFrameTime: () => number;
  34753. /** @hidden */
  34754. _animate(): void;
  34755. /** Execute all animations (for a frame) */
  34756. animate(): void;
  34757. /**
  34758. * Render the scene
  34759. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34760. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34761. */
  34762. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34763. /**
  34764. * Freeze all materials
  34765. * A frozen material will not be updatable but should be faster to render
  34766. */
  34767. freezeMaterials(): void;
  34768. /**
  34769. * Unfreeze all materials
  34770. * A frozen material will not be updatable but should be faster to render
  34771. */
  34772. unfreezeMaterials(): void;
  34773. /**
  34774. * Releases all held ressources
  34775. */
  34776. dispose(): void;
  34777. /**
  34778. * Gets if the scene is already disposed
  34779. */
  34780. readonly isDisposed: boolean;
  34781. /**
  34782. * Call this function to reduce memory footprint of the scene.
  34783. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34784. */
  34785. clearCachedVertexData(): void;
  34786. /**
  34787. * This function will remove the local cached buffer data from texture.
  34788. * It will save memory but will prevent the texture from being rebuilt
  34789. */
  34790. cleanCachedTextureBuffer(): void;
  34791. /**
  34792. * Get the world extend vectors with an optional filter
  34793. *
  34794. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34795. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34796. */
  34797. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34798. min: Vector3;
  34799. max: Vector3;
  34800. };
  34801. /**
  34802. * Creates a ray that can be used to pick in the scene
  34803. * @param x defines the x coordinate of the origin (on-screen)
  34804. * @param y defines the y coordinate of the origin (on-screen)
  34805. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34806. * @param camera defines the camera to use for the picking
  34807. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34808. * @returns a Ray
  34809. */
  34810. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34811. /**
  34812. * Creates a ray that can be used to pick in the scene
  34813. * @param x defines the x coordinate of the origin (on-screen)
  34814. * @param y defines the y coordinate of the origin (on-screen)
  34815. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34816. * @param result defines the ray where to store the picking ray
  34817. * @param camera defines the camera to use for the picking
  34818. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34819. * @returns the current scene
  34820. */
  34821. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34822. /**
  34823. * Creates a ray that can be used to pick in the scene
  34824. * @param x defines the x coordinate of the origin (on-screen)
  34825. * @param y defines the y coordinate of the origin (on-screen)
  34826. * @param camera defines the camera to use for the picking
  34827. * @returns a Ray
  34828. */
  34829. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34830. /**
  34831. * Creates a ray that can be used to pick in the scene
  34832. * @param x defines the x coordinate of the origin (on-screen)
  34833. * @param y defines the y coordinate of the origin (on-screen)
  34834. * @param result defines the ray where to store the picking ray
  34835. * @param camera defines the camera to use for the picking
  34836. * @returns the current scene
  34837. */
  34838. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34839. /** Launch a ray to try to pick a mesh in the scene
  34840. * @param x position on screen
  34841. * @param y position on screen
  34842. * @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
  34843. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34844. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34845. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34846. * @returns a PickingInfo
  34847. */
  34848. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34849. /** Use the given ray to pick a mesh in the scene
  34850. * @param ray The ray to use to pick meshes
  34851. * @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
  34852. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34853. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34854. * @returns a PickingInfo
  34855. */
  34856. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34857. /**
  34858. * Launch a ray to try to pick a mesh in the scene
  34859. * @param x X position on screen
  34860. * @param y Y position on screen
  34861. * @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
  34862. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34863. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34864. * @returns an array of PickingInfo
  34865. */
  34866. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34867. /**
  34868. * Launch a ray to try to pick a mesh in the scene
  34869. * @param ray Ray to use
  34870. * @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
  34871. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34872. * @returns an array of PickingInfo
  34873. */
  34874. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34875. /**
  34876. * Force the value of meshUnderPointer
  34877. * @param mesh defines the mesh to use
  34878. */
  34879. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34880. /**
  34881. * Gets the mesh under the pointer
  34882. * @returns a Mesh or null if no mesh is under the pointer
  34883. */
  34884. getPointerOverMesh(): Nullable<AbstractMesh>;
  34885. /** @hidden */
  34886. _rebuildGeometries(): void;
  34887. /** @hidden */
  34888. _rebuildTextures(): void;
  34889. private _getByTags;
  34890. /**
  34891. * Get a list of meshes by tags
  34892. * @param tagsQuery defines the tags query to use
  34893. * @param forEach defines a predicate used to filter results
  34894. * @returns an array of Mesh
  34895. */
  34896. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34897. /**
  34898. * Get a list of cameras by tags
  34899. * @param tagsQuery defines the tags query to use
  34900. * @param forEach defines a predicate used to filter results
  34901. * @returns an array of Camera
  34902. */
  34903. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34904. /**
  34905. * Get a list of lights by tags
  34906. * @param tagsQuery defines the tags query to use
  34907. * @param forEach defines a predicate used to filter results
  34908. * @returns an array of Light
  34909. */
  34910. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34911. /**
  34912. * Get a list of materials by tags
  34913. * @param tagsQuery defines the tags query to use
  34914. * @param forEach defines a predicate used to filter results
  34915. * @returns an array of Material
  34916. */
  34917. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34918. /**
  34919. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34920. * This allowed control for front to back rendering or reversly depending of the special needs.
  34921. *
  34922. * @param renderingGroupId The rendering group id corresponding to its index
  34923. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34924. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34925. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34926. */
  34927. 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;
  34928. /**
  34929. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34930. *
  34931. * @param renderingGroupId The rendering group id corresponding to its index
  34932. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34933. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34934. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34935. */
  34936. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34937. /**
  34938. * Gets the current auto clear configuration for one rendering group of the rendering
  34939. * manager.
  34940. * @param index the rendering group index to get the information for
  34941. * @returns The auto clear setup for the requested rendering group
  34942. */
  34943. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34944. private _blockMaterialDirtyMechanism;
  34945. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34946. blockMaterialDirtyMechanism: boolean;
  34947. /**
  34948. * Will flag all materials as dirty to trigger new shader compilation
  34949. * @param flag defines the flag used to specify which material part must be marked as dirty
  34950. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34951. */
  34952. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34953. /** @hidden */
  34954. _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;
  34955. /** @hidden */
  34956. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34957. }
  34958. }
  34959. declare module "babylonjs/assetContainer" {
  34960. import { AbstractScene } from "babylonjs/abstractScene";
  34961. import { Scene } from "babylonjs/scene";
  34962. import { Mesh } from "babylonjs/Meshes/mesh";
  34963. /**
  34964. * Set of assets to keep when moving a scene into an asset container.
  34965. */
  34966. export class KeepAssets extends AbstractScene {
  34967. }
  34968. /**
  34969. * Container with a set of assets that can be added or removed from a scene.
  34970. */
  34971. export class AssetContainer extends AbstractScene {
  34972. /**
  34973. * The scene the AssetContainer belongs to.
  34974. */
  34975. scene: Scene;
  34976. /**
  34977. * Instantiates an AssetContainer.
  34978. * @param scene The scene the AssetContainer belongs to.
  34979. */
  34980. constructor(scene: Scene);
  34981. /**
  34982. * Adds all the assets from the container to the scene.
  34983. */
  34984. addAllToScene(): void;
  34985. /**
  34986. * Removes all the assets in the container from the scene
  34987. */
  34988. removeAllFromScene(): void;
  34989. /**
  34990. * Disposes all the assets in the container
  34991. */
  34992. dispose(): void;
  34993. private _moveAssets;
  34994. /**
  34995. * Removes all the assets contained in the scene and adds them to the container.
  34996. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34997. */
  34998. moveAllFromScene(keepAssets?: KeepAssets): void;
  34999. /**
  35000. * 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.
  35001. * @returns the root mesh
  35002. */
  35003. createRootMesh(): Mesh;
  35004. }
  35005. }
  35006. declare module "babylonjs/abstractScene" {
  35007. import { Scene } from "babylonjs/scene";
  35008. import { Nullable } from "babylonjs/types";
  35009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35010. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35011. import { Geometry } from "babylonjs/Meshes/geometry";
  35012. import { Skeleton } from "babylonjs/Bones/skeleton";
  35013. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35014. import { AssetContainer } from "babylonjs/assetContainer";
  35015. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35016. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35017. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35018. import { Material } from "babylonjs/Materials/material";
  35019. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35020. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35021. import { Camera } from "babylonjs/Cameras/camera";
  35022. import { Light } from "babylonjs/Lights/light";
  35023. import { Node } from "babylonjs/node";
  35024. import { Animation } from "babylonjs/Animations/animation";
  35025. /**
  35026. * Defines how the parser contract is defined.
  35027. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35028. */
  35029. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35030. /**
  35031. * Defines how the individual parser contract is defined.
  35032. * These parser can parse an individual asset
  35033. */
  35034. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35035. /**
  35036. * Base class of the scene acting as a container for the different elements composing a scene.
  35037. * This class is dynamically extended by the different components of the scene increasing
  35038. * flexibility and reducing coupling
  35039. */
  35040. export abstract class AbstractScene {
  35041. /**
  35042. * Stores the list of available parsers in the application.
  35043. */
  35044. private static _BabylonFileParsers;
  35045. /**
  35046. * Stores the list of available individual parsers in the application.
  35047. */
  35048. private static _IndividualBabylonFileParsers;
  35049. /**
  35050. * Adds a parser in the list of available ones
  35051. * @param name Defines the name of the parser
  35052. * @param parser Defines the parser to add
  35053. */
  35054. static AddParser(name: string, parser: BabylonFileParser): void;
  35055. /**
  35056. * Gets a general parser from the list of avaialble ones
  35057. * @param name Defines the name of the parser
  35058. * @returns the requested parser or null
  35059. */
  35060. static GetParser(name: string): Nullable<BabylonFileParser>;
  35061. /**
  35062. * Adds n individual parser in the list of available ones
  35063. * @param name Defines the name of the parser
  35064. * @param parser Defines the parser to add
  35065. */
  35066. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35067. /**
  35068. * Gets an individual parser from the list of avaialble ones
  35069. * @param name Defines the name of the parser
  35070. * @returns the requested parser or null
  35071. */
  35072. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35073. /**
  35074. * Parser json data and populate both a scene and its associated container object
  35075. * @param jsonData Defines the data to parse
  35076. * @param scene Defines the scene to parse the data for
  35077. * @param container Defines the container attached to the parsing sequence
  35078. * @param rootUrl Defines the root url of the data
  35079. */
  35080. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35081. /**
  35082. * Gets the list of root nodes (ie. nodes with no parent)
  35083. */
  35084. rootNodes: Node[];
  35085. /** All of the cameras added to this scene
  35086. * @see http://doc.babylonjs.com/babylon101/cameras
  35087. */
  35088. cameras: Camera[];
  35089. /**
  35090. * All of the lights added to this scene
  35091. * @see http://doc.babylonjs.com/babylon101/lights
  35092. */
  35093. lights: Light[];
  35094. /**
  35095. * All of the (abstract) meshes added to this scene
  35096. */
  35097. meshes: AbstractMesh[];
  35098. /**
  35099. * The list of skeletons added to the scene
  35100. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35101. */
  35102. skeletons: Skeleton[];
  35103. /**
  35104. * All of the particle systems added to this scene
  35105. * @see http://doc.babylonjs.com/babylon101/particles
  35106. */
  35107. particleSystems: IParticleSystem[];
  35108. /**
  35109. * Gets a list of Animations associated with the scene
  35110. */
  35111. animations: Animation[];
  35112. /**
  35113. * All of the animation groups added to this scene
  35114. * @see http://doc.babylonjs.com/how_to/group
  35115. */
  35116. animationGroups: AnimationGroup[];
  35117. /**
  35118. * All of the multi-materials added to this scene
  35119. * @see http://doc.babylonjs.com/how_to/multi_materials
  35120. */
  35121. multiMaterials: MultiMaterial[];
  35122. /**
  35123. * All of the materials added to this scene
  35124. * In the context of a Scene, it is not supposed to be modified manually.
  35125. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35126. * Note also that the order of the Material wihin the array is not significant and might change.
  35127. * @see http://doc.babylonjs.com/babylon101/materials
  35128. */
  35129. materials: Material[];
  35130. /**
  35131. * The list of morph target managers added to the scene
  35132. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35133. */
  35134. morphTargetManagers: MorphTargetManager[];
  35135. /**
  35136. * The list of geometries used in the scene.
  35137. */
  35138. geometries: Geometry[];
  35139. /**
  35140. * All of the tranform nodes added to this scene
  35141. * In the context of a Scene, it is not supposed to be modified manually.
  35142. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35143. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35144. * @see http://doc.babylonjs.com/how_to/transformnode
  35145. */
  35146. transformNodes: TransformNode[];
  35147. /**
  35148. * ActionManagers available on the scene.
  35149. */
  35150. actionManagers: AbstractActionManager[];
  35151. /**
  35152. * Textures to keep.
  35153. */
  35154. textures: BaseTexture[];
  35155. /**
  35156. * Environment texture for the scene
  35157. */
  35158. environmentTexture: Nullable<BaseTexture>;
  35159. }
  35160. }
  35161. declare module "babylonjs/Audio/sound" {
  35162. import { Observable } from "babylonjs/Misc/observable";
  35163. import { Vector3 } from "babylonjs/Maths/math";
  35164. import { Nullable } from "babylonjs/types";
  35165. import { Scene } from "babylonjs/scene";
  35166. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35167. /**
  35168. * Interface used to define options for Sound class
  35169. */
  35170. export interface ISoundOptions {
  35171. /**
  35172. * Does the sound autoplay once loaded.
  35173. */
  35174. autoplay?: boolean;
  35175. /**
  35176. * Does the sound loop after it finishes playing once.
  35177. */
  35178. loop?: boolean;
  35179. /**
  35180. * Sound's volume
  35181. */
  35182. volume?: number;
  35183. /**
  35184. * Is it a spatial sound?
  35185. */
  35186. spatialSound?: boolean;
  35187. /**
  35188. * Maximum distance to hear that sound
  35189. */
  35190. maxDistance?: number;
  35191. /**
  35192. * Uses user defined attenuation function
  35193. */
  35194. useCustomAttenuation?: boolean;
  35195. /**
  35196. * Define the roll off factor of spatial sounds.
  35197. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35198. */
  35199. rolloffFactor?: number;
  35200. /**
  35201. * Define the reference distance the sound should be heard perfectly.
  35202. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35203. */
  35204. refDistance?: number;
  35205. /**
  35206. * Define the distance attenuation model the sound will follow.
  35207. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35208. */
  35209. distanceModel?: string;
  35210. /**
  35211. * Defines the playback speed (1 by default)
  35212. */
  35213. playbackRate?: number;
  35214. /**
  35215. * Defines if the sound is from a streaming source
  35216. */
  35217. streaming?: boolean;
  35218. /**
  35219. * Defines an optional length (in seconds) inside the sound file
  35220. */
  35221. length?: number;
  35222. /**
  35223. * Defines an optional offset (in seconds) inside the sound file
  35224. */
  35225. offset?: number;
  35226. /**
  35227. * If true, URLs will not be required to state the audio file codec to use.
  35228. */
  35229. skipCodecCheck?: boolean;
  35230. }
  35231. /**
  35232. * Defines a sound that can be played in the application.
  35233. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35234. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35235. */
  35236. export class Sound {
  35237. /**
  35238. * The name of the sound in the scene.
  35239. */
  35240. name: string;
  35241. /**
  35242. * Does the sound autoplay once loaded.
  35243. */
  35244. autoplay: boolean;
  35245. /**
  35246. * Does the sound loop after it finishes playing once.
  35247. */
  35248. loop: boolean;
  35249. /**
  35250. * Does the sound use a custom attenuation curve to simulate the falloff
  35251. * happening when the source gets further away from the camera.
  35252. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35253. */
  35254. useCustomAttenuation: boolean;
  35255. /**
  35256. * The sound track id this sound belongs to.
  35257. */
  35258. soundTrackId: number;
  35259. /**
  35260. * Is this sound currently played.
  35261. */
  35262. isPlaying: boolean;
  35263. /**
  35264. * Is this sound currently paused.
  35265. */
  35266. isPaused: boolean;
  35267. /**
  35268. * Does this sound enables spatial sound.
  35269. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35270. */
  35271. spatialSound: boolean;
  35272. /**
  35273. * Define the reference distance the sound should be heard perfectly.
  35274. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35275. */
  35276. refDistance: number;
  35277. /**
  35278. * Define the roll off factor of spatial sounds.
  35279. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35280. */
  35281. rolloffFactor: number;
  35282. /**
  35283. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  35284. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35285. */
  35286. maxDistance: number;
  35287. /**
  35288. * Define the distance attenuation model the sound will follow.
  35289. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35290. */
  35291. distanceModel: string;
  35292. /**
  35293. * @hidden
  35294. * Back Compat
  35295. **/
  35296. onended: () => any;
  35297. /**
  35298. * Observable event when the current playing sound finishes.
  35299. */
  35300. onEndedObservable: Observable<Sound>;
  35301. private _panningModel;
  35302. private _playbackRate;
  35303. private _streaming;
  35304. private _startTime;
  35305. private _startOffset;
  35306. private _position;
  35307. /** @hidden */
  35308. _positionInEmitterSpace: boolean;
  35309. private _localDirection;
  35310. private _volume;
  35311. private _isReadyToPlay;
  35312. private _isDirectional;
  35313. private _readyToPlayCallback;
  35314. private _audioBuffer;
  35315. private _soundSource;
  35316. private _streamingSource;
  35317. private _soundPanner;
  35318. private _soundGain;
  35319. private _inputAudioNode;
  35320. private _outputAudioNode;
  35321. private _coneInnerAngle;
  35322. private _coneOuterAngle;
  35323. private _coneOuterGain;
  35324. private _scene;
  35325. private _connectedTransformNode;
  35326. private _customAttenuationFunction;
  35327. private _registerFunc;
  35328. private _isOutputConnected;
  35329. private _htmlAudioElement;
  35330. private _urlType;
  35331. private _length?;
  35332. private _offset?;
  35333. /** @hidden */
  35334. static _SceneComponentInitialization: (scene: Scene) => void;
  35335. /**
  35336. * Create a sound and attach it to a scene
  35337. * @param name Name of your sound
  35338. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  35339. * @param scene defines the scene the sound belongs to
  35340. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  35341. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  35342. */
  35343. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  35344. /**
  35345. * Release the sound and its associated resources
  35346. */
  35347. dispose(): void;
  35348. /**
  35349. * Gets if the sounds is ready to be played or not.
  35350. * @returns true if ready, otherwise false
  35351. */
  35352. isReady(): boolean;
  35353. private _soundLoaded;
  35354. /**
  35355. * Sets the data of the sound from an audiobuffer
  35356. * @param audioBuffer The audioBuffer containing the data
  35357. */
  35358. setAudioBuffer(audioBuffer: AudioBuffer): void;
  35359. /**
  35360. * Updates the current sounds options such as maxdistance, loop...
  35361. * @param options A JSON object containing values named as the object properties
  35362. */
  35363. updateOptions(options: ISoundOptions): void;
  35364. private _createSpatialParameters;
  35365. private _updateSpatialParameters;
  35366. /**
  35367. * Switch the panning model to HRTF:
  35368. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35369. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35370. */
  35371. switchPanningModelToHRTF(): void;
  35372. /**
  35373. * Switch the panning model to Equal Power:
  35374. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35375. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35376. */
  35377. switchPanningModelToEqualPower(): void;
  35378. private _switchPanningModel;
  35379. /**
  35380. * Connect this sound to a sound track audio node like gain...
  35381. * @param soundTrackAudioNode the sound track audio node to connect to
  35382. */
  35383. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  35384. /**
  35385. * Transform this sound into a directional source
  35386. * @param coneInnerAngle Size of the inner cone in degree
  35387. * @param coneOuterAngle Size of the outer cone in degree
  35388. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  35389. */
  35390. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  35391. /**
  35392. * Gets or sets the inner angle for the directional cone.
  35393. */
  35394. /**
  35395. * Gets or sets the inner angle for the directional cone.
  35396. */
  35397. directionalConeInnerAngle: number;
  35398. /**
  35399. * Gets or sets the outer angle for the directional cone.
  35400. */
  35401. /**
  35402. * Gets or sets the outer angle for the directional cone.
  35403. */
  35404. directionalConeOuterAngle: number;
  35405. /**
  35406. * Sets the position of the emitter if spatial sound is enabled
  35407. * @param newPosition Defines the new posisiton
  35408. */
  35409. setPosition(newPosition: Vector3): void;
  35410. /**
  35411. * Sets the local direction of the emitter if spatial sound is enabled
  35412. * @param newLocalDirection Defines the new local direction
  35413. */
  35414. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35415. private _updateDirection;
  35416. /** @hidden */
  35417. updateDistanceFromListener(): void;
  35418. /**
  35419. * Sets a new custom attenuation function for the sound.
  35420. * @param callback Defines the function used for the attenuation
  35421. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35422. */
  35423. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35424. /**
  35425. * Play the sound
  35426. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35427. * @param offset (optional) Start the sound at a specific time in seconds
  35428. * @param length (optional) Sound duration (in seconds)
  35429. */
  35430. play(time?: number, offset?: number, length?: number): void;
  35431. private _onended;
  35432. /**
  35433. * Stop the sound
  35434. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35435. */
  35436. stop(time?: number): void;
  35437. /**
  35438. * Put the sound in pause
  35439. */
  35440. pause(): void;
  35441. /**
  35442. * Sets a dedicated volume for this sounds
  35443. * @param newVolume Define the new volume of the sound
  35444. * @param time Define time for gradual change to new volume
  35445. */
  35446. setVolume(newVolume: number, time?: number): void;
  35447. /**
  35448. * Set the sound play back rate
  35449. * @param newPlaybackRate Define the playback rate the sound should be played at
  35450. */
  35451. setPlaybackRate(newPlaybackRate: number): void;
  35452. /**
  35453. * Gets the volume of the sound.
  35454. * @returns the volume of the sound
  35455. */
  35456. getVolume(): number;
  35457. /**
  35458. * Attach the sound to a dedicated mesh
  35459. * @param transformNode The transform node to connect the sound with
  35460. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35461. */
  35462. attachToMesh(transformNode: TransformNode): void;
  35463. /**
  35464. * Detach the sound from the previously attached mesh
  35465. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35466. */
  35467. detachFromMesh(): void;
  35468. private _onRegisterAfterWorldMatrixUpdate;
  35469. /**
  35470. * Clone the current sound in the scene.
  35471. * @returns the new sound clone
  35472. */
  35473. clone(): Nullable<Sound>;
  35474. /**
  35475. * Gets the current underlying audio buffer containing the data
  35476. * @returns the audio buffer
  35477. */
  35478. getAudioBuffer(): Nullable<AudioBuffer>;
  35479. /**
  35480. * Serializes the Sound in a JSON representation
  35481. * @returns the JSON representation of the sound
  35482. */
  35483. serialize(): any;
  35484. /**
  35485. * Parse a JSON representation of a sound to innstantiate in a given scene
  35486. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35487. * @param scene Define the scene the new parsed sound should be created in
  35488. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35489. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35490. * @returns the newly parsed sound
  35491. */
  35492. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35493. }
  35494. }
  35495. declare module "babylonjs/Actions/directAudioActions" {
  35496. import { Action } from "babylonjs/Actions/action";
  35497. import { Condition } from "babylonjs/Actions/condition";
  35498. import { Sound } from "babylonjs/Audio/sound";
  35499. /**
  35500. * This defines an action helpful to play a defined sound on a triggered action.
  35501. */
  35502. export class PlaySoundAction extends Action {
  35503. private _sound;
  35504. /**
  35505. * Instantiate the action
  35506. * @param triggerOptions defines the trigger options
  35507. * @param sound defines the sound to play
  35508. * @param condition defines the trigger related conditions
  35509. */
  35510. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35511. /** @hidden */
  35512. _prepare(): void;
  35513. /**
  35514. * Execute the action and play the sound.
  35515. */
  35516. execute(): void;
  35517. /**
  35518. * Serializes the actions and its related information.
  35519. * @param parent defines the object to serialize in
  35520. * @returns the serialized object
  35521. */
  35522. serialize(parent: any): any;
  35523. }
  35524. /**
  35525. * This defines an action helpful to stop a defined sound on a triggered action.
  35526. */
  35527. export class StopSoundAction extends Action {
  35528. private _sound;
  35529. /**
  35530. * Instantiate the action
  35531. * @param triggerOptions defines the trigger options
  35532. * @param sound defines the sound to stop
  35533. * @param condition defines the trigger related conditions
  35534. */
  35535. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35536. /** @hidden */
  35537. _prepare(): void;
  35538. /**
  35539. * Execute the action and stop the sound.
  35540. */
  35541. execute(): void;
  35542. /**
  35543. * Serializes the actions and its related information.
  35544. * @param parent defines the object to serialize in
  35545. * @returns the serialized object
  35546. */
  35547. serialize(parent: any): any;
  35548. }
  35549. }
  35550. declare module "babylonjs/Actions/interpolateValueAction" {
  35551. import { Action } from "babylonjs/Actions/action";
  35552. import { Condition } from "babylonjs/Actions/condition";
  35553. import { Observable } from "babylonjs/Misc/observable";
  35554. /**
  35555. * This defines an action responsible to change the value of a property
  35556. * by interpolating between its current value and the newly set one once triggered.
  35557. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35558. */
  35559. export class InterpolateValueAction extends Action {
  35560. /**
  35561. * Defines the path of the property where the value should be interpolated
  35562. */
  35563. propertyPath: string;
  35564. /**
  35565. * Defines the target value at the end of the interpolation.
  35566. */
  35567. value: any;
  35568. /**
  35569. * Defines the time it will take for the property to interpolate to the value.
  35570. */
  35571. duration: number;
  35572. /**
  35573. * Defines if the other scene animations should be stopped when the action has been triggered
  35574. */
  35575. stopOtherAnimations?: boolean;
  35576. /**
  35577. * Defines a callback raised once the interpolation animation has been done.
  35578. */
  35579. onInterpolationDone?: () => void;
  35580. /**
  35581. * Observable triggered once the interpolation animation has been done.
  35582. */
  35583. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35584. private _target;
  35585. private _effectiveTarget;
  35586. private _property;
  35587. /**
  35588. * Instantiate the action
  35589. * @param triggerOptions defines the trigger options
  35590. * @param target defines the object containing the value to interpolate
  35591. * @param propertyPath defines the path to the property in the target object
  35592. * @param value defines the target value at the end of the interpolation
  35593. * @param duration deines the time it will take for the property to interpolate to the value.
  35594. * @param condition defines the trigger related conditions
  35595. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35596. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35597. */
  35598. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35599. /** @hidden */
  35600. _prepare(): void;
  35601. /**
  35602. * Execute the action starts the value interpolation.
  35603. */
  35604. execute(): void;
  35605. /**
  35606. * Serializes the actions and its related information.
  35607. * @param parent defines the object to serialize in
  35608. * @returns the serialized object
  35609. */
  35610. serialize(parent: any): any;
  35611. }
  35612. }
  35613. declare module "babylonjs/Actions/index" {
  35614. export * from "babylonjs/Actions/action";
  35615. export * from "babylonjs/Actions/actionEvent";
  35616. export * from "babylonjs/Actions/actionManager";
  35617. export * from "babylonjs/Actions/condition";
  35618. export * from "babylonjs/Actions/directActions";
  35619. export * from "babylonjs/Actions/directAudioActions";
  35620. export * from "babylonjs/Actions/interpolateValueAction";
  35621. }
  35622. declare module "babylonjs/Animations/index" {
  35623. export * from "babylonjs/Animations/animatable";
  35624. export * from "babylonjs/Animations/animation";
  35625. export * from "babylonjs/Animations/animationGroup";
  35626. export * from "babylonjs/Animations/animationPropertiesOverride";
  35627. export * from "babylonjs/Animations/easing";
  35628. export * from "babylonjs/Animations/runtimeAnimation";
  35629. export * from "babylonjs/Animations/animationEvent";
  35630. export * from "babylonjs/Animations/animationGroup";
  35631. export * from "babylonjs/Animations/animationKey";
  35632. export * from "babylonjs/Animations/animationRange";
  35633. }
  35634. declare module "babylonjs/Audio/soundTrack" {
  35635. import { Sound } from "babylonjs/Audio/sound";
  35636. import { Analyser } from "babylonjs/Audio/analyser";
  35637. import { Scene } from "babylonjs/scene";
  35638. /**
  35639. * Options allowed during the creation of a sound track.
  35640. */
  35641. export interface ISoundTrackOptions {
  35642. /**
  35643. * The volume the sound track should take during creation
  35644. */
  35645. volume?: number;
  35646. /**
  35647. * Define if the sound track is the main sound track of the scene
  35648. */
  35649. mainTrack?: boolean;
  35650. }
  35651. /**
  35652. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35653. * It will be also used in a future release to apply effects on a specific track.
  35654. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35655. */
  35656. export class SoundTrack {
  35657. /**
  35658. * The unique identifier of the sound track in the scene.
  35659. */
  35660. id: number;
  35661. /**
  35662. * The list of sounds included in the sound track.
  35663. */
  35664. soundCollection: Array<Sound>;
  35665. private _outputAudioNode;
  35666. private _scene;
  35667. private _isMainTrack;
  35668. private _connectedAnalyser;
  35669. private _options;
  35670. private _isInitialized;
  35671. /**
  35672. * Creates a new sound track.
  35673. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35674. * @param scene Define the scene the sound track belongs to
  35675. * @param options
  35676. */
  35677. constructor(scene: Scene, options?: ISoundTrackOptions);
  35678. private _initializeSoundTrackAudioGraph;
  35679. /**
  35680. * Release the sound track and its associated resources
  35681. */
  35682. dispose(): void;
  35683. /**
  35684. * Adds a sound to this sound track
  35685. * @param sound define the cound to add
  35686. * @ignoreNaming
  35687. */
  35688. AddSound(sound: Sound): void;
  35689. /**
  35690. * Removes a sound to this sound track
  35691. * @param sound define the cound to remove
  35692. * @ignoreNaming
  35693. */
  35694. RemoveSound(sound: Sound): void;
  35695. /**
  35696. * Set a global volume for the full sound track.
  35697. * @param newVolume Define the new volume of the sound track
  35698. */
  35699. setVolume(newVolume: number): void;
  35700. /**
  35701. * Switch the panning model to HRTF:
  35702. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35703. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35704. */
  35705. switchPanningModelToHRTF(): void;
  35706. /**
  35707. * Switch the panning model to Equal Power:
  35708. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35709. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35710. */
  35711. switchPanningModelToEqualPower(): void;
  35712. /**
  35713. * Connect the sound track to an audio analyser allowing some amazing
  35714. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35715. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35716. * @param analyser The analyser to connect to the engine
  35717. */
  35718. connectToAnalyser(analyser: Analyser): void;
  35719. }
  35720. }
  35721. declare module "babylonjs/Audio/audioSceneComponent" {
  35722. import { Sound } from "babylonjs/Audio/sound";
  35723. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  35724. import { Nullable } from "babylonjs/types";
  35725. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  35726. import { Scene } from "babylonjs/scene";
  35727. import { AbstractScene } from "babylonjs/abstractScene";
  35728. module "babylonjs/abstractScene" {
  35729. interface AbstractScene {
  35730. /**
  35731. * The list of sounds used in the scene.
  35732. */
  35733. sounds: Nullable<Array<Sound>>;
  35734. }
  35735. }
  35736. module "babylonjs/scene" {
  35737. interface Scene {
  35738. /**
  35739. * @hidden
  35740. * Backing field
  35741. */
  35742. _mainSoundTrack: SoundTrack;
  35743. /**
  35744. * The main sound track played by the scene.
  35745. * It cotains your primary collection of sounds.
  35746. */
  35747. mainSoundTrack: SoundTrack;
  35748. /**
  35749. * The list of sound tracks added to the scene
  35750. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35751. */
  35752. soundTracks: Nullable<Array<SoundTrack>>;
  35753. /**
  35754. * Gets a sound using a given name
  35755. * @param name defines the name to search for
  35756. * @return the found sound or null if not found at all.
  35757. */
  35758. getSoundByName(name: string): Nullable<Sound>;
  35759. /**
  35760. * Gets or sets if audio support is enabled
  35761. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35762. */
  35763. audioEnabled: boolean;
  35764. /**
  35765. * Gets or sets if audio will be output to headphones
  35766. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35767. */
  35768. headphone: boolean;
  35769. }
  35770. }
  35771. /**
  35772. * Defines the sound scene component responsible to manage any sounds
  35773. * in a given scene.
  35774. */
  35775. export class AudioSceneComponent implements ISceneSerializableComponent {
  35776. /**
  35777. * The component name helpfull to identify the component in the list of scene components.
  35778. */
  35779. readonly name: string;
  35780. /**
  35781. * The scene the component belongs to.
  35782. */
  35783. scene: Scene;
  35784. private _audioEnabled;
  35785. /**
  35786. * Gets whether audio is enabled or not.
  35787. * Please use related enable/disable method to switch state.
  35788. */
  35789. readonly audioEnabled: boolean;
  35790. private _headphone;
  35791. /**
  35792. * Gets whether audio is outputing to headphone or not.
  35793. * Please use the according Switch methods to change output.
  35794. */
  35795. readonly headphone: boolean;
  35796. /**
  35797. * Creates a new instance of the component for the given scene
  35798. * @param scene Defines the scene to register the component in
  35799. */
  35800. constructor(scene: Scene);
  35801. /**
  35802. * Registers the component in a given scene
  35803. */
  35804. register(): void;
  35805. /**
  35806. * Rebuilds the elements related to this component in case of
  35807. * context lost for instance.
  35808. */
  35809. rebuild(): void;
  35810. /**
  35811. * Serializes the component data to the specified json object
  35812. * @param serializationObject The object to serialize to
  35813. */
  35814. serialize(serializationObject: any): void;
  35815. /**
  35816. * Adds all the elements from the container to the scene
  35817. * @param container the container holding the elements
  35818. */
  35819. addFromContainer(container: AbstractScene): void;
  35820. /**
  35821. * Removes all the elements in the container from the scene
  35822. * @param container contains the elements to remove
  35823. * @param dispose if the removed element should be disposed (default: false)
  35824. */
  35825. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35826. /**
  35827. * Disposes the component and the associated ressources.
  35828. */
  35829. dispose(): void;
  35830. /**
  35831. * Disables audio in the associated scene.
  35832. */
  35833. disableAudio(): void;
  35834. /**
  35835. * Enables audio in the associated scene.
  35836. */
  35837. enableAudio(): void;
  35838. /**
  35839. * Switch audio to headphone output.
  35840. */
  35841. switchAudioModeForHeadphones(): void;
  35842. /**
  35843. * Switch audio to normal speakers.
  35844. */
  35845. switchAudioModeForNormalSpeakers(): void;
  35846. private _afterRender;
  35847. }
  35848. }
  35849. declare module "babylonjs/Audio/weightedsound" {
  35850. import { Sound } from "babylonjs/Audio/sound";
  35851. /**
  35852. * Wraps one or more Sound objects and selects one with random weight for playback.
  35853. */
  35854. export class WeightedSound {
  35855. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35856. loop: boolean;
  35857. private _coneInnerAngle;
  35858. private _coneOuterAngle;
  35859. private _volume;
  35860. /** A Sound is currently playing. */
  35861. isPlaying: boolean;
  35862. /** A Sound is currently paused. */
  35863. isPaused: boolean;
  35864. private _sounds;
  35865. private _weights;
  35866. private _currentIndex?;
  35867. /**
  35868. * Creates a new WeightedSound from the list of sounds given.
  35869. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35870. * @param sounds Array of Sounds that will be selected from.
  35871. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35872. */
  35873. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35874. /**
  35875. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35876. */
  35877. /**
  35878. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35879. */
  35880. directionalConeInnerAngle: number;
  35881. /**
  35882. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35883. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35884. */
  35885. /**
  35886. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35887. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35888. */
  35889. directionalConeOuterAngle: number;
  35890. /**
  35891. * Playback volume.
  35892. */
  35893. /**
  35894. * Playback volume.
  35895. */
  35896. volume: number;
  35897. private _onended;
  35898. /**
  35899. * Suspend playback
  35900. */
  35901. pause(): void;
  35902. /**
  35903. * Stop playback
  35904. */
  35905. stop(): void;
  35906. /**
  35907. * Start playback.
  35908. * @param startOffset Position the clip head at a specific time in seconds.
  35909. */
  35910. play(startOffset?: number): void;
  35911. }
  35912. }
  35913. declare module "babylonjs/Audio/index" {
  35914. export * from "babylonjs/Audio/analyser";
  35915. export * from "babylonjs/Audio/audioEngine";
  35916. export * from "babylonjs/Audio/audioSceneComponent";
  35917. export * from "babylonjs/Audio/sound";
  35918. export * from "babylonjs/Audio/soundTrack";
  35919. export * from "babylonjs/Audio/weightedsound";
  35920. }
  35921. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35922. import { Behavior } from "babylonjs/Behaviors/behavior";
  35923. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35924. import { BackEase } from "babylonjs/Animations/easing";
  35925. /**
  35926. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35927. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35928. */
  35929. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35930. /**
  35931. * Gets the name of the behavior.
  35932. */
  35933. readonly name: string;
  35934. /**
  35935. * The easing function used by animations
  35936. */
  35937. static EasingFunction: BackEase;
  35938. /**
  35939. * The easing mode used by animations
  35940. */
  35941. static EasingMode: number;
  35942. /**
  35943. * The duration of the animation, in milliseconds
  35944. */
  35945. transitionDuration: number;
  35946. /**
  35947. * Length of the distance animated by the transition when lower radius is reached
  35948. */
  35949. lowerRadiusTransitionRange: number;
  35950. /**
  35951. * Length of the distance animated by the transition when upper radius is reached
  35952. */
  35953. upperRadiusTransitionRange: number;
  35954. private _autoTransitionRange;
  35955. /**
  35956. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35957. */
  35958. /**
  35959. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35960. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35961. */
  35962. autoTransitionRange: boolean;
  35963. private _attachedCamera;
  35964. private _onAfterCheckInputsObserver;
  35965. private _onMeshTargetChangedObserver;
  35966. /**
  35967. * Initializes the behavior.
  35968. */
  35969. init(): void;
  35970. /**
  35971. * Attaches the behavior to its arc rotate camera.
  35972. * @param camera Defines the camera to attach the behavior to
  35973. */
  35974. attach(camera: ArcRotateCamera): void;
  35975. /**
  35976. * Detaches the behavior from its current arc rotate camera.
  35977. */
  35978. detach(): void;
  35979. private _radiusIsAnimating;
  35980. private _radiusBounceTransition;
  35981. private _animatables;
  35982. private _cachedWheelPrecision;
  35983. /**
  35984. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35985. * @param radiusLimit The limit to check against.
  35986. * @return Bool to indicate if at limit.
  35987. */
  35988. private _isRadiusAtLimit;
  35989. /**
  35990. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35991. * @param radiusDelta The delta by which to animate to. Can be negative.
  35992. */
  35993. private _applyBoundRadiusAnimation;
  35994. /**
  35995. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35996. */
  35997. protected _clearAnimationLocks(): void;
  35998. /**
  35999. * Stops and removes all animations that have been applied to the camera
  36000. */
  36001. stopAllAnimations(): void;
  36002. }
  36003. }
  36004. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36005. import { Behavior } from "babylonjs/Behaviors/behavior";
  36006. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36007. import { ExponentialEase } from "babylonjs/Animations/easing";
  36008. import { Nullable } from "babylonjs/types";
  36009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36010. import { Vector3 } from "babylonjs/Maths/math";
  36011. /**
  36012. * 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.
  36013. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36014. */
  36015. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36016. /**
  36017. * Gets the name of the behavior.
  36018. */
  36019. readonly name: string;
  36020. private _mode;
  36021. private _radiusScale;
  36022. private _positionScale;
  36023. private _defaultElevation;
  36024. private _elevationReturnTime;
  36025. private _elevationReturnWaitTime;
  36026. private _zoomStopsAnimation;
  36027. private _framingTime;
  36028. /**
  36029. * The easing function used by animations
  36030. */
  36031. static EasingFunction: ExponentialEase;
  36032. /**
  36033. * The easing mode used by animations
  36034. */
  36035. static EasingMode: number;
  36036. /**
  36037. * Sets the current mode used by the behavior
  36038. */
  36039. /**
  36040. * Gets current mode used by the behavior.
  36041. */
  36042. mode: number;
  36043. /**
  36044. * Sets the scale applied to the radius (1 by default)
  36045. */
  36046. /**
  36047. * Gets the scale applied to the radius
  36048. */
  36049. radiusScale: number;
  36050. /**
  36051. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36052. */
  36053. /**
  36054. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36055. */
  36056. positionScale: number;
  36057. /**
  36058. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36059. * behaviour is triggered, in radians.
  36060. */
  36061. /**
  36062. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36063. * behaviour is triggered, in radians.
  36064. */
  36065. defaultElevation: number;
  36066. /**
  36067. * Sets the time (in milliseconds) taken to return to the default beta position.
  36068. * Negative value indicates camera should not return to default.
  36069. */
  36070. /**
  36071. * Gets the time (in milliseconds) taken to return to the default beta position.
  36072. * Negative value indicates camera should not return to default.
  36073. */
  36074. elevationReturnTime: number;
  36075. /**
  36076. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36077. */
  36078. /**
  36079. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36080. */
  36081. elevationReturnWaitTime: number;
  36082. /**
  36083. * Sets the flag that indicates if user zooming should stop animation.
  36084. */
  36085. /**
  36086. * Gets the flag that indicates if user zooming should stop animation.
  36087. */
  36088. zoomStopsAnimation: boolean;
  36089. /**
  36090. * Sets the transition time when framing the mesh, in milliseconds
  36091. */
  36092. /**
  36093. * Gets the transition time when framing the mesh, in milliseconds
  36094. */
  36095. framingTime: number;
  36096. /**
  36097. * Define if the behavior should automatically change the configured
  36098. * camera limits and sensibilities.
  36099. */
  36100. autoCorrectCameraLimitsAndSensibility: boolean;
  36101. private _onPrePointerObservableObserver;
  36102. private _onAfterCheckInputsObserver;
  36103. private _onMeshTargetChangedObserver;
  36104. private _attachedCamera;
  36105. private _isPointerDown;
  36106. private _lastInteractionTime;
  36107. /**
  36108. * Initializes the behavior.
  36109. */
  36110. init(): void;
  36111. /**
  36112. * Attaches the behavior to its arc rotate camera.
  36113. * @param camera Defines the camera to attach the behavior to
  36114. */
  36115. attach(camera: ArcRotateCamera): void;
  36116. /**
  36117. * Detaches the behavior from its current arc rotate camera.
  36118. */
  36119. detach(): void;
  36120. private _animatables;
  36121. private _betaIsAnimating;
  36122. private _betaTransition;
  36123. private _radiusTransition;
  36124. private _vectorTransition;
  36125. /**
  36126. * Targets the given mesh and updates zoom level accordingly.
  36127. * @param mesh The mesh to target.
  36128. * @param radius Optional. If a cached radius position already exists, overrides default.
  36129. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36130. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36131. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36132. */
  36133. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36134. /**
  36135. * Targets the given mesh with its children and updates zoom level accordingly.
  36136. * @param mesh The mesh to target.
  36137. * @param radius Optional. If a cached radius position already exists, overrides default.
  36138. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36139. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36140. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36141. */
  36142. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36143. /**
  36144. * Targets the given meshes with their children and updates zoom level accordingly.
  36145. * @param meshes The mesh to target.
  36146. * @param radius Optional. If a cached radius position already exists, overrides default.
  36147. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36148. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36149. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36150. */
  36151. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36152. /**
  36153. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36154. * @param minimumWorld Determines the smaller position of the bounding box extend
  36155. * @param maximumWorld Determines the bigger position of the bounding box extend
  36156. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36157. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36158. */
  36159. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36160. /**
  36161. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36162. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36163. * frustum width.
  36164. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36165. * to fully enclose the mesh in the viewing frustum.
  36166. */
  36167. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36168. /**
  36169. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36170. * is automatically returned to its default position (expected to be above ground plane).
  36171. */
  36172. private _maintainCameraAboveGround;
  36173. /**
  36174. * Returns the frustum slope based on the canvas ratio and camera FOV
  36175. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36176. */
  36177. private _getFrustumSlope;
  36178. /**
  36179. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36180. */
  36181. private _clearAnimationLocks;
  36182. /**
  36183. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36184. */
  36185. private _applyUserInteraction;
  36186. /**
  36187. * Stops and removes all animations that have been applied to the camera
  36188. */
  36189. stopAllAnimations(): void;
  36190. /**
  36191. * Gets a value indicating if the user is moving the camera
  36192. */
  36193. readonly isUserIsMoving: boolean;
  36194. /**
  36195. * The camera can move all the way towards the mesh.
  36196. */
  36197. static IgnoreBoundsSizeMode: number;
  36198. /**
  36199. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36200. */
  36201. static FitFrustumSidesMode: number;
  36202. }
  36203. }
  36204. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36205. import { Nullable } from "babylonjs/types";
  36206. import { Camera } from "babylonjs/Cameras/camera";
  36207. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36208. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36209. /**
  36210. * Base class for Camera Pointer Inputs.
  36211. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36212. * for example usage.
  36213. */
  36214. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36215. /**
  36216. * Defines the camera the input is attached to.
  36217. */
  36218. abstract camera: Camera;
  36219. /**
  36220. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36221. */
  36222. protected _altKey: boolean;
  36223. protected _ctrlKey: boolean;
  36224. protected _metaKey: boolean;
  36225. protected _shiftKey: boolean;
  36226. /**
  36227. * Which mouse buttons were pressed at time of last mouse event.
  36228. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  36229. */
  36230. protected _buttonsPressed: number;
  36231. /**
  36232. * Defines the buttons associated with the input to handle camera move.
  36233. */
  36234. buttons: number[];
  36235. /**
  36236. * Attach the input controls to a specific dom element to get the input from.
  36237. * @param element Defines the element the controls should be listened from
  36238. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36239. */
  36240. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36241. /**
  36242. * Detach the current controls from the specified dom element.
  36243. * @param element Defines the element to stop listening the inputs from
  36244. */
  36245. detachControl(element: Nullable<HTMLElement>): void;
  36246. /**
  36247. * Gets the class name of the current input.
  36248. * @returns the class name
  36249. */
  36250. getClassName(): string;
  36251. /**
  36252. * Get the friendly name associated with the input class.
  36253. * @returns the input friendly name
  36254. */
  36255. getSimpleName(): string;
  36256. /**
  36257. * Called on pointer POINTERDOUBLETAP event.
  36258. * Override this method to provide functionality on POINTERDOUBLETAP event.
  36259. */
  36260. protected onDoubleTap(type: string): void;
  36261. /**
  36262. * Called on pointer POINTERMOVE event if only a single touch is active.
  36263. * Override this method to provide functionality.
  36264. */
  36265. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36266. /**
  36267. * Called on pointer POINTERMOVE event if multiple touches are active.
  36268. * Override this method to provide functionality.
  36269. */
  36270. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36271. /**
  36272. * Called on JS contextmenu event.
  36273. * Override this method to provide functionality.
  36274. */
  36275. protected onContextMenu(evt: PointerEvent): void;
  36276. /**
  36277. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36278. * press.
  36279. * Override this method to provide functionality.
  36280. */
  36281. protected onButtonDown(evt: PointerEvent): void;
  36282. /**
  36283. * Called each time a new POINTERUP event occurs. Ie, for each button
  36284. * release.
  36285. * Override this method to provide functionality.
  36286. */
  36287. protected onButtonUp(evt: PointerEvent): void;
  36288. /**
  36289. * Called when window becomes inactive.
  36290. * Override this method to provide functionality.
  36291. */
  36292. protected onLostFocus(): void;
  36293. private _pointerInput;
  36294. private _observer;
  36295. private _onLostFocus;
  36296. private pointA;
  36297. private pointB;
  36298. }
  36299. }
  36300. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  36301. import { Nullable } from "babylonjs/types";
  36302. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36303. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  36304. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36305. /**
  36306. * Manage the pointers inputs to control an arc rotate camera.
  36307. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36308. */
  36309. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  36310. /**
  36311. * Defines the camera the input is attached to.
  36312. */
  36313. camera: ArcRotateCamera;
  36314. /**
  36315. * Gets the class name of the current input.
  36316. * @returns the class name
  36317. */
  36318. getClassName(): string;
  36319. /**
  36320. * Defines the buttons associated with the input to handle camera move.
  36321. */
  36322. buttons: number[];
  36323. /**
  36324. * Defines the pointer angular sensibility along the X axis or how fast is
  36325. * the camera rotating.
  36326. */
  36327. angularSensibilityX: number;
  36328. /**
  36329. * Defines the pointer angular sensibility along the Y axis or how fast is
  36330. * the camera rotating.
  36331. */
  36332. angularSensibilityY: number;
  36333. /**
  36334. * Defines the pointer pinch precision or how fast is the camera zooming.
  36335. */
  36336. pinchPrecision: number;
  36337. /**
  36338. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36339. * from 0.
  36340. * It defines the percentage of current camera.radius to use as delta when
  36341. * pinch zoom is used.
  36342. */
  36343. pinchDeltaPercentage: number;
  36344. /**
  36345. * Defines the pointer panning sensibility or how fast is the camera moving.
  36346. */
  36347. panningSensibility: number;
  36348. /**
  36349. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  36350. */
  36351. multiTouchPanning: boolean;
  36352. /**
  36353. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  36354. * zoom (pinch) through multitouch.
  36355. */
  36356. multiTouchPanAndZoom: boolean;
  36357. /**
  36358. * Revers pinch action direction.
  36359. */
  36360. pinchInwards: boolean;
  36361. private _isPanClick;
  36362. private _twoFingerActivityCount;
  36363. private _isPinching;
  36364. /**
  36365. * Called on pointer POINTERMOVE event if only a single touch is active.
  36366. */
  36367. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36368. /**
  36369. * Called on pointer POINTERDOUBLETAP event.
  36370. */
  36371. protected onDoubleTap(type: string): void;
  36372. /**
  36373. * Called on pointer POINTERMOVE event if multiple touches are active.
  36374. */
  36375. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36376. /**
  36377. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  36378. * press.
  36379. */
  36380. protected onButtonDown(evt: PointerEvent): void;
  36381. /**
  36382. * Called each time a new POINTERUP event occurs. Ie, for each button
  36383. * release.
  36384. */
  36385. protected onButtonUp(evt: PointerEvent): void;
  36386. /**
  36387. * Called when window becomes inactive.
  36388. */
  36389. protected onLostFocus(): void;
  36390. }
  36391. }
  36392. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  36393. import { Nullable } from "babylonjs/types";
  36394. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36395. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36396. /**
  36397. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  36398. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36399. */
  36400. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  36401. /**
  36402. * Defines the camera the input is attached to.
  36403. */
  36404. camera: ArcRotateCamera;
  36405. /**
  36406. * Defines the list of key codes associated with the up action (increase alpha)
  36407. */
  36408. keysUp: number[];
  36409. /**
  36410. * Defines the list of key codes associated with the down action (decrease alpha)
  36411. */
  36412. keysDown: number[];
  36413. /**
  36414. * Defines the list of key codes associated with the left action (increase beta)
  36415. */
  36416. keysLeft: number[];
  36417. /**
  36418. * Defines the list of key codes associated with the right action (decrease beta)
  36419. */
  36420. keysRight: number[];
  36421. /**
  36422. * Defines the list of key codes associated with the reset action.
  36423. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36424. */
  36425. keysReset: number[];
  36426. /**
  36427. * Defines the panning sensibility of the inputs.
  36428. * (How fast is the camera paning)
  36429. */
  36430. panningSensibility: number;
  36431. /**
  36432. * Defines the zooming sensibility of the inputs.
  36433. * (How fast is the camera zooming)
  36434. */
  36435. zoomingSensibility: number;
  36436. /**
  36437. * Defines wether maintaining the alt key down switch the movement mode from
  36438. * orientation to zoom.
  36439. */
  36440. useAltToZoom: boolean;
  36441. /**
  36442. * Rotation speed of the camera
  36443. */
  36444. angularSpeed: number;
  36445. private _keys;
  36446. private _ctrlPressed;
  36447. private _altPressed;
  36448. private _onCanvasBlurObserver;
  36449. private _onKeyboardObserver;
  36450. private _engine;
  36451. private _scene;
  36452. /**
  36453. * Attach the input controls to a specific dom element to get the input from.
  36454. * @param element Defines the element the controls should be listened from
  36455. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36456. */
  36457. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36458. /**
  36459. * Detach the current controls from the specified dom element.
  36460. * @param element Defines the element to stop listening the inputs from
  36461. */
  36462. detachControl(element: Nullable<HTMLElement>): void;
  36463. /**
  36464. * Update the current camera state depending on the inputs that have been used this frame.
  36465. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36466. */
  36467. checkInputs(): void;
  36468. /**
  36469. * Gets the class name of the current intput.
  36470. * @returns the class name
  36471. */
  36472. getClassName(): string;
  36473. /**
  36474. * Get the friendly name associated with the input class.
  36475. * @returns the input friendly name
  36476. */
  36477. getSimpleName(): string;
  36478. }
  36479. }
  36480. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36481. import { Nullable } from "babylonjs/types";
  36482. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36483. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36484. /**
  36485. * Manage the mouse wheel inputs to control an arc rotate camera.
  36486. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36487. */
  36488. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36489. /**
  36490. * Defines the camera the input is attached to.
  36491. */
  36492. camera: ArcRotateCamera;
  36493. /**
  36494. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36495. */
  36496. wheelPrecision: number;
  36497. /**
  36498. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36499. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36500. */
  36501. wheelDeltaPercentage: number;
  36502. private _wheel;
  36503. private _observer;
  36504. private computeDeltaFromMouseWheelLegacyEvent;
  36505. /**
  36506. * Attach the input controls to a specific dom element to get the input from.
  36507. * @param element Defines the element the controls should be listened from
  36508. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36509. */
  36510. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36511. /**
  36512. * Detach the current controls from the specified dom element.
  36513. * @param element Defines the element to stop listening the inputs from
  36514. */
  36515. detachControl(element: Nullable<HTMLElement>): void;
  36516. /**
  36517. * Gets the class name of the current intput.
  36518. * @returns the class name
  36519. */
  36520. getClassName(): string;
  36521. /**
  36522. * Get the friendly name associated with the input class.
  36523. * @returns the input friendly name
  36524. */
  36525. getSimpleName(): string;
  36526. }
  36527. }
  36528. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36529. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36530. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36531. /**
  36532. * Default Inputs manager for the ArcRotateCamera.
  36533. * It groups all the default supported inputs for ease of use.
  36534. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36535. */
  36536. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36537. /**
  36538. * Instantiates a new ArcRotateCameraInputsManager.
  36539. * @param camera Defines the camera the inputs belong to
  36540. */
  36541. constructor(camera: ArcRotateCamera);
  36542. /**
  36543. * Add mouse wheel input support to the input manager.
  36544. * @returns the current input manager
  36545. */
  36546. addMouseWheel(): ArcRotateCameraInputsManager;
  36547. /**
  36548. * Add pointers input support to the input manager.
  36549. * @returns the current input manager
  36550. */
  36551. addPointers(): ArcRotateCameraInputsManager;
  36552. /**
  36553. * Add keyboard input support to the input manager.
  36554. * @returns the current input manager
  36555. */
  36556. addKeyboard(): ArcRotateCameraInputsManager;
  36557. }
  36558. }
  36559. declare module "babylonjs/Cameras/arcRotateCamera" {
  36560. import { Observable } from "babylonjs/Misc/observable";
  36561. import { Nullable } from "babylonjs/types";
  36562. import { Scene } from "babylonjs/scene";
  36563. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  36564. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36565. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36566. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36567. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36568. import { Camera } from "babylonjs/Cameras/camera";
  36569. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36570. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36571. import { Collider } from "babylonjs/Collisions/collider";
  36572. /**
  36573. * This represents an orbital type of camera.
  36574. *
  36575. * 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.
  36576. * 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.
  36577. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36578. */
  36579. export class ArcRotateCamera extends TargetCamera {
  36580. /**
  36581. * Defines the rotation angle of the camera along the longitudinal axis.
  36582. */
  36583. alpha: number;
  36584. /**
  36585. * Defines the rotation angle of the camera along the latitudinal axis.
  36586. */
  36587. beta: number;
  36588. /**
  36589. * Defines the radius of the camera from it s target point.
  36590. */
  36591. radius: number;
  36592. protected _target: Vector3;
  36593. protected _targetHost: Nullable<AbstractMesh>;
  36594. /**
  36595. * Defines the target point of the camera.
  36596. * The camera looks towards it form the radius distance.
  36597. */
  36598. target: Vector3;
  36599. /**
  36600. * Define the current local position of the camera in the scene
  36601. */
  36602. position: Vector3;
  36603. protected _upVector: Vector3;
  36604. protected _upToYMatrix: Matrix;
  36605. protected _YToUpMatrix: Matrix;
  36606. /**
  36607. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36608. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36609. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36610. */
  36611. upVector: Vector3;
  36612. /**
  36613. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36614. */
  36615. setMatUp(): void;
  36616. /**
  36617. * Current inertia value on the longitudinal axis.
  36618. * The bigger this number the longer it will take for the camera to stop.
  36619. */
  36620. inertialAlphaOffset: number;
  36621. /**
  36622. * Current inertia value on the latitudinal axis.
  36623. * The bigger this number the longer it will take for the camera to stop.
  36624. */
  36625. inertialBetaOffset: number;
  36626. /**
  36627. * Current inertia value on the radius axis.
  36628. * The bigger this number the longer it will take for the camera to stop.
  36629. */
  36630. inertialRadiusOffset: number;
  36631. /**
  36632. * Minimum allowed angle on the longitudinal axis.
  36633. * This can help limiting how the Camera is able to move in the scene.
  36634. */
  36635. lowerAlphaLimit: Nullable<number>;
  36636. /**
  36637. * Maximum allowed angle on the longitudinal axis.
  36638. * This can help limiting how the Camera is able to move in the scene.
  36639. */
  36640. upperAlphaLimit: Nullable<number>;
  36641. /**
  36642. * Minimum allowed angle on the latitudinal axis.
  36643. * This can help limiting how the Camera is able to move in the scene.
  36644. */
  36645. lowerBetaLimit: number;
  36646. /**
  36647. * Maximum allowed angle on the latitudinal axis.
  36648. * This can help limiting how the Camera is able to move in the scene.
  36649. */
  36650. upperBetaLimit: number;
  36651. /**
  36652. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36653. * This can help limiting how the Camera is able to move in the scene.
  36654. */
  36655. lowerRadiusLimit: Nullable<number>;
  36656. /**
  36657. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36658. * This can help limiting how the Camera is able to move in the scene.
  36659. */
  36660. upperRadiusLimit: Nullable<number>;
  36661. /**
  36662. * Defines the current inertia value used during panning of the camera along the X axis.
  36663. */
  36664. inertialPanningX: number;
  36665. /**
  36666. * Defines the current inertia value used during panning of the camera along the Y axis.
  36667. */
  36668. inertialPanningY: number;
  36669. /**
  36670. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36671. * Basically if your fingers moves away from more than this distance you will be considered
  36672. * in pinch mode.
  36673. */
  36674. pinchToPanMaxDistance: number;
  36675. /**
  36676. * Defines the maximum distance the camera can pan.
  36677. * This could help keeping the cammera always in your scene.
  36678. */
  36679. panningDistanceLimit: Nullable<number>;
  36680. /**
  36681. * Defines the target of the camera before paning.
  36682. */
  36683. panningOriginTarget: Vector3;
  36684. /**
  36685. * Defines the value of the inertia used during panning.
  36686. * 0 would mean stop inertia and one would mean no decelleration at all.
  36687. */
  36688. panningInertia: number;
  36689. /**
  36690. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36691. */
  36692. angularSensibilityX: number;
  36693. /**
  36694. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36695. */
  36696. angularSensibilityY: number;
  36697. /**
  36698. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36699. */
  36700. pinchPrecision: number;
  36701. /**
  36702. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36703. * It will be used instead of pinchDeltaPrecision if different from 0.
  36704. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36705. */
  36706. pinchDeltaPercentage: number;
  36707. /**
  36708. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36709. */
  36710. panningSensibility: number;
  36711. /**
  36712. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36713. */
  36714. keysUp: number[];
  36715. /**
  36716. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36717. */
  36718. keysDown: number[];
  36719. /**
  36720. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36721. */
  36722. keysLeft: number[];
  36723. /**
  36724. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36725. */
  36726. keysRight: number[];
  36727. /**
  36728. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36729. */
  36730. wheelPrecision: number;
  36731. /**
  36732. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36733. * It will be used instead of pinchDeltaPrecision if different from 0.
  36734. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36735. */
  36736. wheelDeltaPercentage: number;
  36737. /**
  36738. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36739. */
  36740. zoomOnFactor: number;
  36741. /**
  36742. * Defines a screen offset for the camera position.
  36743. */
  36744. targetScreenOffset: Vector2;
  36745. /**
  36746. * Allows the camera to be completely reversed.
  36747. * If false the camera can not arrive upside down.
  36748. */
  36749. allowUpsideDown: boolean;
  36750. /**
  36751. * Define if double tap/click is used to restore the previously saved state of the camera.
  36752. */
  36753. useInputToRestoreState: boolean;
  36754. /** @hidden */
  36755. _viewMatrix: Matrix;
  36756. /** @hidden */
  36757. _useCtrlForPanning: boolean;
  36758. /** @hidden */
  36759. _panningMouseButton: number;
  36760. /**
  36761. * Defines the input associated to the camera.
  36762. */
  36763. inputs: ArcRotateCameraInputsManager;
  36764. /** @hidden */
  36765. _reset: () => void;
  36766. /**
  36767. * Defines the allowed panning axis.
  36768. */
  36769. panningAxis: Vector3;
  36770. protected _localDirection: Vector3;
  36771. protected _transformedDirection: Vector3;
  36772. private _bouncingBehavior;
  36773. /**
  36774. * Gets the bouncing behavior of the camera if it has been enabled.
  36775. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36776. */
  36777. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36778. /**
  36779. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36780. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36781. */
  36782. useBouncingBehavior: boolean;
  36783. private _framingBehavior;
  36784. /**
  36785. * Gets the framing behavior of the camera if it has been enabled.
  36786. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36787. */
  36788. readonly framingBehavior: Nullable<FramingBehavior>;
  36789. /**
  36790. * Defines if the framing behavior of the camera is enabled on the camera.
  36791. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36792. */
  36793. useFramingBehavior: boolean;
  36794. private _autoRotationBehavior;
  36795. /**
  36796. * Gets the auto rotation behavior of the camera if it has been enabled.
  36797. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36798. */
  36799. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36800. /**
  36801. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36802. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36803. */
  36804. useAutoRotationBehavior: boolean;
  36805. /**
  36806. * Observable triggered when the mesh target has been changed on the camera.
  36807. */
  36808. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36809. /**
  36810. * Event raised when the camera is colliding with a mesh.
  36811. */
  36812. onCollide: (collidedMesh: AbstractMesh) => void;
  36813. /**
  36814. * Defines whether the camera should check collision with the objects oh the scene.
  36815. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36816. */
  36817. checkCollisions: boolean;
  36818. /**
  36819. * Defines the collision radius of the camera.
  36820. * This simulates a sphere around the camera.
  36821. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36822. */
  36823. collisionRadius: Vector3;
  36824. protected _collider: Collider;
  36825. protected _previousPosition: Vector3;
  36826. protected _collisionVelocity: Vector3;
  36827. protected _newPosition: Vector3;
  36828. protected _previousAlpha: number;
  36829. protected _previousBeta: number;
  36830. protected _previousRadius: number;
  36831. protected _collisionTriggered: boolean;
  36832. protected _targetBoundingCenter: Nullable<Vector3>;
  36833. private _computationVector;
  36834. /**
  36835. * Instantiates a new ArcRotateCamera in a given scene
  36836. * @param name Defines the name of the camera
  36837. * @param alpha Defines the camera rotation along the logitudinal axis
  36838. * @param beta Defines the camera rotation along the latitudinal axis
  36839. * @param radius Defines the camera distance from its target
  36840. * @param target Defines the camera target
  36841. * @param scene Defines the scene the camera belongs to
  36842. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36843. */
  36844. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36845. /** @hidden */
  36846. _initCache(): void;
  36847. /** @hidden */
  36848. _updateCache(ignoreParentClass?: boolean): void;
  36849. protected _getTargetPosition(): Vector3;
  36850. private _storedAlpha;
  36851. private _storedBeta;
  36852. private _storedRadius;
  36853. private _storedTarget;
  36854. /**
  36855. * Stores the current state of the camera (alpha, beta, radius and target)
  36856. * @returns the camera itself
  36857. */
  36858. storeState(): Camera;
  36859. /**
  36860. * @hidden
  36861. * Restored camera state. You must call storeState() first
  36862. */
  36863. _restoreStateValues(): boolean;
  36864. /** @hidden */
  36865. _isSynchronizedViewMatrix(): boolean;
  36866. /**
  36867. * Attached controls to the current camera.
  36868. * @param element Defines the element the controls should be listened from
  36869. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36870. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36871. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36872. */
  36873. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36874. /**
  36875. * Detach the current controls from the camera.
  36876. * The camera will stop reacting to inputs.
  36877. * @param element Defines the element to stop listening the inputs from
  36878. */
  36879. detachControl(element: HTMLElement): void;
  36880. /** @hidden */
  36881. _checkInputs(): void;
  36882. protected _checkLimits(): void;
  36883. /**
  36884. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36885. */
  36886. rebuildAnglesAndRadius(): void;
  36887. /**
  36888. * Use a position to define the current camera related information like aplha, beta and radius
  36889. * @param position Defines the position to set the camera at
  36890. */
  36891. setPosition(position: Vector3): void;
  36892. /**
  36893. * Defines the target the camera should look at.
  36894. * This will automatically adapt alpha beta and radius to fit within the new target.
  36895. * @param target Defines the new target as a Vector or a mesh
  36896. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36897. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36898. */
  36899. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36900. /** @hidden */
  36901. _getViewMatrix(): Matrix;
  36902. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36903. /**
  36904. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36905. * @param meshes Defines the mesh to zoom on
  36906. * @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)
  36907. */
  36908. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36909. /**
  36910. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36911. * The target will be changed but the radius
  36912. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36913. * @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)
  36914. */
  36915. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36916. min: Vector3;
  36917. max: Vector3;
  36918. distance: number;
  36919. }, doNotUpdateMaxZ?: boolean): void;
  36920. /**
  36921. * @override
  36922. * Override Camera.createRigCamera
  36923. */
  36924. createRigCamera(name: string, cameraIndex: number): Camera;
  36925. /**
  36926. * @hidden
  36927. * @override
  36928. * Override Camera._updateRigCameras
  36929. */
  36930. _updateRigCameras(): void;
  36931. /**
  36932. * Destroy the camera and release the current resources hold by it.
  36933. */
  36934. dispose(): void;
  36935. /**
  36936. * Gets the current object class name.
  36937. * @return the class name
  36938. */
  36939. getClassName(): string;
  36940. }
  36941. }
  36942. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36943. import { Behavior } from "babylonjs/Behaviors/behavior";
  36944. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36945. /**
  36946. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36947. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36948. */
  36949. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36950. /**
  36951. * Gets the name of the behavior.
  36952. */
  36953. readonly name: string;
  36954. private _zoomStopsAnimation;
  36955. private _idleRotationSpeed;
  36956. private _idleRotationWaitTime;
  36957. private _idleRotationSpinupTime;
  36958. /**
  36959. * Sets the flag that indicates if user zooming should stop animation.
  36960. */
  36961. /**
  36962. * Gets the flag that indicates if user zooming should stop animation.
  36963. */
  36964. zoomStopsAnimation: boolean;
  36965. /**
  36966. * Sets the default speed at which the camera rotates around the model.
  36967. */
  36968. /**
  36969. * Gets the default speed at which the camera rotates around the model.
  36970. */
  36971. idleRotationSpeed: number;
  36972. /**
  36973. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36974. */
  36975. /**
  36976. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36977. */
  36978. idleRotationWaitTime: number;
  36979. /**
  36980. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36981. */
  36982. /**
  36983. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36984. */
  36985. idleRotationSpinupTime: number;
  36986. /**
  36987. * Gets a value indicating if the camera is currently rotating because of this behavior
  36988. */
  36989. readonly rotationInProgress: boolean;
  36990. private _onPrePointerObservableObserver;
  36991. private _onAfterCheckInputsObserver;
  36992. private _attachedCamera;
  36993. private _isPointerDown;
  36994. private _lastFrameTime;
  36995. private _lastInteractionTime;
  36996. private _cameraRotationSpeed;
  36997. /**
  36998. * Initializes the behavior.
  36999. */
  37000. init(): void;
  37001. /**
  37002. * Attaches the behavior to its arc rotate camera.
  37003. * @param camera Defines the camera to attach the behavior to
  37004. */
  37005. attach(camera: ArcRotateCamera): void;
  37006. /**
  37007. * Detaches the behavior from its current arc rotate camera.
  37008. */
  37009. detach(): void;
  37010. /**
  37011. * Returns true if user is scrolling.
  37012. * @return true if user is scrolling.
  37013. */
  37014. private _userIsZooming;
  37015. private _lastFrameRadius;
  37016. private _shouldAnimationStopForInteraction;
  37017. /**
  37018. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37019. */
  37020. private _applyUserInteraction;
  37021. private _userIsMoving;
  37022. }
  37023. }
  37024. declare module "babylonjs/Behaviors/Cameras/index" {
  37025. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37026. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37027. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37028. }
  37029. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37030. import { Mesh } from "babylonjs/Meshes/mesh";
  37031. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37032. import { Behavior } from "babylonjs/Behaviors/behavior";
  37033. /**
  37034. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37035. */
  37036. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37037. private ui;
  37038. /**
  37039. * The name of the behavior
  37040. */
  37041. name: string;
  37042. /**
  37043. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37044. */
  37045. distanceAwayFromFace: number;
  37046. /**
  37047. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37048. */
  37049. distanceAwayFromBottomOfFace: number;
  37050. private _faceVectors;
  37051. private _target;
  37052. private _scene;
  37053. private _onRenderObserver;
  37054. private _tmpMatrix;
  37055. private _tmpVector;
  37056. /**
  37057. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37058. * @param ui The transform node that should be attched to the mesh
  37059. */
  37060. constructor(ui: TransformNode);
  37061. /**
  37062. * Initializes the behavior
  37063. */
  37064. init(): void;
  37065. private _closestFace;
  37066. private _zeroVector;
  37067. private _lookAtTmpMatrix;
  37068. private _lookAtToRef;
  37069. /**
  37070. * Attaches the AttachToBoxBehavior to the passed in mesh
  37071. * @param target The mesh that the specified node will be attached to
  37072. */
  37073. attach(target: Mesh): void;
  37074. /**
  37075. * Detaches the behavior from the mesh
  37076. */
  37077. detach(): void;
  37078. }
  37079. }
  37080. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37081. import { Behavior } from "babylonjs/Behaviors/behavior";
  37082. import { Mesh } from "babylonjs/Meshes/mesh";
  37083. /**
  37084. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37085. */
  37086. export class FadeInOutBehavior implements Behavior<Mesh> {
  37087. /**
  37088. * Time in milliseconds to delay before fading in (Default: 0)
  37089. */
  37090. delay: number;
  37091. /**
  37092. * Time in milliseconds for the mesh to fade in (Default: 300)
  37093. */
  37094. fadeInTime: number;
  37095. private _millisecondsPerFrame;
  37096. private _hovered;
  37097. private _hoverValue;
  37098. private _ownerNode;
  37099. /**
  37100. * Instatiates the FadeInOutBehavior
  37101. */
  37102. constructor();
  37103. /**
  37104. * The name of the behavior
  37105. */
  37106. readonly name: string;
  37107. /**
  37108. * Initializes the behavior
  37109. */
  37110. init(): void;
  37111. /**
  37112. * Attaches the fade behavior on the passed in mesh
  37113. * @param ownerNode The mesh that will be faded in/out once attached
  37114. */
  37115. attach(ownerNode: Mesh): void;
  37116. /**
  37117. * Detaches the behavior from the mesh
  37118. */
  37119. detach(): void;
  37120. /**
  37121. * Triggers the mesh to begin fading in or out
  37122. * @param value if the object should fade in or out (true to fade in)
  37123. */
  37124. fadeIn(value: boolean): void;
  37125. private _update;
  37126. private _setAllVisibility;
  37127. }
  37128. }
  37129. declare module "babylonjs/Misc/pivotTools" {
  37130. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37131. /**
  37132. * Class containing a set of static utilities functions for managing Pivots
  37133. * @hidden
  37134. */
  37135. export class PivotTools {
  37136. private static _PivotCached;
  37137. private static _OldPivotPoint;
  37138. private static _PivotTranslation;
  37139. private static _PivotTmpVector;
  37140. /** @hidden */
  37141. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37142. /** @hidden */
  37143. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37144. }
  37145. }
  37146. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37147. import { Scene } from "babylonjs/scene";
  37148. import { Vector4, Plane } from "babylonjs/Maths/math";
  37149. import { Mesh } from "babylonjs/Meshes/mesh";
  37150. import { Nullable } from "babylonjs/types";
  37151. /**
  37152. * Class containing static functions to help procedurally build meshes
  37153. */
  37154. export class PlaneBuilder {
  37155. /**
  37156. * Creates a plane mesh
  37157. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37158. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37159. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37160. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37161. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37162. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37163. * @param name defines the name of the mesh
  37164. * @param options defines the options used to create the mesh
  37165. * @param scene defines the hosting scene
  37166. * @returns the plane mesh
  37167. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37168. */
  37169. static CreatePlane(name: string, options: {
  37170. size?: number;
  37171. width?: number;
  37172. height?: number;
  37173. sideOrientation?: number;
  37174. frontUVs?: Vector4;
  37175. backUVs?: Vector4;
  37176. updatable?: boolean;
  37177. sourcePlane?: Plane;
  37178. }, scene?: Nullable<Scene>): Mesh;
  37179. }
  37180. }
  37181. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37182. import { Behavior } from "babylonjs/Behaviors/behavior";
  37183. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37184. import { Observable } from "babylonjs/Misc/observable";
  37185. import { Vector3 } from "babylonjs/Maths/math";
  37186. import { Ray } from "babylonjs/Culling/ray";
  37187. import "babylonjs/Meshes/Builders/planeBuilder";
  37188. /**
  37189. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37190. */
  37191. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37192. private static _AnyMouseID;
  37193. /**
  37194. * Abstract mesh the behavior is set on
  37195. */
  37196. attachedNode: AbstractMesh;
  37197. private _dragPlane;
  37198. private _scene;
  37199. private _pointerObserver;
  37200. private _beforeRenderObserver;
  37201. private static _planeScene;
  37202. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37203. /**
  37204. * 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)
  37205. */
  37206. maxDragAngle: number;
  37207. /**
  37208. * @hidden
  37209. */
  37210. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37211. /**
  37212. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37213. */
  37214. currentDraggingPointerID: number;
  37215. /**
  37216. * The last position where the pointer hit the drag plane in world space
  37217. */
  37218. lastDragPosition: Vector3;
  37219. /**
  37220. * If the behavior is currently in a dragging state
  37221. */
  37222. dragging: boolean;
  37223. /**
  37224. * 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)
  37225. */
  37226. dragDeltaRatio: number;
  37227. /**
  37228. * If the drag plane orientation should be updated during the dragging (Default: true)
  37229. */
  37230. updateDragPlane: boolean;
  37231. private _debugMode;
  37232. private _moving;
  37233. /**
  37234. * Fires each time the attached mesh is dragged with the pointer
  37235. * * delta between last drag position and current drag position in world space
  37236. * * dragDistance along the drag axis
  37237. * * dragPlaneNormal normal of the current drag plane used during the drag
  37238. * * dragPlanePoint in world space where the drag intersects the drag plane
  37239. */
  37240. onDragObservable: Observable<{
  37241. delta: Vector3;
  37242. dragPlanePoint: Vector3;
  37243. dragPlaneNormal: Vector3;
  37244. dragDistance: number;
  37245. pointerId: number;
  37246. }>;
  37247. /**
  37248. * Fires each time a drag begins (eg. mouse down on mesh)
  37249. */
  37250. onDragStartObservable: Observable<{
  37251. dragPlanePoint: Vector3;
  37252. pointerId: number;
  37253. }>;
  37254. /**
  37255. * Fires each time a drag ends (eg. mouse release after drag)
  37256. */
  37257. onDragEndObservable: Observable<{
  37258. dragPlanePoint: Vector3;
  37259. pointerId: number;
  37260. }>;
  37261. /**
  37262. * If the attached mesh should be moved when dragged
  37263. */
  37264. moveAttached: boolean;
  37265. /**
  37266. * If the drag behavior will react to drag events (Default: true)
  37267. */
  37268. enabled: boolean;
  37269. /**
  37270. * If pointer events should start and release the drag (Default: true)
  37271. */
  37272. startAndReleaseDragOnPointerEvents: boolean;
  37273. /**
  37274. * If camera controls should be detached during the drag
  37275. */
  37276. detachCameraControls: boolean;
  37277. /**
  37278. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  37279. */
  37280. useObjectOrienationForDragging: boolean;
  37281. private _options;
  37282. /**
  37283. * Creates a pointer drag behavior that can be attached to a mesh
  37284. * @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)
  37285. */
  37286. constructor(options?: {
  37287. dragAxis?: Vector3;
  37288. dragPlaneNormal?: Vector3;
  37289. });
  37290. /**
  37291. * Predicate to determine if it is valid to move the object to a new position when it is moved
  37292. */
  37293. validateDrag: (targetPosition: Vector3) => boolean;
  37294. /**
  37295. * The name of the behavior
  37296. */
  37297. readonly name: string;
  37298. /**
  37299. * Initializes the behavior
  37300. */
  37301. init(): void;
  37302. private _tmpVector;
  37303. private _alternatePickedPoint;
  37304. private _worldDragAxis;
  37305. private _targetPosition;
  37306. private _attachedElement;
  37307. /**
  37308. * Attaches the drag behavior the passed in mesh
  37309. * @param ownerNode The mesh that will be dragged around once attached
  37310. */
  37311. attach(ownerNode: AbstractMesh): void;
  37312. /**
  37313. * Force relase the drag action by code.
  37314. */
  37315. releaseDrag(): void;
  37316. private _startDragRay;
  37317. private _lastPointerRay;
  37318. /**
  37319. * Simulates the start of a pointer drag event on the behavior
  37320. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  37321. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  37322. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  37323. */
  37324. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  37325. private _startDrag;
  37326. private _dragDelta;
  37327. private _moveDrag;
  37328. private _pickWithRayOnDragPlane;
  37329. private _pointA;
  37330. private _pointB;
  37331. private _pointC;
  37332. private _lineA;
  37333. private _lineB;
  37334. private _localAxis;
  37335. private _lookAt;
  37336. private _updateDragPlanePosition;
  37337. /**
  37338. * Detaches the behavior from the mesh
  37339. */
  37340. detach(): void;
  37341. }
  37342. }
  37343. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  37344. import { Mesh } from "babylonjs/Meshes/mesh";
  37345. import { Behavior } from "babylonjs/Behaviors/behavior";
  37346. /**
  37347. * A behavior that when attached to a mesh will allow the mesh to be scaled
  37348. */
  37349. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  37350. private _dragBehaviorA;
  37351. private _dragBehaviorB;
  37352. private _startDistance;
  37353. private _initialScale;
  37354. private _targetScale;
  37355. private _ownerNode;
  37356. private _sceneRenderObserver;
  37357. /**
  37358. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  37359. */
  37360. constructor();
  37361. /**
  37362. * The name of the behavior
  37363. */
  37364. readonly name: string;
  37365. /**
  37366. * Initializes the behavior
  37367. */
  37368. init(): void;
  37369. private _getCurrentDistance;
  37370. /**
  37371. * Attaches the scale behavior the passed in mesh
  37372. * @param ownerNode The mesh that will be scaled around once attached
  37373. */
  37374. attach(ownerNode: Mesh): void;
  37375. /**
  37376. * Detaches the behavior from the mesh
  37377. */
  37378. detach(): void;
  37379. }
  37380. }
  37381. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  37382. import { Behavior } from "babylonjs/Behaviors/behavior";
  37383. import { Mesh } from "babylonjs/Meshes/mesh";
  37384. import { Observable } from "babylonjs/Misc/observable";
  37385. /**
  37386. * 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
  37387. */
  37388. export class SixDofDragBehavior implements Behavior<Mesh> {
  37389. private static _virtualScene;
  37390. private _ownerNode;
  37391. private _sceneRenderObserver;
  37392. private _scene;
  37393. private _targetPosition;
  37394. private _virtualOriginMesh;
  37395. private _virtualDragMesh;
  37396. private _pointerObserver;
  37397. private _moving;
  37398. private _startingOrientation;
  37399. /**
  37400. * 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)
  37401. */
  37402. private zDragFactor;
  37403. /**
  37404. * If the object should rotate to face the drag origin
  37405. */
  37406. rotateDraggedObject: boolean;
  37407. /**
  37408. * If the behavior is currently in a dragging state
  37409. */
  37410. dragging: boolean;
  37411. /**
  37412. * 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)
  37413. */
  37414. dragDeltaRatio: number;
  37415. /**
  37416. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37417. */
  37418. currentDraggingPointerID: number;
  37419. /**
  37420. * If camera controls should be detached during the drag
  37421. */
  37422. detachCameraControls: boolean;
  37423. /**
  37424. * Fires each time a drag starts
  37425. */
  37426. onDragStartObservable: Observable<{}>;
  37427. /**
  37428. * Fires each time a drag ends (eg. mouse release after drag)
  37429. */
  37430. onDragEndObservable: Observable<{}>;
  37431. /**
  37432. * 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
  37433. */
  37434. constructor();
  37435. /**
  37436. * The name of the behavior
  37437. */
  37438. readonly name: string;
  37439. /**
  37440. * Initializes the behavior
  37441. */
  37442. init(): void;
  37443. /**
  37444. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  37445. */
  37446. private readonly _pointerCamera;
  37447. /**
  37448. * Attaches the scale behavior the passed in mesh
  37449. * @param ownerNode The mesh that will be scaled around once attached
  37450. */
  37451. attach(ownerNode: Mesh): void;
  37452. /**
  37453. * Detaches the behavior from the mesh
  37454. */
  37455. detach(): void;
  37456. }
  37457. }
  37458. declare module "babylonjs/Behaviors/Meshes/index" {
  37459. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37460. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37461. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37462. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37463. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37464. }
  37465. declare module "babylonjs/Behaviors/index" {
  37466. export * from "babylonjs/Behaviors/behavior";
  37467. export * from "babylonjs/Behaviors/Cameras/index";
  37468. export * from "babylonjs/Behaviors/Meshes/index";
  37469. }
  37470. declare module "babylonjs/Bones/boneIKController" {
  37471. import { Bone } from "babylonjs/Bones/bone";
  37472. import { Vector3 } from "babylonjs/Maths/math";
  37473. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37474. import { Nullable } from "babylonjs/types";
  37475. /**
  37476. * Class used to apply inverse kinematics to bones
  37477. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37478. */
  37479. export class BoneIKController {
  37480. private static _tmpVecs;
  37481. private static _tmpQuat;
  37482. private static _tmpMats;
  37483. /**
  37484. * Gets or sets the target mesh
  37485. */
  37486. targetMesh: AbstractMesh;
  37487. /** Gets or sets the mesh used as pole */
  37488. poleTargetMesh: AbstractMesh;
  37489. /**
  37490. * Gets or sets the bone used as pole
  37491. */
  37492. poleTargetBone: Nullable<Bone>;
  37493. /**
  37494. * Gets or sets the target position
  37495. */
  37496. targetPosition: Vector3;
  37497. /**
  37498. * Gets or sets the pole target position
  37499. */
  37500. poleTargetPosition: Vector3;
  37501. /**
  37502. * Gets or sets the pole target local offset
  37503. */
  37504. poleTargetLocalOffset: Vector3;
  37505. /**
  37506. * Gets or sets the pole angle
  37507. */
  37508. poleAngle: number;
  37509. /**
  37510. * Gets or sets the mesh associated with the controller
  37511. */
  37512. mesh: AbstractMesh;
  37513. /**
  37514. * 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)
  37515. */
  37516. slerpAmount: number;
  37517. private _bone1Quat;
  37518. private _bone1Mat;
  37519. private _bone2Ang;
  37520. private _bone1;
  37521. private _bone2;
  37522. private _bone1Length;
  37523. private _bone2Length;
  37524. private _maxAngle;
  37525. private _maxReach;
  37526. private _rightHandedSystem;
  37527. private _bendAxis;
  37528. private _slerping;
  37529. private _adjustRoll;
  37530. /**
  37531. * Gets or sets maximum allowed angle
  37532. */
  37533. maxAngle: number;
  37534. /**
  37535. * Creates a new BoneIKController
  37536. * @param mesh defines the mesh to control
  37537. * @param bone defines the bone to control
  37538. * @param options defines options to set up the controller
  37539. */
  37540. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37541. targetMesh?: AbstractMesh;
  37542. poleTargetMesh?: AbstractMesh;
  37543. poleTargetBone?: Bone;
  37544. poleTargetLocalOffset?: Vector3;
  37545. poleAngle?: number;
  37546. bendAxis?: Vector3;
  37547. maxAngle?: number;
  37548. slerpAmount?: number;
  37549. });
  37550. private _setMaxAngle;
  37551. /**
  37552. * Force the controller to update the bones
  37553. */
  37554. update(): void;
  37555. }
  37556. }
  37557. declare module "babylonjs/Bones/boneLookController" {
  37558. import { Vector3, Space } from "babylonjs/Maths/math";
  37559. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37560. import { Bone } from "babylonjs/Bones/bone";
  37561. /**
  37562. * Class used to make a bone look toward a point in space
  37563. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37564. */
  37565. export class BoneLookController {
  37566. private static _tmpVecs;
  37567. private static _tmpQuat;
  37568. private static _tmpMats;
  37569. /**
  37570. * The target Vector3 that the bone will look at
  37571. */
  37572. target: Vector3;
  37573. /**
  37574. * The mesh that the bone is attached to
  37575. */
  37576. mesh: AbstractMesh;
  37577. /**
  37578. * The bone that will be looking to the target
  37579. */
  37580. bone: Bone;
  37581. /**
  37582. * The up axis of the coordinate system that is used when the bone is rotated
  37583. */
  37584. upAxis: Vector3;
  37585. /**
  37586. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37587. */
  37588. upAxisSpace: Space;
  37589. /**
  37590. * Used to make an adjustment to the yaw of the bone
  37591. */
  37592. adjustYaw: number;
  37593. /**
  37594. * Used to make an adjustment to the pitch of the bone
  37595. */
  37596. adjustPitch: number;
  37597. /**
  37598. * Used to make an adjustment to the roll of the bone
  37599. */
  37600. adjustRoll: number;
  37601. /**
  37602. * 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)
  37603. */
  37604. slerpAmount: number;
  37605. private _minYaw;
  37606. private _maxYaw;
  37607. private _minPitch;
  37608. private _maxPitch;
  37609. private _minYawSin;
  37610. private _minYawCos;
  37611. private _maxYawSin;
  37612. private _maxYawCos;
  37613. private _midYawConstraint;
  37614. private _minPitchTan;
  37615. private _maxPitchTan;
  37616. private _boneQuat;
  37617. private _slerping;
  37618. private _transformYawPitch;
  37619. private _transformYawPitchInv;
  37620. private _firstFrameSkipped;
  37621. private _yawRange;
  37622. private _fowardAxis;
  37623. /**
  37624. * Gets or sets the minimum yaw angle that the bone can look to
  37625. */
  37626. minYaw: number;
  37627. /**
  37628. * Gets or sets the maximum yaw angle that the bone can look to
  37629. */
  37630. maxYaw: number;
  37631. /**
  37632. * Gets or sets the minimum pitch angle that the bone can look to
  37633. */
  37634. minPitch: number;
  37635. /**
  37636. * Gets or sets the maximum pitch angle that the bone can look to
  37637. */
  37638. maxPitch: number;
  37639. /**
  37640. * Create a BoneLookController
  37641. * @param mesh the mesh that the bone belongs to
  37642. * @param bone the bone that will be looking to the target
  37643. * @param target the target Vector3 to look at
  37644. * @param options optional settings:
  37645. * * maxYaw: the maximum angle the bone will yaw to
  37646. * * minYaw: the minimum angle the bone will yaw to
  37647. * * maxPitch: the maximum angle the bone will pitch to
  37648. * * minPitch: the minimum angle the bone will yaw to
  37649. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37650. * * upAxis: the up axis of the coordinate system
  37651. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37652. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37653. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37654. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37655. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37656. * * adjustRoll: used to make an adjustment to the roll of the bone
  37657. **/
  37658. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37659. maxYaw?: number;
  37660. minYaw?: number;
  37661. maxPitch?: number;
  37662. minPitch?: number;
  37663. slerpAmount?: number;
  37664. upAxis?: Vector3;
  37665. upAxisSpace?: Space;
  37666. yawAxis?: Vector3;
  37667. pitchAxis?: Vector3;
  37668. adjustYaw?: number;
  37669. adjustPitch?: number;
  37670. adjustRoll?: number;
  37671. });
  37672. /**
  37673. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37674. */
  37675. update(): void;
  37676. private _getAngleDiff;
  37677. private _getAngleBetween;
  37678. private _isAngleBetween;
  37679. }
  37680. }
  37681. declare module "babylonjs/Bones/index" {
  37682. export * from "babylonjs/Bones/bone";
  37683. export * from "babylonjs/Bones/boneIKController";
  37684. export * from "babylonjs/Bones/boneLookController";
  37685. export * from "babylonjs/Bones/skeleton";
  37686. }
  37687. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  37688. import { Nullable } from "babylonjs/types";
  37689. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37690. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37691. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37692. /**
  37693. * Manage the gamepad inputs to control an arc rotate camera.
  37694. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37695. */
  37696. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37697. /**
  37698. * Defines the camera the input is attached to.
  37699. */
  37700. camera: ArcRotateCamera;
  37701. /**
  37702. * Defines the gamepad the input is gathering event from.
  37703. */
  37704. gamepad: Nullable<Gamepad>;
  37705. /**
  37706. * Defines the gamepad rotation sensiblity.
  37707. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37708. */
  37709. gamepadRotationSensibility: number;
  37710. /**
  37711. * Defines the gamepad move sensiblity.
  37712. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37713. */
  37714. gamepadMoveSensibility: number;
  37715. private _onGamepadConnectedObserver;
  37716. private _onGamepadDisconnectedObserver;
  37717. /**
  37718. * Attach the input controls to a specific dom element to get the input from.
  37719. * @param element Defines the element the controls should be listened from
  37720. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37721. */
  37722. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37723. /**
  37724. * Detach the current controls from the specified dom element.
  37725. * @param element Defines the element to stop listening the inputs from
  37726. */
  37727. detachControl(element: Nullable<HTMLElement>): void;
  37728. /**
  37729. * Update the current camera state depending on the inputs that have been used this frame.
  37730. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37731. */
  37732. checkInputs(): void;
  37733. /**
  37734. * Gets the class name of the current intput.
  37735. * @returns the class name
  37736. */
  37737. getClassName(): string;
  37738. /**
  37739. * Get the friendly name associated with the input class.
  37740. * @returns the input friendly name
  37741. */
  37742. getSimpleName(): string;
  37743. }
  37744. }
  37745. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  37746. import { Nullable } from "babylonjs/types";
  37747. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37748. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37749. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37750. interface ArcRotateCameraInputsManager {
  37751. /**
  37752. * Add orientation input support to the input manager.
  37753. * @returns the current input manager
  37754. */
  37755. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37756. }
  37757. }
  37758. /**
  37759. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37760. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37761. */
  37762. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37763. /**
  37764. * Defines the camera the input is attached to.
  37765. */
  37766. camera: ArcRotateCamera;
  37767. /**
  37768. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37769. */
  37770. alphaCorrection: number;
  37771. /**
  37772. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37773. */
  37774. gammaCorrection: number;
  37775. private _alpha;
  37776. private _gamma;
  37777. private _dirty;
  37778. private _deviceOrientationHandler;
  37779. /**
  37780. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37781. */
  37782. constructor();
  37783. /**
  37784. * Attach the input controls to a specific dom element to get the input from.
  37785. * @param element Defines the element the controls should be listened from
  37786. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37787. */
  37788. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37789. /** @hidden */
  37790. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37791. /**
  37792. * Update the current camera state depending on the inputs that have been used this frame.
  37793. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37794. */
  37795. checkInputs(): void;
  37796. /**
  37797. * Detach the current controls from the specified dom element.
  37798. * @param element Defines the element to stop listening the inputs from
  37799. */
  37800. detachControl(element: Nullable<HTMLElement>): void;
  37801. /**
  37802. * Gets the class name of the current intput.
  37803. * @returns the class name
  37804. */
  37805. getClassName(): string;
  37806. /**
  37807. * Get the friendly name associated with the input class.
  37808. * @returns the input friendly name
  37809. */
  37810. getSimpleName(): string;
  37811. }
  37812. }
  37813. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37814. import { Nullable } from "babylonjs/types";
  37815. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37816. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37817. /**
  37818. * Listen to mouse events to control the camera.
  37819. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37820. */
  37821. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37822. /**
  37823. * Defines the camera the input is attached to.
  37824. */
  37825. camera: FlyCamera;
  37826. /**
  37827. * Defines if touch is enabled. (Default is true.)
  37828. */
  37829. touchEnabled: boolean;
  37830. /**
  37831. * Defines the buttons associated with the input to handle camera rotation.
  37832. */
  37833. buttons: number[];
  37834. /**
  37835. * Assign buttons for Yaw control.
  37836. */
  37837. buttonsYaw: number[];
  37838. /**
  37839. * Assign buttons for Pitch control.
  37840. */
  37841. buttonsPitch: number[];
  37842. /**
  37843. * Assign buttons for Roll control.
  37844. */
  37845. buttonsRoll: number[];
  37846. /**
  37847. * Detect if any button is being pressed while mouse is moved.
  37848. * -1 = Mouse locked.
  37849. * 0 = Left button.
  37850. * 1 = Middle Button.
  37851. * 2 = Right Button.
  37852. */
  37853. activeButton: number;
  37854. /**
  37855. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37856. * Higher values reduce its sensitivity.
  37857. */
  37858. angularSensibility: number;
  37859. private _mousemoveCallback;
  37860. private _observer;
  37861. private _rollObserver;
  37862. private previousPosition;
  37863. private noPreventDefault;
  37864. private element;
  37865. /**
  37866. * Listen to mouse events to control the camera.
  37867. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37868. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37869. */
  37870. constructor(touchEnabled?: boolean);
  37871. /**
  37872. * Attach the mouse control to the HTML DOM element.
  37873. * @param element Defines the element that listens to the input events.
  37874. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37875. */
  37876. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37877. /**
  37878. * Detach the current controls from the specified dom element.
  37879. * @param element Defines the element to stop listening the inputs from
  37880. */
  37881. detachControl(element: Nullable<HTMLElement>): void;
  37882. /**
  37883. * Gets the class name of the current input.
  37884. * @returns the class name.
  37885. */
  37886. getClassName(): string;
  37887. /**
  37888. * Get the friendly name associated with the input class.
  37889. * @returns the input's friendly name.
  37890. */
  37891. getSimpleName(): string;
  37892. private _pointerInput;
  37893. private _onMouseMove;
  37894. /**
  37895. * Rotate camera by mouse offset.
  37896. */
  37897. private rotateCamera;
  37898. }
  37899. }
  37900. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37901. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37902. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37903. /**
  37904. * Default Inputs manager for the FlyCamera.
  37905. * It groups all the default supported inputs for ease of use.
  37906. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37907. */
  37908. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37909. /**
  37910. * Instantiates a new FlyCameraInputsManager.
  37911. * @param camera Defines the camera the inputs belong to.
  37912. */
  37913. constructor(camera: FlyCamera);
  37914. /**
  37915. * Add keyboard input support to the input manager.
  37916. * @returns the new FlyCameraKeyboardMoveInput().
  37917. */
  37918. addKeyboard(): FlyCameraInputsManager;
  37919. /**
  37920. * Add mouse input support to the input manager.
  37921. * @param touchEnabled Enable touch screen support.
  37922. * @returns the new FlyCameraMouseInput().
  37923. */
  37924. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37925. }
  37926. }
  37927. declare module "babylonjs/Cameras/flyCamera" {
  37928. import { Scene } from "babylonjs/scene";
  37929. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37930. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37931. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37932. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37933. /**
  37934. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37935. * such as in a 3D Space Shooter or a Flight Simulator.
  37936. */
  37937. export class FlyCamera extends TargetCamera {
  37938. /**
  37939. * Define the collision ellipsoid of the camera.
  37940. * This is helpful for simulating a camera body, like a player's body.
  37941. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37942. */
  37943. ellipsoid: Vector3;
  37944. /**
  37945. * Define an offset for the position of the ellipsoid around the camera.
  37946. * This can be helpful if the camera is attached away from the player's body center,
  37947. * such as at its head.
  37948. */
  37949. ellipsoidOffset: Vector3;
  37950. /**
  37951. * Enable or disable collisions of the camera with the rest of the scene objects.
  37952. */
  37953. checkCollisions: boolean;
  37954. /**
  37955. * Enable or disable gravity on the camera.
  37956. */
  37957. applyGravity: boolean;
  37958. /**
  37959. * Define the current direction the camera is moving to.
  37960. */
  37961. cameraDirection: Vector3;
  37962. /**
  37963. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37964. * This overrides and empties cameraRotation.
  37965. */
  37966. rotationQuaternion: Quaternion;
  37967. /**
  37968. * Track Roll to maintain the wanted Rolling when looking around.
  37969. */
  37970. _trackRoll: number;
  37971. /**
  37972. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37973. */
  37974. rollCorrect: number;
  37975. /**
  37976. * Mimic a banked turn, Rolling the camera when Yawing.
  37977. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37978. */
  37979. bankedTurn: boolean;
  37980. /**
  37981. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37982. */
  37983. bankedTurnLimit: number;
  37984. /**
  37985. * Value of 0 disables the banked Roll.
  37986. * Value of 1 is equal to the Yaw angle in radians.
  37987. */
  37988. bankedTurnMultiplier: number;
  37989. /**
  37990. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37991. */
  37992. inputs: FlyCameraInputsManager;
  37993. /**
  37994. * Gets the input sensibility for mouse input.
  37995. * Higher values reduce sensitivity.
  37996. */
  37997. /**
  37998. * Sets the input sensibility for a mouse input.
  37999. * Higher values reduce sensitivity.
  38000. */
  38001. angularSensibility: number;
  38002. /**
  38003. * Get the keys for camera movement forward.
  38004. */
  38005. /**
  38006. * Set the keys for camera movement forward.
  38007. */
  38008. keysForward: number[];
  38009. /**
  38010. * Get the keys for camera movement backward.
  38011. */
  38012. keysBackward: number[];
  38013. /**
  38014. * Get the keys for camera movement up.
  38015. */
  38016. /**
  38017. * Set the keys for camera movement up.
  38018. */
  38019. keysUp: number[];
  38020. /**
  38021. * Get the keys for camera movement down.
  38022. */
  38023. /**
  38024. * Set the keys for camera movement down.
  38025. */
  38026. keysDown: number[];
  38027. /**
  38028. * Get the keys for camera movement left.
  38029. */
  38030. /**
  38031. * Set the keys for camera movement left.
  38032. */
  38033. keysLeft: number[];
  38034. /**
  38035. * Set the keys for camera movement right.
  38036. */
  38037. /**
  38038. * Set the keys for camera movement right.
  38039. */
  38040. keysRight: number[];
  38041. /**
  38042. * Event raised when the camera collides with a mesh in the scene.
  38043. */
  38044. onCollide: (collidedMesh: AbstractMesh) => void;
  38045. private _collider;
  38046. private _needMoveForGravity;
  38047. private _oldPosition;
  38048. private _diffPosition;
  38049. private _newPosition;
  38050. /** @hidden */
  38051. _localDirection: Vector3;
  38052. /** @hidden */
  38053. _transformedDirection: Vector3;
  38054. /**
  38055. * Instantiates a FlyCamera.
  38056. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38057. * such as in a 3D Space Shooter or a Flight Simulator.
  38058. * @param name Define the name of the camera in the scene.
  38059. * @param position Define the starting position of the camera in the scene.
  38060. * @param scene Define the scene the camera belongs to.
  38061. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38062. */
  38063. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38064. /**
  38065. * Attach a control to the HTML DOM element.
  38066. * @param element Defines the element that listens to the input events.
  38067. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38068. */
  38069. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38070. /**
  38071. * Detach a control from the HTML DOM element.
  38072. * The camera will stop reacting to that input.
  38073. * @param element Defines the element that listens to the input events.
  38074. */
  38075. detachControl(element: HTMLElement): void;
  38076. private _collisionMask;
  38077. /**
  38078. * Get the mask that the camera ignores in collision events.
  38079. */
  38080. /**
  38081. * Set the mask that the camera ignores in collision events.
  38082. */
  38083. collisionMask: number;
  38084. /** @hidden */
  38085. _collideWithWorld(displacement: Vector3): void;
  38086. /** @hidden */
  38087. private _onCollisionPositionChange;
  38088. /** @hidden */
  38089. _checkInputs(): void;
  38090. /** @hidden */
  38091. _decideIfNeedsToMove(): boolean;
  38092. /** @hidden */
  38093. _updatePosition(): void;
  38094. /**
  38095. * Restore the Roll to its target value at the rate specified.
  38096. * @param rate - Higher means slower restoring.
  38097. * @hidden
  38098. */
  38099. restoreRoll(rate: number): void;
  38100. /**
  38101. * Destroy the camera and release the current resources held by it.
  38102. */
  38103. dispose(): void;
  38104. /**
  38105. * Get the current object class name.
  38106. * @returns the class name.
  38107. */
  38108. getClassName(): string;
  38109. }
  38110. }
  38111. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38112. import { Nullable } from "babylonjs/types";
  38113. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38114. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38115. /**
  38116. * Listen to keyboard events to control the camera.
  38117. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38118. */
  38119. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38120. /**
  38121. * Defines the camera the input is attached to.
  38122. */
  38123. camera: FlyCamera;
  38124. /**
  38125. * The list of keyboard keys used to control the forward move of the camera.
  38126. */
  38127. keysForward: number[];
  38128. /**
  38129. * The list of keyboard keys used to control the backward move of the camera.
  38130. */
  38131. keysBackward: number[];
  38132. /**
  38133. * The list of keyboard keys used to control the forward move of the camera.
  38134. */
  38135. keysUp: number[];
  38136. /**
  38137. * The list of keyboard keys used to control the backward move of the camera.
  38138. */
  38139. keysDown: number[];
  38140. /**
  38141. * The list of keyboard keys used to control the right strafe move of the camera.
  38142. */
  38143. keysRight: number[];
  38144. /**
  38145. * The list of keyboard keys used to control the left strafe move of the camera.
  38146. */
  38147. keysLeft: number[];
  38148. private _keys;
  38149. private _onCanvasBlurObserver;
  38150. private _onKeyboardObserver;
  38151. private _engine;
  38152. private _scene;
  38153. /**
  38154. * Attach the input controls to a specific dom element to get the input from.
  38155. * @param element Defines the element the controls should be listened from
  38156. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38157. */
  38158. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38159. /**
  38160. * Detach the current controls from the specified dom element.
  38161. * @param element Defines the element to stop listening the inputs from
  38162. */
  38163. detachControl(element: Nullable<HTMLElement>): void;
  38164. /**
  38165. * Gets the class name of the current intput.
  38166. * @returns the class name
  38167. */
  38168. getClassName(): string;
  38169. /** @hidden */
  38170. _onLostFocus(e: FocusEvent): void;
  38171. /**
  38172. * Get the friendly name associated with the input class.
  38173. * @returns the input friendly name
  38174. */
  38175. getSimpleName(): string;
  38176. /**
  38177. * Update the current camera state depending on the inputs that have been used this frame.
  38178. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38179. */
  38180. checkInputs(): void;
  38181. }
  38182. }
  38183. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38184. import { Nullable } from "babylonjs/types";
  38185. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38186. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38187. /**
  38188. * Manage the mouse wheel inputs to control a follow camera.
  38189. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38190. */
  38191. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38192. /**
  38193. * Defines the camera the input is attached to.
  38194. */
  38195. camera: FollowCamera;
  38196. /**
  38197. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38198. */
  38199. axisControlRadius: boolean;
  38200. /**
  38201. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38202. */
  38203. axisControlHeight: boolean;
  38204. /**
  38205. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38206. */
  38207. axisControlRotation: boolean;
  38208. /**
  38209. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38210. * relation to mouseWheel events.
  38211. */
  38212. wheelPrecision: number;
  38213. /**
  38214. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38215. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38216. */
  38217. wheelDeltaPercentage: number;
  38218. private _wheel;
  38219. private _observer;
  38220. /**
  38221. * Attach the input controls to a specific dom element to get the input from.
  38222. * @param element Defines the element the controls should be listened from
  38223. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38224. */
  38225. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38226. /**
  38227. * Detach the current controls from the specified dom element.
  38228. * @param element Defines the element to stop listening the inputs from
  38229. */
  38230. detachControl(element: Nullable<HTMLElement>): void;
  38231. /**
  38232. * Gets the class name of the current intput.
  38233. * @returns the class name
  38234. */
  38235. getClassName(): string;
  38236. /**
  38237. * Get the friendly name associated with the input class.
  38238. * @returns the input friendly name
  38239. */
  38240. getSimpleName(): string;
  38241. }
  38242. }
  38243. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  38244. import { Nullable } from "babylonjs/types";
  38245. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38246. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  38247. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  38248. /**
  38249. * Manage the pointers inputs to control an follow camera.
  38250. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38251. */
  38252. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  38253. /**
  38254. * Defines the camera the input is attached to.
  38255. */
  38256. camera: FollowCamera;
  38257. /**
  38258. * Gets the class name of the current input.
  38259. * @returns the class name
  38260. */
  38261. getClassName(): string;
  38262. /**
  38263. * Defines the pointer angular sensibility along the X axis or how fast is
  38264. * the camera rotating.
  38265. * A negative number will reverse the axis direction.
  38266. */
  38267. angularSensibilityX: number;
  38268. /**
  38269. * Defines the pointer angular sensibility along the Y axis or how fast is
  38270. * the camera rotating.
  38271. * A negative number will reverse the axis direction.
  38272. */
  38273. angularSensibilityY: number;
  38274. /**
  38275. * Defines the pointer pinch precision or how fast is the camera zooming.
  38276. * A negative number will reverse the axis direction.
  38277. */
  38278. pinchPrecision: number;
  38279. /**
  38280. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38281. * from 0.
  38282. * It defines the percentage of current camera.radius to use as delta when
  38283. * pinch zoom is used.
  38284. */
  38285. pinchDeltaPercentage: number;
  38286. /**
  38287. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  38288. */
  38289. axisXControlRadius: boolean;
  38290. /**
  38291. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  38292. */
  38293. axisXControlHeight: boolean;
  38294. /**
  38295. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  38296. */
  38297. axisXControlRotation: boolean;
  38298. /**
  38299. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  38300. */
  38301. axisYControlRadius: boolean;
  38302. /**
  38303. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  38304. */
  38305. axisYControlHeight: boolean;
  38306. /**
  38307. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  38308. */
  38309. axisYControlRotation: boolean;
  38310. /**
  38311. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  38312. */
  38313. axisPinchControlRadius: boolean;
  38314. /**
  38315. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  38316. */
  38317. axisPinchControlHeight: boolean;
  38318. /**
  38319. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  38320. */
  38321. axisPinchControlRotation: boolean;
  38322. /**
  38323. * Log error messages if basic misconfiguration has occurred.
  38324. */
  38325. warningEnable: boolean;
  38326. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38327. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38328. private _warningCounter;
  38329. private _warning;
  38330. }
  38331. }
  38332. declare module "babylonjs/Cameras/followCameraInputsManager" {
  38333. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38334. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38335. /**
  38336. * Default Inputs manager for the FollowCamera.
  38337. * It groups all the default supported inputs for ease of use.
  38338. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38339. */
  38340. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  38341. /**
  38342. * Instantiates a new FollowCameraInputsManager.
  38343. * @param camera Defines the camera the inputs belong to
  38344. */
  38345. constructor(camera: FollowCamera);
  38346. /**
  38347. * Add keyboard input support to the input manager.
  38348. * @returns the current input manager
  38349. */
  38350. addKeyboard(): FollowCameraInputsManager;
  38351. /**
  38352. * Add mouse wheel input support to the input manager.
  38353. * @returns the current input manager
  38354. */
  38355. addMouseWheel(): FollowCameraInputsManager;
  38356. /**
  38357. * Add pointers input support to the input manager.
  38358. * @returns the current input manager
  38359. */
  38360. addPointers(): FollowCameraInputsManager;
  38361. /**
  38362. * Add orientation input support to the input manager.
  38363. * @returns the current input manager
  38364. */
  38365. addVRDeviceOrientation(): FollowCameraInputsManager;
  38366. }
  38367. }
  38368. declare module "babylonjs/Cameras/followCamera" {
  38369. import { Nullable } from "babylonjs/types";
  38370. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38371. import { Scene } from "babylonjs/scene";
  38372. import { Vector3 } from "babylonjs/Maths/math";
  38373. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38374. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  38375. /**
  38376. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  38377. * an arc rotate version arcFollowCamera are available.
  38378. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38379. */
  38380. export class FollowCamera extends TargetCamera {
  38381. /**
  38382. * Distance the follow camera should follow an object at
  38383. */
  38384. radius: number;
  38385. /**
  38386. * Minimum allowed distance of the camera to the axis of rotation
  38387. * (The camera can not get closer).
  38388. * This can help limiting how the Camera is able to move in the scene.
  38389. */
  38390. lowerRadiusLimit: Nullable<number>;
  38391. /**
  38392. * Maximum allowed distance of the camera to the axis of rotation
  38393. * (The camera can not get further).
  38394. * This can help limiting how the Camera is able to move in the scene.
  38395. */
  38396. upperRadiusLimit: Nullable<number>;
  38397. /**
  38398. * Define a rotation offset between the camera and the object it follows
  38399. */
  38400. rotationOffset: number;
  38401. /**
  38402. * Minimum allowed angle to camera position relative to target object.
  38403. * This can help limiting how the Camera is able to move in the scene.
  38404. */
  38405. lowerRotationOffsetLimit: Nullable<number>;
  38406. /**
  38407. * Maximum allowed angle to camera position relative to target object.
  38408. * This can help limiting how the Camera is able to move in the scene.
  38409. */
  38410. upperRotationOffsetLimit: Nullable<number>;
  38411. /**
  38412. * Define a height offset between the camera and the object it follows.
  38413. * It can help following an object from the top (like a car chaing a plane)
  38414. */
  38415. heightOffset: number;
  38416. /**
  38417. * Minimum allowed height of camera position relative to target object.
  38418. * This can help limiting how the Camera is able to move in the scene.
  38419. */
  38420. lowerHeightOffsetLimit: Nullable<number>;
  38421. /**
  38422. * Maximum allowed height of camera position relative to target object.
  38423. * This can help limiting how the Camera is able to move in the scene.
  38424. */
  38425. upperHeightOffsetLimit: Nullable<number>;
  38426. /**
  38427. * Define how fast the camera can accelerate to follow it s target.
  38428. */
  38429. cameraAcceleration: number;
  38430. /**
  38431. * Define the speed limit of the camera following an object.
  38432. */
  38433. maxCameraSpeed: number;
  38434. /**
  38435. * Define the target of the camera.
  38436. */
  38437. lockedTarget: Nullable<AbstractMesh>;
  38438. /**
  38439. * Defines the input associated with the camera.
  38440. */
  38441. inputs: FollowCameraInputsManager;
  38442. /**
  38443. * Instantiates the follow camera.
  38444. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38445. * @param name Define the name of the camera in the scene
  38446. * @param position Define the position of the camera
  38447. * @param scene Define the scene the camera belong to
  38448. * @param lockedTarget Define the target of the camera
  38449. */
  38450. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38451. private _follow;
  38452. /**
  38453. * Attached controls to the current camera.
  38454. * @param element Defines the element the controls should be listened from
  38455. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38456. */
  38457. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38458. /**
  38459. * Detach the current controls from the camera.
  38460. * The camera will stop reacting to inputs.
  38461. * @param element Defines the element to stop listening the inputs from
  38462. */
  38463. detachControl(element: HTMLElement): void;
  38464. /** @hidden */
  38465. _checkInputs(): void;
  38466. private _checkLimits;
  38467. /**
  38468. * Gets the camera class name.
  38469. * @returns the class name
  38470. */
  38471. getClassName(): string;
  38472. }
  38473. /**
  38474. * Arc Rotate version of the follow camera.
  38475. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38476. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38477. */
  38478. export class ArcFollowCamera extends TargetCamera {
  38479. /** The longitudinal angle of the camera */
  38480. alpha: number;
  38481. /** The latitudinal angle of the camera */
  38482. beta: number;
  38483. /** The radius of the camera from its target */
  38484. radius: number;
  38485. /** Define the camera target (the messh it should follow) */
  38486. target: Nullable<AbstractMesh>;
  38487. private _cartesianCoordinates;
  38488. /**
  38489. * Instantiates a new ArcFollowCamera
  38490. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38491. * @param name Define the name of the camera
  38492. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38493. * @param beta Define the rotation angle of the camera around the elevation axis
  38494. * @param radius Define the radius of the camera from its target point
  38495. * @param target Define the target of the camera
  38496. * @param scene Define the scene the camera belongs to
  38497. */
  38498. constructor(name: string,
  38499. /** The longitudinal angle of the camera */
  38500. alpha: number,
  38501. /** The latitudinal angle of the camera */
  38502. beta: number,
  38503. /** The radius of the camera from its target */
  38504. radius: number,
  38505. /** Define the camera target (the messh it should follow) */
  38506. target: Nullable<AbstractMesh>, scene: Scene);
  38507. private _follow;
  38508. /** @hidden */
  38509. _checkInputs(): void;
  38510. /**
  38511. * Returns the class name of the object.
  38512. * It is mostly used internally for serialization purposes.
  38513. */
  38514. getClassName(): string;
  38515. }
  38516. }
  38517. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38518. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38519. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38520. import { Nullable } from "babylonjs/types";
  38521. /**
  38522. * Manage the keyboard inputs to control the movement of a follow camera.
  38523. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38524. */
  38525. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38526. /**
  38527. * Defines the camera the input is attached to.
  38528. */
  38529. camera: FollowCamera;
  38530. /**
  38531. * Defines the list of key codes associated with the up action (increase heightOffset)
  38532. */
  38533. keysHeightOffsetIncr: number[];
  38534. /**
  38535. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38536. */
  38537. keysHeightOffsetDecr: number[];
  38538. /**
  38539. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38540. */
  38541. keysHeightOffsetModifierAlt: boolean;
  38542. /**
  38543. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38544. */
  38545. keysHeightOffsetModifierCtrl: boolean;
  38546. /**
  38547. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38548. */
  38549. keysHeightOffsetModifierShift: boolean;
  38550. /**
  38551. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38552. */
  38553. keysRotationOffsetIncr: number[];
  38554. /**
  38555. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38556. */
  38557. keysRotationOffsetDecr: number[];
  38558. /**
  38559. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38560. */
  38561. keysRotationOffsetModifierAlt: boolean;
  38562. /**
  38563. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38564. */
  38565. keysRotationOffsetModifierCtrl: boolean;
  38566. /**
  38567. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38568. */
  38569. keysRotationOffsetModifierShift: boolean;
  38570. /**
  38571. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38572. */
  38573. keysRadiusIncr: number[];
  38574. /**
  38575. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38576. */
  38577. keysRadiusDecr: number[];
  38578. /**
  38579. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38580. */
  38581. keysRadiusModifierAlt: boolean;
  38582. /**
  38583. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38584. */
  38585. keysRadiusModifierCtrl: boolean;
  38586. /**
  38587. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38588. */
  38589. keysRadiusModifierShift: boolean;
  38590. /**
  38591. * Defines the rate of change of heightOffset.
  38592. */
  38593. heightSensibility: number;
  38594. /**
  38595. * Defines the rate of change of rotationOffset.
  38596. */
  38597. rotationSensibility: number;
  38598. /**
  38599. * Defines the rate of change of radius.
  38600. */
  38601. radiusSensibility: number;
  38602. private _keys;
  38603. private _ctrlPressed;
  38604. private _altPressed;
  38605. private _shiftPressed;
  38606. private _onCanvasBlurObserver;
  38607. private _onKeyboardObserver;
  38608. private _engine;
  38609. private _scene;
  38610. /**
  38611. * Attach the input controls to a specific dom element to get the input from.
  38612. * @param element Defines the element the controls should be listened from
  38613. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38614. */
  38615. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38616. /**
  38617. * Detach the current controls from the specified dom element.
  38618. * @param element Defines the element to stop listening the inputs from
  38619. */
  38620. detachControl(element: Nullable<HTMLElement>): void;
  38621. /**
  38622. * Update the current camera state depending on the inputs that have been used this frame.
  38623. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38624. */
  38625. checkInputs(): void;
  38626. /**
  38627. * Gets the class name of the current input.
  38628. * @returns the class name
  38629. */
  38630. getClassName(): string;
  38631. /**
  38632. * Get the friendly name associated with the input class.
  38633. * @returns the input friendly name
  38634. */
  38635. getSimpleName(): string;
  38636. /**
  38637. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38638. * allow modification of the heightOffset value.
  38639. */
  38640. private _modifierHeightOffset;
  38641. /**
  38642. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38643. * allow modification of the rotationOffset value.
  38644. */
  38645. private _modifierRotationOffset;
  38646. /**
  38647. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38648. * allow modification of the radius value.
  38649. */
  38650. private _modifierRadius;
  38651. }
  38652. }
  38653. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  38654. import { Nullable } from "babylonjs/types";
  38655. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38656. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38657. import { Observable } from "babylonjs/Misc/observable";
  38658. module "babylonjs/Cameras/freeCameraInputsManager" {
  38659. interface FreeCameraInputsManager {
  38660. /**
  38661. * @hidden
  38662. */
  38663. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38664. /**
  38665. * Add orientation input support to the input manager.
  38666. * @returns the current input manager
  38667. */
  38668. addDeviceOrientation(): FreeCameraInputsManager;
  38669. }
  38670. }
  38671. /**
  38672. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38673. * Screen rotation is taken into account.
  38674. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38675. */
  38676. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38677. private _camera;
  38678. private _screenOrientationAngle;
  38679. private _constantTranform;
  38680. private _screenQuaternion;
  38681. private _alpha;
  38682. private _beta;
  38683. private _gamma;
  38684. /**
  38685. * Can be used to detect if a device orientation sensor is availible on a device
  38686. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  38687. * @returns a promise that will resolve on orientation change
  38688. */
  38689. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  38690. /**
  38691. * @hidden
  38692. */
  38693. _onDeviceOrientationChangedObservable: Observable<void>;
  38694. /**
  38695. * Instantiates a new input
  38696. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38697. */
  38698. constructor();
  38699. /**
  38700. * Define the camera controlled by the input.
  38701. */
  38702. camera: FreeCamera;
  38703. /**
  38704. * Attach the input controls to a specific dom element to get the input from.
  38705. * @param element Defines the element the controls should be listened from
  38706. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38707. */
  38708. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38709. private _orientationChanged;
  38710. private _deviceOrientation;
  38711. /**
  38712. * Detach the current controls from the specified dom element.
  38713. * @param element Defines the element to stop listening the inputs from
  38714. */
  38715. detachControl(element: Nullable<HTMLElement>): void;
  38716. /**
  38717. * Update the current camera state depending on the inputs that have been used this frame.
  38718. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38719. */
  38720. checkInputs(): void;
  38721. /**
  38722. * Gets the class name of the current intput.
  38723. * @returns the class name
  38724. */
  38725. getClassName(): string;
  38726. /**
  38727. * Get the friendly name associated with the input class.
  38728. * @returns the input friendly name
  38729. */
  38730. getSimpleName(): string;
  38731. }
  38732. }
  38733. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  38734. import { Nullable } from "babylonjs/types";
  38735. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38736. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38737. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38738. /**
  38739. * Manage the gamepad inputs to control a free camera.
  38740. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38741. */
  38742. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38743. /**
  38744. * Define the camera the input is attached to.
  38745. */
  38746. camera: FreeCamera;
  38747. /**
  38748. * Define the Gamepad controlling the input
  38749. */
  38750. gamepad: Nullable<Gamepad>;
  38751. /**
  38752. * Defines the gamepad rotation sensiblity.
  38753. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38754. */
  38755. gamepadAngularSensibility: number;
  38756. /**
  38757. * Defines the gamepad move sensiblity.
  38758. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38759. */
  38760. gamepadMoveSensibility: number;
  38761. private _onGamepadConnectedObserver;
  38762. private _onGamepadDisconnectedObserver;
  38763. private _cameraTransform;
  38764. private _deltaTransform;
  38765. private _vector3;
  38766. private _vector2;
  38767. /**
  38768. * Attach the input controls to a specific dom element to get the input from.
  38769. * @param element Defines the element the controls should be listened from
  38770. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38771. */
  38772. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38773. /**
  38774. * Detach the current controls from the specified dom element.
  38775. * @param element Defines the element to stop listening the inputs from
  38776. */
  38777. detachControl(element: Nullable<HTMLElement>): void;
  38778. /**
  38779. * Update the current camera state depending on the inputs that have been used this frame.
  38780. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38781. */
  38782. checkInputs(): void;
  38783. /**
  38784. * Gets the class name of the current intput.
  38785. * @returns the class name
  38786. */
  38787. getClassName(): string;
  38788. /**
  38789. * Get the friendly name associated with the input class.
  38790. * @returns the input friendly name
  38791. */
  38792. getSimpleName(): string;
  38793. }
  38794. }
  38795. declare module "babylonjs/Misc/virtualJoystick" {
  38796. import { Nullable } from "babylonjs/types";
  38797. import { Vector3 } from "babylonjs/Maths/math";
  38798. /**
  38799. * Defines the potential axis of a Joystick
  38800. */
  38801. export enum JoystickAxis {
  38802. /** X axis */
  38803. X = 0,
  38804. /** Y axis */
  38805. Y = 1,
  38806. /** Z axis */
  38807. Z = 2
  38808. }
  38809. /**
  38810. * Class used to define virtual joystick (used in touch mode)
  38811. */
  38812. export class VirtualJoystick {
  38813. /**
  38814. * Gets or sets a boolean indicating that left and right values must be inverted
  38815. */
  38816. reverseLeftRight: boolean;
  38817. /**
  38818. * Gets or sets a boolean indicating that up and down values must be inverted
  38819. */
  38820. reverseUpDown: boolean;
  38821. /**
  38822. * Gets the offset value for the position (ie. the change of the position value)
  38823. */
  38824. deltaPosition: Vector3;
  38825. /**
  38826. * Gets a boolean indicating if the virtual joystick was pressed
  38827. */
  38828. pressed: boolean;
  38829. /**
  38830. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38831. */
  38832. static Canvas: Nullable<HTMLCanvasElement>;
  38833. private static _globalJoystickIndex;
  38834. private static vjCanvasContext;
  38835. private static vjCanvasWidth;
  38836. private static vjCanvasHeight;
  38837. private static halfWidth;
  38838. private _action;
  38839. private _axisTargetedByLeftAndRight;
  38840. private _axisTargetedByUpAndDown;
  38841. private _joystickSensibility;
  38842. private _inversedSensibility;
  38843. private _joystickPointerID;
  38844. private _joystickColor;
  38845. private _joystickPointerPos;
  38846. private _joystickPreviousPointerPos;
  38847. private _joystickPointerStartPos;
  38848. private _deltaJoystickVector;
  38849. private _leftJoystick;
  38850. private _touches;
  38851. private _onPointerDownHandlerRef;
  38852. private _onPointerMoveHandlerRef;
  38853. private _onPointerUpHandlerRef;
  38854. private _onResize;
  38855. /**
  38856. * Creates a new virtual joystick
  38857. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38858. */
  38859. constructor(leftJoystick?: boolean);
  38860. /**
  38861. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38862. * @param newJoystickSensibility defines the new sensibility
  38863. */
  38864. setJoystickSensibility(newJoystickSensibility: number): void;
  38865. private _onPointerDown;
  38866. private _onPointerMove;
  38867. private _onPointerUp;
  38868. /**
  38869. * Change the color of the virtual joystick
  38870. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38871. */
  38872. setJoystickColor(newColor: string): void;
  38873. /**
  38874. * Defines a callback to call when the joystick is touched
  38875. * @param action defines the callback
  38876. */
  38877. setActionOnTouch(action: () => any): void;
  38878. /**
  38879. * Defines which axis you'd like to control for left & right
  38880. * @param axis defines the axis to use
  38881. */
  38882. setAxisForLeftRight(axis: JoystickAxis): void;
  38883. /**
  38884. * Defines which axis you'd like to control for up & down
  38885. * @param axis defines the axis to use
  38886. */
  38887. setAxisForUpDown(axis: JoystickAxis): void;
  38888. private _drawVirtualJoystick;
  38889. /**
  38890. * Release internal HTML canvas
  38891. */
  38892. releaseCanvas(): void;
  38893. }
  38894. }
  38895. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38896. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38897. import { Nullable } from "babylonjs/types";
  38898. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38899. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38900. module "babylonjs/Cameras/freeCameraInputsManager" {
  38901. interface FreeCameraInputsManager {
  38902. /**
  38903. * Add virtual joystick input support to the input manager.
  38904. * @returns the current input manager
  38905. */
  38906. addVirtualJoystick(): FreeCameraInputsManager;
  38907. }
  38908. }
  38909. /**
  38910. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38911. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38912. */
  38913. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38914. /**
  38915. * Defines the camera the input is attached to.
  38916. */
  38917. camera: FreeCamera;
  38918. private _leftjoystick;
  38919. private _rightjoystick;
  38920. /**
  38921. * Gets the left stick of the virtual joystick.
  38922. * @returns The virtual Joystick
  38923. */
  38924. getLeftJoystick(): VirtualJoystick;
  38925. /**
  38926. * Gets the right stick of the virtual joystick.
  38927. * @returns The virtual Joystick
  38928. */
  38929. getRightJoystick(): VirtualJoystick;
  38930. /**
  38931. * Update the current camera state depending on the inputs that have been used this frame.
  38932. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38933. */
  38934. checkInputs(): void;
  38935. /**
  38936. * Attach the input controls to a specific dom element to get the input from.
  38937. * @param element Defines the element the controls should be listened from
  38938. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38939. */
  38940. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38941. /**
  38942. * Detach the current controls from the specified dom element.
  38943. * @param element Defines the element to stop listening the inputs from
  38944. */
  38945. detachControl(element: Nullable<HTMLElement>): void;
  38946. /**
  38947. * Gets the class name of the current intput.
  38948. * @returns the class name
  38949. */
  38950. getClassName(): string;
  38951. /**
  38952. * Get the friendly name associated with the input class.
  38953. * @returns the input friendly name
  38954. */
  38955. getSimpleName(): string;
  38956. }
  38957. }
  38958. declare module "babylonjs/Cameras/Inputs/index" {
  38959. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38960. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38961. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38962. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38963. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38964. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38965. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38966. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38967. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38968. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38969. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38970. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38971. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38972. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38973. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38974. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38975. }
  38976. declare module "babylonjs/Cameras/touchCamera" {
  38977. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38978. import { Scene } from "babylonjs/scene";
  38979. import { Vector3 } from "babylonjs/Maths/math";
  38980. /**
  38981. * This represents a FPS type of camera controlled by touch.
  38982. * This is like a universal camera minus the Gamepad controls.
  38983. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38984. */
  38985. export class TouchCamera extends FreeCamera {
  38986. /**
  38987. * Defines the touch sensibility for rotation.
  38988. * The higher the faster.
  38989. */
  38990. touchAngularSensibility: number;
  38991. /**
  38992. * Defines the touch sensibility for move.
  38993. * The higher the faster.
  38994. */
  38995. touchMoveSensibility: number;
  38996. /**
  38997. * Instantiates a new touch camera.
  38998. * This represents a FPS type of camera controlled by touch.
  38999. * This is like a universal camera minus the Gamepad controls.
  39000. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39001. * @param name Define the name of the camera in the scene
  39002. * @param position Define the start position of the camera in the scene
  39003. * @param scene Define the scene the camera belongs to
  39004. */
  39005. constructor(name: string, position: Vector3, scene: Scene);
  39006. /**
  39007. * Gets the current object class name.
  39008. * @return the class name
  39009. */
  39010. getClassName(): string;
  39011. /** @hidden */
  39012. _setupInputs(): void;
  39013. }
  39014. }
  39015. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39016. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39017. import { Scene } from "babylonjs/scene";
  39018. import { Vector3, Axis } from "babylonjs/Maths/math";
  39019. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39020. /**
  39021. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39022. * being tilted forward or back and left or right.
  39023. */
  39024. export class DeviceOrientationCamera extends FreeCamera {
  39025. private _initialQuaternion;
  39026. private _quaternionCache;
  39027. private _tmpDragQuaternion;
  39028. /**
  39029. * Creates a new device orientation camera
  39030. * @param name The name of the camera
  39031. * @param position The start position camera
  39032. * @param scene The scene the camera belongs to
  39033. */
  39034. constructor(name: string, position: Vector3, scene: Scene);
  39035. /**
  39036. * @hidden
  39037. * Disabled pointer input on first orientation sensor update (Default: true)
  39038. */
  39039. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  39040. private _dragFactor;
  39041. /**
  39042. * Enabled turning on the y axis when the orientation sensor is active
  39043. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39044. */
  39045. enableHorizontalDragging(dragFactor?: number): void;
  39046. /**
  39047. * Gets the current instance class name ("DeviceOrientationCamera").
  39048. * This helps avoiding instanceof at run time.
  39049. * @returns the class name
  39050. */
  39051. getClassName(): string;
  39052. /**
  39053. * @hidden
  39054. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39055. */
  39056. _checkInputs(): void;
  39057. /**
  39058. * Reset the camera to its default orientation on the specified axis only.
  39059. * @param axis The axis to reset
  39060. */
  39061. resetToCurrentRotation(axis?: Axis): void;
  39062. }
  39063. }
  39064. declare module "babylonjs/Gamepads/xboxGamepad" {
  39065. import { Observable } from "babylonjs/Misc/observable";
  39066. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39067. /**
  39068. * Defines supported buttons for XBox360 compatible gamepads
  39069. */
  39070. export enum Xbox360Button {
  39071. /** A */
  39072. A = 0,
  39073. /** B */
  39074. B = 1,
  39075. /** X */
  39076. X = 2,
  39077. /** Y */
  39078. Y = 3,
  39079. /** Start */
  39080. Start = 4,
  39081. /** Back */
  39082. Back = 5,
  39083. /** Left button */
  39084. LB = 6,
  39085. /** Right button */
  39086. RB = 7,
  39087. /** Left stick */
  39088. LeftStick = 8,
  39089. /** Right stick */
  39090. RightStick = 9
  39091. }
  39092. /** Defines values for XBox360 DPad */
  39093. export enum Xbox360Dpad {
  39094. /** Up */
  39095. Up = 0,
  39096. /** Down */
  39097. Down = 1,
  39098. /** Left */
  39099. Left = 2,
  39100. /** Right */
  39101. Right = 3
  39102. }
  39103. /**
  39104. * Defines a XBox360 gamepad
  39105. */
  39106. export class Xbox360Pad extends Gamepad {
  39107. private _leftTrigger;
  39108. private _rightTrigger;
  39109. private _onlefttriggerchanged;
  39110. private _onrighttriggerchanged;
  39111. private _onbuttondown;
  39112. private _onbuttonup;
  39113. private _ondpaddown;
  39114. private _ondpadup;
  39115. /** Observable raised when a button is pressed */
  39116. onButtonDownObservable: Observable<Xbox360Button>;
  39117. /** Observable raised when a button is released */
  39118. onButtonUpObservable: Observable<Xbox360Button>;
  39119. /** Observable raised when a pad is pressed */
  39120. onPadDownObservable: Observable<Xbox360Dpad>;
  39121. /** Observable raised when a pad is released */
  39122. onPadUpObservable: Observable<Xbox360Dpad>;
  39123. private _buttonA;
  39124. private _buttonB;
  39125. private _buttonX;
  39126. private _buttonY;
  39127. private _buttonBack;
  39128. private _buttonStart;
  39129. private _buttonLB;
  39130. private _buttonRB;
  39131. private _buttonLeftStick;
  39132. private _buttonRightStick;
  39133. private _dPadUp;
  39134. private _dPadDown;
  39135. private _dPadLeft;
  39136. private _dPadRight;
  39137. private _isXboxOnePad;
  39138. /**
  39139. * Creates a new XBox360 gamepad object
  39140. * @param id defines the id of this gamepad
  39141. * @param index defines its index
  39142. * @param gamepad defines the internal HTML gamepad object
  39143. * @param xboxOne defines if it is a XBox One gamepad
  39144. */
  39145. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39146. /**
  39147. * Defines the callback to call when left trigger is pressed
  39148. * @param callback defines the callback to use
  39149. */
  39150. onlefttriggerchanged(callback: (value: number) => void): void;
  39151. /**
  39152. * Defines the callback to call when right trigger is pressed
  39153. * @param callback defines the callback to use
  39154. */
  39155. onrighttriggerchanged(callback: (value: number) => void): void;
  39156. /**
  39157. * Gets the left trigger value
  39158. */
  39159. /**
  39160. * Sets the left trigger value
  39161. */
  39162. leftTrigger: number;
  39163. /**
  39164. * Gets the right trigger value
  39165. */
  39166. /**
  39167. * Sets the right trigger value
  39168. */
  39169. rightTrigger: number;
  39170. /**
  39171. * Defines the callback to call when a button is pressed
  39172. * @param callback defines the callback to use
  39173. */
  39174. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39175. /**
  39176. * Defines the callback to call when a button is released
  39177. * @param callback defines the callback to use
  39178. */
  39179. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39180. /**
  39181. * Defines the callback to call when a pad is pressed
  39182. * @param callback defines the callback to use
  39183. */
  39184. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39185. /**
  39186. * Defines the callback to call when a pad is released
  39187. * @param callback defines the callback to use
  39188. */
  39189. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39190. private _setButtonValue;
  39191. private _setDPadValue;
  39192. /**
  39193. * Gets the value of the `A` button
  39194. */
  39195. /**
  39196. * Sets the value of the `A` button
  39197. */
  39198. buttonA: number;
  39199. /**
  39200. * Gets the value of the `B` button
  39201. */
  39202. /**
  39203. * Sets the value of the `B` button
  39204. */
  39205. buttonB: number;
  39206. /**
  39207. * Gets the value of the `X` button
  39208. */
  39209. /**
  39210. * Sets the value of the `X` button
  39211. */
  39212. buttonX: number;
  39213. /**
  39214. * Gets the value of the `Y` button
  39215. */
  39216. /**
  39217. * Sets the value of the `Y` button
  39218. */
  39219. buttonY: number;
  39220. /**
  39221. * Gets the value of the `Start` button
  39222. */
  39223. /**
  39224. * Sets the value of the `Start` button
  39225. */
  39226. buttonStart: number;
  39227. /**
  39228. * Gets the value of the `Back` button
  39229. */
  39230. /**
  39231. * Sets the value of the `Back` button
  39232. */
  39233. buttonBack: number;
  39234. /**
  39235. * Gets the value of the `Left` button
  39236. */
  39237. /**
  39238. * Sets the value of the `Left` button
  39239. */
  39240. buttonLB: number;
  39241. /**
  39242. * Gets the value of the `Right` button
  39243. */
  39244. /**
  39245. * Sets the value of the `Right` button
  39246. */
  39247. buttonRB: number;
  39248. /**
  39249. * Gets the value of the Left joystick
  39250. */
  39251. /**
  39252. * Sets the value of the Left joystick
  39253. */
  39254. buttonLeftStick: number;
  39255. /**
  39256. * Gets the value of the Right joystick
  39257. */
  39258. /**
  39259. * Sets the value of the Right joystick
  39260. */
  39261. buttonRightStick: number;
  39262. /**
  39263. * Gets the value of D-pad up
  39264. */
  39265. /**
  39266. * Sets the value of D-pad up
  39267. */
  39268. dPadUp: number;
  39269. /**
  39270. * Gets the value of D-pad down
  39271. */
  39272. /**
  39273. * Sets the value of D-pad down
  39274. */
  39275. dPadDown: number;
  39276. /**
  39277. * Gets the value of D-pad left
  39278. */
  39279. /**
  39280. * Sets the value of D-pad left
  39281. */
  39282. dPadLeft: number;
  39283. /**
  39284. * Gets the value of D-pad right
  39285. */
  39286. /**
  39287. * Sets the value of D-pad right
  39288. */
  39289. dPadRight: number;
  39290. /**
  39291. * Force the gamepad to synchronize with device values
  39292. */
  39293. update(): void;
  39294. /**
  39295. * Disposes the gamepad
  39296. */
  39297. dispose(): void;
  39298. }
  39299. }
  39300. declare module "babylonjs/Gamepads/gamepadManager" {
  39301. import { Observable } from "babylonjs/Misc/observable";
  39302. import { Nullable } from "babylonjs/types";
  39303. import { Scene } from "babylonjs/scene";
  39304. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39305. /**
  39306. * Manager for handling gamepads
  39307. */
  39308. export class GamepadManager {
  39309. private _scene?;
  39310. private _babylonGamepads;
  39311. private _oneGamepadConnected;
  39312. /** @hidden */
  39313. _isMonitoring: boolean;
  39314. private _gamepadEventSupported;
  39315. private _gamepadSupport;
  39316. /**
  39317. * observable to be triggered when the gamepad controller has been connected
  39318. */
  39319. onGamepadConnectedObservable: Observable<Gamepad>;
  39320. /**
  39321. * observable to be triggered when the gamepad controller has been disconnected
  39322. */
  39323. onGamepadDisconnectedObservable: Observable<Gamepad>;
  39324. private _onGamepadConnectedEvent;
  39325. private _onGamepadDisconnectedEvent;
  39326. /**
  39327. * Initializes the gamepad manager
  39328. * @param _scene BabylonJS scene
  39329. */
  39330. constructor(_scene?: Scene | undefined);
  39331. /**
  39332. * The gamepads in the game pad manager
  39333. */
  39334. readonly gamepads: Gamepad[];
  39335. /**
  39336. * Get the gamepad controllers based on type
  39337. * @param type The type of gamepad controller
  39338. * @returns Nullable gamepad
  39339. */
  39340. getGamepadByType(type?: number): Nullable<Gamepad>;
  39341. /**
  39342. * Disposes the gamepad manager
  39343. */
  39344. dispose(): void;
  39345. private _addNewGamepad;
  39346. private _startMonitoringGamepads;
  39347. private _stopMonitoringGamepads;
  39348. /** @hidden */
  39349. _checkGamepadsStatus(): void;
  39350. private _updateGamepadObjects;
  39351. }
  39352. }
  39353. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  39354. import { Nullable } from "babylonjs/types";
  39355. import { Scene } from "babylonjs/scene";
  39356. import { ISceneComponent } from "babylonjs/sceneComponent";
  39357. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  39358. module "babylonjs/scene" {
  39359. interface Scene {
  39360. /** @hidden */
  39361. _gamepadManager: Nullable<GamepadManager>;
  39362. /**
  39363. * Gets the gamepad manager associated with the scene
  39364. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  39365. */
  39366. gamepadManager: GamepadManager;
  39367. }
  39368. }
  39369. module "babylonjs/Cameras/freeCameraInputsManager" {
  39370. /**
  39371. * Interface representing a free camera inputs manager
  39372. */
  39373. interface FreeCameraInputsManager {
  39374. /**
  39375. * Adds gamepad input support to the FreeCameraInputsManager.
  39376. * @returns the FreeCameraInputsManager
  39377. */
  39378. addGamepad(): FreeCameraInputsManager;
  39379. }
  39380. }
  39381. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39382. /**
  39383. * Interface representing an arc rotate camera inputs manager
  39384. */
  39385. interface ArcRotateCameraInputsManager {
  39386. /**
  39387. * Adds gamepad input support to the ArcRotateCamera InputManager.
  39388. * @returns the camera inputs manager
  39389. */
  39390. addGamepad(): ArcRotateCameraInputsManager;
  39391. }
  39392. }
  39393. /**
  39394. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  39395. */
  39396. export class GamepadSystemSceneComponent implements ISceneComponent {
  39397. /**
  39398. * The component name helpfull to identify the component in the list of scene components.
  39399. */
  39400. readonly name: string;
  39401. /**
  39402. * The scene the component belongs to.
  39403. */
  39404. scene: Scene;
  39405. /**
  39406. * Creates a new instance of the component for the given scene
  39407. * @param scene Defines the scene to register the component in
  39408. */
  39409. constructor(scene: Scene);
  39410. /**
  39411. * Registers the component in a given scene
  39412. */
  39413. register(): void;
  39414. /**
  39415. * Rebuilds the elements related to this component in case of
  39416. * context lost for instance.
  39417. */
  39418. rebuild(): void;
  39419. /**
  39420. * Disposes the component and the associated ressources
  39421. */
  39422. dispose(): void;
  39423. private _beforeCameraUpdate;
  39424. }
  39425. }
  39426. declare module "babylonjs/Cameras/universalCamera" {
  39427. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  39428. import { Scene } from "babylonjs/scene";
  39429. import { Vector3 } from "babylonjs/Maths/math";
  39430. import "babylonjs/Gamepads/gamepadSceneComponent";
  39431. /**
  39432. * 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,
  39433. * which still works and will still be found in many Playgrounds.
  39434. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39435. */
  39436. export class UniversalCamera extends TouchCamera {
  39437. /**
  39438. * Defines the gamepad rotation sensiblity.
  39439. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39440. */
  39441. gamepadAngularSensibility: number;
  39442. /**
  39443. * Defines the gamepad move sensiblity.
  39444. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39445. */
  39446. gamepadMoveSensibility: number;
  39447. /**
  39448. * 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,
  39449. * which still works and will still be found in many Playgrounds.
  39450. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39451. * @param name Define the name of the camera in the scene
  39452. * @param position Define the start position of the camera in the scene
  39453. * @param scene Define the scene the camera belongs to
  39454. */
  39455. constructor(name: string, position: Vector3, scene: Scene);
  39456. /**
  39457. * Gets the current object class name.
  39458. * @return the class name
  39459. */
  39460. getClassName(): string;
  39461. }
  39462. }
  39463. declare module "babylonjs/Cameras/gamepadCamera" {
  39464. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39465. import { Scene } from "babylonjs/scene";
  39466. import { Vector3 } from "babylonjs/Maths/math";
  39467. /**
  39468. * This represents a FPS type of camera. This is only here for back compat purpose.
  39469. * Please use the UniversalCamera instead as both are identical.
  39470. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39471. */
  39472. export class GamepadCamera extends UniversalCamera {
  39473. /**
  39474. * Instantiates a new Gamepad Camera
  39475. * This represents a FPS type of camera. This is only here for back compat purpose.
  39476. * Please use the UniversalCamera instead as both are identical.
  39477. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39478. * @param name Define the name of the camera in the scene
  39479. * @param position Define the start position of the camera in the scene
  39480. * @param scene Define the scene the camera belongs to
  39481. */
  39482. constructor(name: string, position: Vector3, scene: Scene);
  39483. /**
  39484. * Gets the current object class name.
  39485. * @return the class name
  39486. */
  39487. getClassName(): string;
  39488. }
  39489. }
  39490. declare module "babylonjs/Shaders/pass.fragment" {
  39491. /** @hidden */
  39492. export var passPixelShader: {
  39493. name: string;
  39494. shader: string;
  39495. };
  39496. }
  39497. declare module "babylonjs/Shaders/passCube.fragment" {
  39498. /** @hidden */
  39499. export var passCubePixelShader: {
  39500. name: string;
  39501. shader: string;
  39502. };
  39503. }
  39504. declare module "babylonjs/PostProcesses/passPostProcess" {
  39505. import { Nullable } from "babylonjs/types";
  39506. import { Camera } from "babylonjs/Cameras/camera";
  39507. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39508. import { Engine } from "babylonjs/Engines/engine";
  39509. import "babylonjs/Shaders/pass.fragment";
  39510. import "babylonjs/Shaders/passCube.fragment";
  39511. /**
  39512. * PassPostProcess which produces an output the same as it's input
  39513. */
  39514. export class PassPostProcess extends PostProcess {
  39515. /**
  39516. * Creates the PassPostProcess
  39517. * @param name The name of the effect.
  39518. * @param options The required width/height ratio to downsize to before computing the render pass.
  39519. * @param camera The camera to apply the render pass to.
  39520. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39521. * @param engine The engine which the post process will be applied. (default: current engine)
  39522. * @param reusable If the post process can be reused on the same frame. (default: false)
  39523. * @param textureType The type of texture to be used when performing the post processing.
  39524. * @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)
  39525. */
  39526. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39527. }
  39528. /**
  39529. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39530. */
  39531. export class PassCubePostProcess extends PostProcess {
  39532. private _face;
  39533. /**
  39534. * Gets or sets the cube face to display.
  39535. * * 0 is +X
  39536. * * 1 is -X
  39537. * * 2 is +Y
  39538. * * 3 is -Y
  39539. * * 4 is +Z
  39540. * * 5 is -Z
  39541. */
  39542. face: number;
  39543. /**
  39544. * Creates the PassCubePostProcess
  39545. * @param name The name of the effect.
  39546. * @param options The required width/height ratio to downsize to before computing the render pass.
  39547. * @param camera The camera to apply the render pass to.
  39548. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39549. * @param engine The engine which the post process will be applied. (default: current engine)
  39550. * @param reusable If the post process can be reused on the same frame. (default: false)
  39551. * @param textureType The type of texture to be used when performing the post processing.
  39552. * @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)
  39553. */
  39554. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39555. }
  39556. }
  39557. declare module "babylonjs/Shaders/anaglyph.fragment" {
  39558. /** @hidden */
  39559. export var anaglyphPixelShader: {
  39560. name: string;
  39561. shader: string;
  39562. };
  39563. }
  39564. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  39565. import { Engine } from "babylonjs/Engines/engine";
  39566. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39567. import { Camera } from "babylonjs/Cameras/camera";
  39568. import "babylonjs/Shaders/anaglyph.fragment";
  39569. /**
  39570. * Postprocess used to generate anaglyphic rendering
  39571. */
  39572. export class AnaglyphPostProcess extends PostProcess {
  39573. private _passedProcess;
  39574. /**
  39575. * Creates a new AnaglyphPostProcess
  39576. * @param name defines postprocess name
  39577. * @param options defines creation options or target ratio scale
  39578. * @param rigCameras defines cameras using this postprocess
  39579. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39580. * @param engine defines hosting engine
  39581. * @param reusable defines if the postprocess will be reused multiple times per frame
  39582. */
  39583. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39584. }
  39585. }
  39586. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  39587. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  39588. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39589. import { Scene } from "babylonjs/scene";
  39590. import { Vector3 } from "babylonjs/Maths/math";
  39591. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39592. /**
  39593. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39594. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39595. */
  39596. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39597. /**
  39598. * Creates a new AnaglyphArcRotateCamera
  39599. * @param name defines camera name
  39600. * @param alpha defines alpha angle (in radians)
  39601. * @param beta defines beta angle (in radians)
  39602. * @param radius defines radius
  39603. * @param target defines camera target
  39604. * @param interaxialDistance defines distance between each color axis
  39605. * @param scene defines the hosting scene
  39606. */
  39607. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39608. /**
  39609. * Gets camera class name
  39610. * @returns AnaglyphArcRotateCamera
  39611. */
  39612. getClassName(): string;
  39613. }
  39614. }
  39615. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  39616. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39617. import { Scene } from "babylonjs/scene";
  39618. import { Vector3 } from "babylonjs/Maths/math";
  39619. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39620. /**
  39621. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39622. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39623. */
  39624. export class AnaglyphFreeCamera extends FreeCamera {
  39625. /**
  39626. * Creates a new AnaglyphFreeCamera
  39627. * @param name defines camera name
  39628. * @param position defines initial position
  39629. * @param interaxialDistance defines distance between each color axis
  39630. * @param scene defines the hosting scene
  39631. */
  39632. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39633. /**
  39634. * Gets camera class name
  39635. * @returns AnaglyphFreeCamera
  39636. */
  39637. getClassName(): string;
  39638. }
  39639. }
  39640. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  39641. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39642. import { Scene } from "babylonjs/scene";
  39643. import { Vector3 } from "babylonjs/Maths/math";
  39644. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39645. /**
  39646. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39647. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39648. */
  39649. export class AnaglyphGamepadCamera extends GamepadCamera {
  39650. /**
  39651. * Creates a new AnaglyphGamepadCamera
  39652. * @param name defines camera name
  39653. * @param position defines initial position
  39654. * @param interaxialDistance defines distance between each color axis
  39655. * @param scene defines the hosting scene
  39656. */
  39657. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39658. /**
  39659. * Gets camera class name
  39660. * @returns AnaglyphGamepadCamera
  39661. */
  39662. getClassName(): string;
  39663. }
  39664. }
  39665. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  39666. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39667. import { Scene } from "babylonjs/scene";
  39668. import { Vector3 } from "babylonjs/Maths/math";
  39669. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39670. /**
  39671. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39672. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39673. */
  39674. export class AnaglyphUniversalCamera extends UniversalCamera {
  39675. /**
  39676. * Creates a new AnaglyphUniversalCamera
  39677. * @param name defines camera name
  39678. * @param position defines initial position
  39679. * @param interaxialDistance defines distance between each color axis
  39680. * @param scene defines the hosting scene
  39681. */
  39682. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39683. /**
  39684. * Gets camera class name
  39685. * @returns AnaglyphUniversalCamera
  39686. */
  39687. getClassName(): string;
  39688. }
  39689. }
  39690. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  39691. /** @hidden */
  39692. export var stereoscopicInterlacePixelShader: {
  39693. name: string;
  39694. shader: string;
  39695. };
  39696. }
  39697. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  39698. import { Camera } from "babylonjs/Cameras/camera";
  39699. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39700. import { Engine } from "babylonjs/Engines/engine";
  39701. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  39702. /**
  39703. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39704. */
  39705. export class StereoscopicInterlacePostProcess extends PostProcess {
  39706. private _stepSize;
  39707. private _passedProcess;
  39708. /**
  39709. * Initializes a StereoscopicInterlacePostProcess
  39710. * @param name The name of the effect.
  39711. * @param rigCameras The rig cameras to be appled to the post process
  39712. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39713. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39714. * @param engine The engine which the post process will be applied. (default: current engine)
  39715. * @param reusable If the post process can be reused on the same frame. (default: false)
  39716. */
  39717. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39718. }
  39719. }
  39720. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  39721. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  39722. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39723. import { Scene } from "babylonjs/scene";
  39724. import { Vector3 } from "babylonjs/Maths/math";
  39725. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39726. /**
  39727. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39728. * @see http://doc.babylonjs.com/features/cameras
  39729. */
  39730. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39731. /**
  39732. * Creates a new StereoscopicArcRotateCamera
  39733. * @param name defines camera name
  39734. * @param alpha defines alpha angle (in radians)
  39735. * @param beta defines beta angle (in radians)
  39736. * @param radius defines radius
  39737. * @param target defines camera target
  39738. * @param interaxialDistance defines distance between each color axis
  39739. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39740. * @param scene defines the hosting scene
  39741. */
  39742. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39743. /**
  39744. * Gets camera class name
  39745. * @returns StereoscopicArcRotateCamera
  39746. */
  39747. getClassName(): string;
  39748. }
  39749. }
  39750. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  39751. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39752. import { Scene } from "babylonjs/scene";
  39753. import { Vector3 } from "babylonjs/Maths/math";
  39754. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39755. /**
  39756. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39757. * @see http://doc.babylonjs.com/features/cameras
  39758. */
  39759. export class StereoscopicFreeCamera extends FreeCamera {
  39760. /**
  39761. * Creates a new StereoscopicFreeCamera
  39762. * @param name defines camera name
  39763. * @param position defines initial position
  39764. * @param interaxialDistance defines distance between each color axis
  39765. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39766. * @param scene defines the hosting scene
  39767. */
  39768. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39769. /**
  39770. * Gets camera class name
  39771. * @returns StereoscopicFreeCamera
  39772. */
  39773. getClassName(): string;
  39774. }
  39775. }
  39776. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  39777. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39778. import { Scene } from "babylonjs/scene";
  39779. import { Vector3 } from "babylonjs/Maths/math";
  39780. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39781. /**
  39782. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39783. * @see http://doc.babylonjs.com/features/cameras
  39784. */
  39785. export class StereoscopicGamepadCamera extends GamepadCamera {
  39786. /**
  39787. * Creates a new StereoscopicGamepadCamera
  39788. * @param name defines camera name
  39789. * @param position defines initial position
  39790. * @param interaxialDistance defines distance between each color axis
  39791. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39792. * @param scene defines the hosting scene
  39793. */
  39794. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39795. /**
  39796. * Gets camera class name
  39797. * @returns StereoscopicGamepadCamera
  39798. */
  39799. getClassName(): string;
  39800. }
  39801. }
  39802. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  39803. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39804. import { Scene } from "babylonjs/scene";
  39805. import { Vector3 } from "babylonjs/Maths/math";
  39806. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39807. /**
  39808. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39809. * @see http://doc.babylonjs.com/features/cameras
  39810. */
  39811. export class StereoscopicUniversalCamera extends UniversalCamera {
  39812. /**
  39813. * Creates a new StereoscopicUniversalCamera
  39814. * @param name defines camera name
  39815. * @param position defines initial position
  39816. * @param interaxialDistance defines distance between each color axis
  39817. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39818. * @param scene defines the hosting scene
  39819. */
  39820. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39821. /**
  39822. * Gets camera class name
  39823. * @returns StereoscopicUniversalCamera
  39824. */
  39825. getClassName(): string;
  39826. }
  39827. }
  39828. declare module "babylonjs/Cameras/Stereoscopic/index" {
  39829. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  39830. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  39831. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  39832. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  39833. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  39834. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  39835. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  39836. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  39837. }
  39838. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  39839. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39840. import { Scene } from "babylonjs/scene";
  39841. import { Vector3 } from "babylonjs/Maths/math";
  39842. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39843. /**
  39844. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39845. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39846. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39847. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39848. */
  39849. export class VirtualJoysticksCamera extends FreeCamera {
  39850. /**
  39851. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39852. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39853. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39854. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39855. * @param name Define the name of the camera in the scene
  39856. * @param position Define the start position of the camera in the scene
  39857. * @param scene Define the scene the camera belongs to
  39858. */
  39859. constructor(name: string, position: Vector3, scene: Scene);
  39860. /**
  39861. * Gets the current object class name.
  39862. * @return the class name
  39863. */
  39864. getClassName(): string;
  39865. }
  39866. }
  39867. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  39868. import { Matrix } from "babylonjs/Maths/math";
  39869. /**
  39870. * This represents all the required metrics to create a VR camera.
  39871. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39872. */
  39873. export class VRCameraMetrics {
  39874. /**
  39875. * Define the horizontal resolution off the screen.
  39876. */
  39877. hResolution: number;
  39878. /**
  39879. * Define the vertical resolution off the screen.
  39880. */
  39881. vResolution: number;
  39882. /**
  39883. * Define the horizontal screen size.
  39884. */
  39885. hScreenSize: number;
  39886. /**
  39887. * Define the vertical screen size.
  39888. */
  39889. vScreenSize: number;
  39890. /**
  39891. * Define the vertical screen center position.
  39892. */
  39893. vScreenCenter: number;
  39894. /**
  39895. * Define the distance of the eyes to the screen.
  39896. */
  39897. eyeToScreenDistance: number;
  39898. /**
  39899. * Define the distance between both lenses
  39900. */
  39901. lensSeparationDistance: number;
  39902. /**
  39903. * Define the distance between both viewer's eyes.
  39904. */
  39905. interpupillaryDistance: number;
  39906. /**
  39907. * Define the distortion factor of the VR postprocess.
  39908. * Please, touch with care.
  39909. */
  39910. distortionK: number[];
  39911. /**
  39912. * Define the chromatic aberration correction factors for the VR post process.
  39913. */
  39914. chromaAbCorrection: number[];
  39915. /**
  39916. * Define the scale factor of the post process.
  39917. * The smaller the better but the slower.
  39918. */
  39919. postProcessScaleFactor: number;
  39920. /**
  39921. * Define an offset for the lens center.
  39922. */
  39923. lensCenterOffset: number;
  39924. /**
  39925. * Define if the current vr camera should compensate the distortion of the lense or not.
  39926. */
  39927. compensateDistortion: boolean;
  39928. /**
  39929. * Defines if multiview should be enabled when rendering (Default: false)
  39930. */
  39931. multiviewEnabled: boolean;
  39932. /**
  39933. * Gets the rendering aspect ratio based on the provided resolutions.
  39934. */
  39935. readonly aspectRatio: number;
  39936. /**
  39937. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39938. */
  39939. readonly aspectRatioFov: number;
  39940. /**
  39941. * @hidden
  39942. */
  39943. readonly leftHMatrix: Matrix;
  39944. /**
  39945. * @hidden
  39946. */
  39947. readonly rightHMatrix: Matrix;
  39948. /**
  39949. * @hidden
  39950. */
  39951. readonly leftPreViewMatrix: Matrix;
  39952. /**
  39953. * @hidden
  39954. */
  39955. readonly rightPreViewMatrix: Matrix;
  39956. /**
  39957. * Get the default VRMetrics based on the most generic setup.
  39958. * @returns the default vr metrics
  39959. */
  39960. static GetDefault(): VRCameraMetrics;
  39961. }
  39962. }
  39963. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  39964. /** @hidden */
  39965. export var vrDistortionCorrectionPixelShader: {
  39966. name: string;
  39967. shader: string;
  39968. };
  39969. }
  39970. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  39971. import { Camera } from "babylonjs/Cameras/camera";
  39972. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39973. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39974. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  39975. /**
  39976. * VRDistortionCorrectionPostProcess used for mobile VR
  39977. */
  39978. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39979. private _isRightEye;
  39980. private _distortionFactors;
  39981. private _postProcessScaleFactor;
  39982. private _lensCenterOffset;
  39983. private _scaleIn;
  39984. private _scaleFactor;
  39985. private _lensCenter;
  39986. /**
  39987. * Initializes the VRDistortionCorrectionPostProcess
  39988. * @param name The name of the effect.
  39989. * @param camera The camera to apply the render pass to.
  39990. * @param isRightEye If this is for the right eye distortion
  39991. * @param vrMetrics All the required metrics for the VR camera
  39992. */
  39993. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39994. }
  39995. }
  39996. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  39997. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  39998. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39999. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40000. import { Scene } from "babylonjs/scene";
  40001. import { Vector3 } from "babylonjs/Maths/math";
  40002. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  40003. import "babylonjs/Cameras/RigModes/vrRigMode";
  40004. /**
  40005. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  40006. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40007. */
  40008. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  40009. /**
  40010. * Creates a new VRDeviceOrientationArcRotateCamera
  40011. * @param name defines camera name
  40012. * @param alpha defines the camera rotation along the logitudinal axis
  40013. * @param beta defines the camera rotation along the latitudinal axis
  40014. * @param radius defines the camera distance from its target
  40015. * @param target defines the camera target
  40016. * @param scene defines the scene the camera belongs to
  40017. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40018. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40019. */
  40020. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40021. /**
  40022. * Gets camera class name
  40023. * @returns VRDeviceOrientationArcRotateCamera
  40024. */
  40025. getClassName(): string;
  40026. }
  40027. }
  40028. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  40029. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40030. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40031. import { Scene } from "babylonjs/scene";
  40032. import { Vector3 } from "babylonjs/Maths/math";
  40033. import "babylonjs/Cameras/RigModes/vrRigMode";
  40034. /**
  40035. * Camera used to simulate VR rendering (based on FreeCamera)
  40036. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40037. */
  40038. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  40039. /**
  40040. * Creates a new VRDeviceOrientationFreeCamera
  40041. * @param name defines camera name
  40042. * @param position defines the start position of the camera
  40043. * @param scene defines the scene the camera belongs to
  40044. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40045. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40046. */
  40047. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40048. /**
  40049. * Gets camera class name
  40050. * @returns VRDeviceOrientationFreeCamera
  40051. */
  40052. getClassName(): string;
  40053. }
  40054. }
  40055. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  40056. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40057. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40058. import { Scene } from "babylonjs/scene";
  40059. import { Vector3 } from "babylonjs/Maths/math";
  40060. import "babylonjs/Gamepads/gamepadSceneComponent";
  40061. /**
  40062. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  40063. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  40064. */
  40065. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  40066. /**
  40067. * Creates a new VRDeviceOrientationGamepadCamera
  40068. * @param name defines camera name
  40069. * @param position defines the start position of the camera
  40070. * @param scene defines the scene the camera belongs to
  40071. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  40072. * @param vrCameraMetrics defines the vr metrics associated to the camera
  40073. */
  40074. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  40075. /**
  40076. * Gets camera class name
  40077. * @returns VRDeviceOrientationGamepadCamera
  40078. */
  40079. getClassName(): string;
  40080. }
  40081. }
  40082. declare module "babylonjs/Materials/pushMaterial" {
  40083. import { Nullable } from "babylonjs/types";
  40084. import { Scene } from "babylonjs/scene";
  40085. import { Matrix } from "babylonjs/Maths/math";
  40086. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40087. import { Mesh } from "babylonjs/Meshes/mesh";
  40088. import { Material } from "babylonjs/Materials/material";
  40089. import { Effect } from "babylonjs/Materials/effect";
  40090. /**
  40091. * Base class of materials working in push mode in babylon JS
  40092. * @hidden
  40093. */
  40094. export class PushMaterial extends Material {
  40095. protected _activeEffect: Effect;
  40096. protected _normalMatrix: Matrix;
  40097. /**
  40098. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  40099. * This means that the material can keep using a previous shader while a new one is being compiled.
  40100. * This is mostly used when shader parallel compilation is supported (true by default)
  40101. */
  40102. allowShaderHotSwapping: boolean;
  40103. constructor(name: string, scene: Scene);
  40104. getEffect(): Effect;
  40105. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  40106. /**
  40107. * Binds the given world matrix to the active effect
  40108. *
  40109. * @param world the matrix to bind
  40110. */
  40111. bindOnlyWorldMatrix(world: Matrix): void;
  40112. /**
  40113. * Binds the given normal matrix to the active effect
  40114. *
  40115. * @param normalMatrix the matrix to bind
  40116. */
  40117. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  40118. bind(world: Matrix, mesh?: Mesh): void;
  40119. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  40120. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  40121. }
  40122. }
  40123. declare module "babylonjs/Materials/materialFlags" {
  40124. /**
  40125. * This groups all the flags used to control the materials channel.
  40126. */
  40127. export class MaterialFlags {
  40128. private static _DiffuseTextureEnabled;
  40129. /**
  40130. * Are diffuse textures enabled in the application.
  40131. */
  40132. static DiffuseTextureEnabled: boolean;
  40133. private static _AmbientTextureEnabled;
  40134. /**
  40135. * Are ambient textures enabled in the application.
  40136. */
  40137. static AmbientTextureEnabled: boolean;
  40138. private static _OpacityTextureEnabled;
  40139. /**
  40140. * Are opacity textures enabled in the application.
  40141. */
  40142. static OpacityTextureEnabled: boolean;
  40143. private static _ReflectionTextureEnabled;
  40144. /**
  40145. * Are reflection textures enabled in the application.
  40146. */
  40147. static ReflectionTextureEnabled: boolean;
  40148. private static _EmissiveTextureEnabled;
  40149. /**
  40150. * Are emissive textures enabled in the application.
  40151. */
  40152. static EmissiveTextureEnabled: boolean;
  40153. private static _SpecularTextureEnabled;
  40154. /**
  40155. * Are specular textures enabled in the application.
  40156. */
  40157. static SpecularTextureEnabled: boolean;
  40158. private static _BumpTextureEnabled;
  40159. /**
  40160. * Are bump textures enabled in the application.
  40161. */
  40162. static BumpTextureEnabled: boolean;
  40163. private static _LightmapTextureEnabled;
  40164. /**
  40165. * Are lightmap textures enabled in the application.
  40166. */
  40167. static LightmapTextureEnabled: boolean;
  40168. private static _RefractionTextureEnabled;
  40169. /**
  40170. * Are refraction textures enabled in the application.
  40171. */
  40172. static RefractionTextureEnabled: boolean;
  40173. private static _ColorGradingTextureEnabled;
  40174. /**
  40175. * Are color grading textures enabled in the application.
  40176. */
  40177. static ColorGradingTextureEnabled: boolean;
  40178. private static _FresnelEnabled;
  40179. /**
  40180. * Are fresnels enabled in the application.
  40181. */
  40182. static FresnelEnabled: boolean;
  40183. private static _ClearCoatTextureEnabled;
  40184. /**
  40185. * Are clear coat textures enabled in the application.
  40186. */
  40187. static ClearCoatTextureEnabled: boolean;
  40188. private static _ClearCoatBumpTextureEnabled;
  40189. /**
  40190. * Are clear coat bump textures enabled in the application.
  40191. */
  40192. static ClearCoatBumpTextureEnabled: boolean;
  40193. private static _ClearCoatTintTextureEnabled;
  40194. /**
  40195. * Are clear coat tint textures enabled in the application.
  40196. */
  40197. static ClearCoatTintTextureEnabled: boolean;
  40198. private static _SheenTextureEnabled;
  40199. /**
  40200. * Are sheen textures enabled in the application.
  40201. */
  40202. static SheenTextureEnabled: boolean;
  40203. private static _AnisotropicTextureEnabled;
  40204. /**
  40205. * Are anisotropic textures enabled in the application.
  40206. */
  40207. static AnisotropicTextureEnabled: boolean;
  40208. private static _ThicknessTextureEnabled;
  40209. /**
  40210. * Are thickness textures enabled in the application.
  40211. */
  40212. static ThicknessTextureEnabled: boolean;
  40213. }
  40214. }
  40215. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  40216. /** @hidden */
  40217. export var defaultFragmentDeclaration: {
  40218. name: string;
  40219. shader: string;
  40220. };
  40221. }
  40222. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  40223. /** @hidden */
  40224. export var defaultUboDeclaration: {
  40225. name: string;
  40226. shader: string;
  40227. };
  40228. }
  40229. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  40230. /** @hidden */
  40231. export var lightFragmentDeclaration: {
  40232. name: string;
  40233. shader: string;
  40234. };
  40235. }
  40236. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  40237. /** @hidden */
  40238. export var lightUboDeclaration: {
  40239. name: string;
  40240. shader: string;
  40241. };
  40242. }
  40243. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  40244. /** @hidden */
  40245. export var lightsFragmentFunctions: {
  40246. name: string;
  40247. shader: string;
  40248. };
  40249. }
  40250. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  40251. /** @hidden */
  40252. export var shadowsFragmentFunctions: {
  40253. name: string;
  40254. shader: string;
  40255. };
  40256. }
  40257. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  40258. /** @hidden */
  40259. export var fresnelFunction: {
  40260. name: string;
  40261. shader: string;
  40262. };
  40263. }
  40264. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  40265. /** @hidden */
  40266. export var reflectionFunction: {
  40267. name: string;
  40268. shader: string;
  40269. };
  40270. }
  40271. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  40272. /** @hidden */
  40273. export var bumpFragmentFunctions: {
  40274. name: string;
  40275. shader: string;
  40276. };
  40277. }
  40278. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  40279. /** @hidden */
  40280. export var logDepthDeclaration: {
  40281. name: string;
  40282. shader: string;
  40283. };
  40284. }
  40285. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  40286. /** @hidden */
  40287. export var bumpFragment: {
  40288. name: string;
  40289. shader: string;
  40290. };
  40291. }
  40292. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  40293. /** @hidden */
  40294. export var depthPrePass: {
  40295. name: string;
  40296. shader: string;
  40297. };
  40298. }
  40299. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  40300. /** @hidden */
  40301. export var lightFragment: {
  40302. name: string;
  40303. shader: string;
  40304. };
  40305. }
  40306. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  40307. /** @hidden */
  40308. export var logDepthFragment: {
  40309. name: string;
  40310. shader: string;
  40311. };
  40312. }
  40313. declare module "babylonjs/Shaders/default.fragment" {
  40314. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  40315. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40316. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40317. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40318. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40319. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  40320. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  40321. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  40322. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  40323. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40324. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40325. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  40326. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  40327. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40328. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  40329. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  40330. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  40331. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  40332. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  40333. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  40334. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  40335. /** @hidden */
  40336. export var defaultPixelShader: {
  40337. name: string;
  40338. shader: string;
  40339. };
  40340. }
  40341. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  40342. /** @hidden */
  40343. export var defaultVertexDeclaration: {
  40344. name: string;
  40345. shader: string;
  40346. };
  40347. }
  40348. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  40349. /** @hidden */
  40350. export var bumpVertexDeclaration: {
  40351. name: string;
  40352. shader: string;
  40353. };
  40354. }
  40355. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  40356. /** @hidden */
  40357. export var bumpVertex: {
  40358. name: string;
  40359. shader: string;
  40360. };
  40361. }
  40362. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  40363. /** @hidden */
  40364. export var fogVertex: {
  40365. name: string;
  40366. shader: string;
  40367. };
  40368. }
  40369. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  40370. /** @hidden */
  40371. export var shadowsVertex: {
  40372. name: string;
  40373. shader: string;
  40374. };
  40375. }
  40376. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  40377. /** @hidden */
  40378. export var pointCloudVertex: {
  40379. name: string;
  40380. shader: string;
  40381. };
  40382. }
  40383. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  40384. /** @hidden */
  40385. export var logDepthVertex: {
  40386. name: string;
  40387. shader: string;
  40388. };
  40389. }
  40390. declare module "babylonjs/Shaders/default.vertex" {
  40391. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  40392. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  40393. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40394. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  40395. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  40396. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  40397. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  40398. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  40399. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  40400. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  40401. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  40402. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  40403. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  40404. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  40405. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  40406. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  40407. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  40408. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  40409. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  40410. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  40411. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  40412. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  40413. /** @hidden */
  40414. export var defaultVertexShader: {
  40415. name: string;
  40416. shader: string;
  40417. };
  40418. }
  40419. declare module "babylonjs/Materials/standardMaterial" {
  40420. import { SmartArray } from "babylonjs/Misc/smartArray";
  40421. import { IAnimatable } from "babylonjs/Misc/tools";
  40422. import { Nullable } from "babylonjs/types";
  40423. import { Scene } from "babylonjs/scene";
  40424. import { Matrix, Color3 } from "babylonjs/Maths/math";
  40425. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40427. import { Mesh } from "babylonjs/Meshes/mesh";
  40428. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  40429. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40430. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  40431. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  40432. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  40433. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40434. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40435. import "babylonjs/Shaders/default.fragment";
  40436. import "babylonjs/Shaders/default.vertex";
  40437. /** @hidden */
  40438. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40439. MAINUV1: boolean;
  40440. MAINUV2: boolean;
  40441. DIFFUSE: boolean;
  40442. DIFFUSEDIRECTUV: number;
  40443. AMBIENT: boolean;
  40444. AMBIENTDIRECTUV: number;
  40445. OPACITY: boolean;
  40446. OPACITYDIRECTUV: number;
  40447. OPACITYRGB: boolean;
  40448. REFLECTION: boolean;
  40449. EMISSIVE: boolean;
  40450. EMISSIVEDIRECTUV: number;
  40451. SPECULAR: boolean;
  40452. SPECULARDIRECTUV: number;
  40453. BUMP: boolean;
  40454. BUMPDIRECTUV: number;
  40455. PARALLAX: boolean;
  40456. PARALLAXOCCLUSION: boolean;
  40457. SPECULAROVERALPHA: boolean;
  40458. CLIPPLANE: boolean;
  40459. CLIPPLANE2: boolean;
  40460. CLIPPLANE3: boolean;
  40461. CLIPPLANE4: boolean;
  40462. ALPHATEST: boolean;
  40463. DEPTHPREPASS: boolean;
  40464. ALPHAFROMDIFFUSE: boolean;
  40465. POINTSIZE: boolean;
  40466. FOG: boolean;
  40467. SPECULARTERM: boolean;
  40468. DIFFUSEFRESNEL: boolean;
  40469. OPACITYFRESNEL: boolean;
  40470. REFLECTIONFRESNEL: boolean;
  40471. REFRACTIONFRESNEL: boolean;
  40472. EMISSIVEFRESNEL: boolean;
  40473. FRESNEL: boolean;
  40474. NORMAL: boolean;
  40475. UV1: boolean;
  40476. UV2: boolean;
  40477. VERTEXCOLOR: boolean;
  40478. VERTEXALPHA: boolean;
  40479. NUM_BONE_INFLUENCERS: number;
  40480. BonesPerMesh: number;
  40481. BONETEXTURE: boolean;
  40482. INSTANCES: boolean;
  40483. GLOSSINESS: boolean;
  40484. ROUGHNESS: boolean;
  40485. EMISSIVEASILLUMINATION: boolean;
  40486. LINKEMISSIVEWITHDIFFUSE: boolean;
  40487. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40488. LIGHTMAP: boolean;
  40489. LIGHTMAPDIRECTUV: number;
  40490. OBJECTSPACE_NORMALMAP: boolean;
  40491. USELIGHTMAPASSHADOWMAP: boolean;
  40492. REFLECTIONMAP_3D: boolean;
  40493. REFLECTIONMAP_SPHERICAL: boolean;
  40494. REFLECTIONMAP_PLANAR: boolean;
  40495. REFLECTIONMAP_CUBIC: boolean;
  40496. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40497. REFLECTIONMAP_PROJECTION: boolean;
  40498. REFLECTIONMAP_SKYBOX: boolean;
  40499. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40500. REFLECTIONMAP_EXPLICIT: boolean;
  40501. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40502. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40503. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40504. INVERTCUBICMAP: boolean;
  40505. LOGARITHMICDEPTH: boolean;
  40506. REFRACTION: boolean;
  40507. REFRACTIONMAP_3D: boolean;
  40508. REFLECTIONOVERALPHA: boolean;
  40509. TWOSIDEDLIGHTING: boolean;
  40510. SHADOWFLOAT: boolean;
  40511. MORPHTARGETS: boolean;
  40512. MORPHTARGETS_NORMAL: boolean;
  40513. MORPHTARGETS_TANGENT: boolean;
  40514. MORPHTARGETS_UV: boolean;
  40515. NUM_MORPH_INFLUENCERS: number;
  40516. NONUNIFORMSCALING: boolean;
  40517. PREMULTIPLYALPHA: boolean;
  40518. IMAGEPROCESSING: boolean;
  40519. VIGNETTE: boolean;
  40520. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40521. VIGNETTEBLENDMODEOPAQUE: boolean;
  40522. TONEMAPPING: boolean;
  40523. TONEMAPPING_ACES: boolean;
  40524. CONTRAST: boolean;
  40525. COLORCURVES: boolean;
  40526. COLORGRADING: boolean;
  40527. COLORGRADING3D: boolean;
  40528. SAMPLER3DGREENDEPTH: boolean;
  40529. SAMPLER3DBGRMAP: boolean;
  40530. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40531. MULTIVIEW: boolean;
  40532. /**
  40533. * If the reflection texture on this material is in linear color space
  40534. * @hidden
  40535. */
  40536. IS_REFLECTION_LINEAR: boolean;
  40537. /**
  40538. * If the refraction texture on this material is in linear color space
  40539. * @hidden
  40540. */
  40541. IS_REFRACTION_LINEAR: boolean;
  40542. EXPOSURE: boolean;
  40543. constructor();
  40544. setReflectionMode(modeToEnable: string): void;
  40545. }
  40546. /**
  40547. * This is the default material used in Babylon. It is the best trade off between quality
  40548. * and performances.
  40549. * @see http://doc.babylonjs.com/babylon101/materials
  40550. */
  40551. export class StandardMaterial extends PushMaterial {
  40552. private _diffuseTexture;
  40553. /**
  40554. * The basic texture of the material as viewed under a light.
  40555. */
  40556. diffuseTexture: Nullable<BaseTexture>;
  40557. private _ambientTexture;
  40558. /**
  40559. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40560. */
  40561. ambientTexture: Nullable<BaseTexture>;
  40562. private _opacityTexture;
  40563. /**
  40564. * Define the transparency of the material from a texture.
  40565. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40566. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40567. */
  40568. opacityTexture: Nullable<BaseTexture>;
  40569. private _reflectionTexture;
  40570. /**
  40571. * Define the texture used to display the reflection.
  40572. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40573. */
  40574. reflectionTexture: Nullable<BaseTexture>;
  40575. private _emissiveTexture;
  40576. /**
  40577. * Define texture of the material as if self lit.
  40578. * This will be mixed in the final result even in the absence of light.
  40579. */
  40580. emissiveTexture: Nullable<BaseTexture>;
  40581. private _specularTexture;
  40582. /**
  40583. * Define how the color and intensity of the highlight given by the light in the material.
  40584. */
  40585. specularTexture: Nullable<BaseTexture>;
  40586. private _bumpTexture;
  40587. /**
  40588. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40589. * 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.
  40590. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40591. */
  40592. bumpTexture: Nullable<BaseTexture>;
  40593. private _lightmapTexture;
  40594. /**
  40595. * Complex lighting can be computationally expensive to compute at runtime.
  40596. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40597. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40598. */
  40599. lightmapTexture: Nullable<BaseTexture>;
  40600. private _refractionTexture;
  40601. /**
  40602. * Define the texture used to display the refraction.
  40603. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40604. */
  40605. refractionTexture: Nullable<BaseTexture>;
  40606. /**
  40607. * The color of the material lit by the environmental background lighting.
  40608. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40609. */
  40610. ambientColor: Color3;
  40611. /**
  40612. * The basic color of the material as viewed under a light.
  40613. */
  40614. diffuseColor: Color3;
  40615. /**
  40616. * Define how the color and intensity of the highlight given by the light in the material.
  40617. */
  40618. specularColor: Color3;
  40619. /**
  40620. * Define the color of the material as if self lit.
  40621. * This will be mixed in the final result even in the absence of light.
  40622. */
  40623. emissiveColor: Color3;
  40624. /**
  40625. * Defines how sharp are the highlights in the material.
  40626. * The bigger the value the sharper giving a more glossy feeling to the result.
  40627. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40628. */
  40629. specularPower: number;
  40630. private _useAlphaFromDiffuseTexture;
  40631. /**
  40632. * Does the transparency come from the diffuse texture alpha channel.
  40633. */
  40634. useAlphaFromDiffuseTexture: boolean;
  40635. private _useEmissiveAsIllumination;
  40636. /**
  40637. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40638. */
  40639. useEmissiveAsIllumination: boolean;
  40640. private _linkEmissiveWithDiffuse;
  40641. /**
  40642. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40643. * the emissive level when the final color is close to one.
  40644. */
  40645. linkEmissiveWithDiffuse: boolean;
  40646. private _useSpecularOverAlpha;
  40647. /**
  40648. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40649. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40650. */
  40651. useSpecularOverAlpha: boolean;
  40652. private _useReflectionOverAlpha;
  40653. /**
  40654. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40655. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40656. */
  40657. useReflectionOverAlpha: boolean;
  40658. private _disableLighting;
  40659. /**
  40660. * Does lights from the scene impacts this material.
  40661. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40662. */
  40663. disableLighting: boolean;
  40664. private _useObjectSpaceNormalMap;
  40665. /**
  40666. * Allows using an object space normal map (instead of tangent space).
  40667. */
  40668. useObjectSpaceNormalMap: boolean;
  40669. private _useParallax;
  40670. /**
  40671. * Is parallax enabled or not.
  40672. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40673. */
  40674. useParallax: boolean;
  40675. private _useParallaxOcclusion;
  40676. /**
  40677. * Is parallax occlusion enabled or not.
  40678. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40679. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40680. */
  40681. useParallaxOcclusion: boolean;
  40682. /**
  40683. * 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.
  40684. */
  40685. parallaxScaleBias: number;
  40686. private _roughness;
  40687. /**
  40688. * Helps to define how blurry the reflections should appears in the material.
  40689. */
  40690. roughness: number;
  40691. /**
  40692. * In case of refraction, define the value of the index of refraction.
  40693. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40694. */
  40695. indexOfRefraction: number;
  40696. /**
  40697. * Invert the refraction texture alongside the y axis.
  40698. * It can be useful with procedural textures or probe for instance.
  40699. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40700. */
  40701. invertRefractionY: boolean;
  40702. /**
  40703. * Defines the alpha limits in alpha test mode.
  40704. */
  40705. alphaCutOff: number;
  40706. private _useLightmapAsShadowmap;
  40707. /**
  40708. * In case of light mapping, define whether the map contains light or shadow informations.
  40709. */
  40710. useLightmapAsShadowmap: boolean;
  40711. private _diffuseFresnelParameters;
  40712. /**
  40713. * Define the diffuse fresnel parameters of the material.
  40714. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40715. */
  40716. diffuseFresnelParameters: FresnelParameters;
  40717. private _opacityFresnelParameters;
  40718. /**
  40719. * Define the opacity fresnel parameters of the material.
  40720. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40721. */
  40722. opacityFresnelParameters: FresnelParameters;
  40723. private _reflectionFresnelParameters;
  40724. /**
  40725. * Define the reflection fresnel parameters of the material.
  40726. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40727. */
  40728. reflectionFresnelParameters: FresnelParameters;
  40729. private _refractionFresnelParameters;
  40730. /**
  40731. * Define the refraction fresnel parameters of the material.
  40732. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40733. */
  40734. refractionFresnelParameters: FresnelParameters;
  40735. private _emissiveFresnelParameters;
  40736. /**
  40737. * Define the emissive fresnel parameters of the material.
  40738. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40739. */
  40740. emissiveFresnelParameters: FresnelParameters;
  40741. private _useReflectionFresnelFromSpecular;
  40742. /**
  40743. * If true automatically deducts the fresnels values from the material specularity.
  40744. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40745. */
  40746. useReflectionFresnelFromSpecular: boolean;
  40747. private _useGlossinessFromSpecularMapAlpha;
  40748. /**
  40749. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40750. */
  40751. useGlossinessFromSpecularMapAlpha: boolean;
  40752. private _maxSimultaneousLights;
  40753. /**
  40754. * Defines the maximum number of lights that can be used in the material
  40755. */
  40756. maxSimultaneousLights: number;
  40757. private _invertNormalMapX;
  40758. /**
  40759. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40760. */
  40761. invertNormalMapX: boolean;
  40762. private _invertNormalMapY;
  40763. /**
  40764. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40765. */
  40766. invertNormalMapY: boolean;
  40767. private _twoSidedLighting;
  40768. /**
  40769. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40770. */
  40771. twoSidedLighting: boolean;
  40772. /**
  40773. * Default configuration related to image processing available in the standard Material.
  40774. */
  40775. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40776. /**
  40777. * Gets the image processing configuration used either in this material.
  40778. */
  40779. /**
  40780. * Sets the Default image processing configuration used either in the this material.
  40781. *
  40782. * If sets to null, the scene one is in use.
  40783. */
  40784. imageProcessingConfiguration: ImageProcessingConfiguration;
  40785. /**
  40786. * Keep track of the image processing observer to allow dispose and replace.
  40787. */
  40788. private _imageProcessingObserver;
  40789. /**
  40790. * Attaches a new image processing configuration to the Standard Material.
  40791. * @param configuration
  40792. */
  40793. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40794. /**
  40795. * Gets wether the color curves effect is enabled.
  40796. */
  40797. /**
  40798. * Sets wether the color curves effect is enabled.
  40799. */
  40800. cameraColorCurvesEnabled: boolean;
  40801. /**
  40802. * Gets wether the color grading effect is enabled.
  40803. */
  40804. /**
  40805. * Gets wether the color grading effect is enabled.
  40806. */
  40807. cameraColorGradingEnabled: boolean;
  40808. /**
  40809. * Gets wether tonemapping is enabled or not.
  40810. */
  40811. /**
  40812. * Sets wether tonemapping is enabled or not
  40813. */
  40814. cameraToneMappingEnabled: boolean;
  40815. /**
  40816. * The camera exposure used on this material.
  40817. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40818. * This corresponds to a photographic exposure.
  40819. */
  40820. /**
  40821. * The camera exposure used on this material.
  40822. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40823. * This corresponds to a photographic exposure.
  40824. */
  40825. cameraExposure: number;
  40826. /**
  40827. * Gets The camera contrast used on this material.
  40828. */
  40829. /**
  40830. * Sets The camera contrast used on this material.
  40831. */
  40832. cameraContrast: number;
  40833. /**
  40834. * Gets the Color Grading 2D Lookup Texture.
  40835. */
  40836. /**
  40837. * Sets the Color Grading 2D Lookup Texture.
  40838. */
  40839. cameraColorGradingTexture: Nullable<BaseTexture>;
  40840. /**
  40841. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40842. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40843. * 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;
  40844. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40845. */
  40846. /**
  40847. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40848. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40849. * 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;
  40850. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40851. */
  40852. cameraColorCurves: Nullable<ColorCurves>;
  40853. /**
  40854. * Custom callback helping to override the default shader used in the material.
  40855. */
  40856. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40857. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40858. protected _worldViewProjectionMatrix: Matrix;
  40859. protected _globalAmbientColor: Color3;
  40860. protected _useLogarithmicDepth: boolean;
  40861. /**
  40862. * Instantiates a new standard material.
  40863. * This is the default material used in Babylon. It is the best trade off between quality
  40864. * and performances.
  40865. * @see http://doc.babylonjs.com/babylon101/materials
  40866. * @param name Define the name of the material in the scene
  40867. * @param scene Define the scene the material belong to
  40868. */
  40869. constructor(name: string, scene: Scene);
  40870. /**
  40871. * Gets a boolean indicating that current material needs to register RTT
  40872. */
  40873. readonly hasRenderTargetTextures: boolean;
  40874. /**
  40875. * Gets the current class name of the material e.g. "StandardMaterial"
  40876. * Mainly use in serialization.
  40877. * @returns the class name
  40878. */
  40879. getClassName(): string;
  40880. /**
  40881. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40882. * You can try switching to logarithmic depth.
  40883. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40884. */
  40885. useLogarithmicDepth: boolean;
  40886. /**
  40887. * Specifies if the material will require alpha blending
  40888. * @returns a boolean specifying if alpha blending is needed
  40889. */
  40890. needAlphaBlending(): boolean;
  40891. /**
  40892. * Specifies if this material should be rendered in alpha test mode
  40893. * @returns a boolean specifying if an alpha test is needed.
  40894. */
  40895. needAlphaTesting(): boolean;
  40896. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40897. /**
  40898. * Get the texture used for alpha test purpose.
  40899. * @returns the diffuse texture in case of the standard material.
  40900. */
  40901. getAlphaTestTexture(): Nullable<BaseTexture>;
  40902. /**
  40903. * Get if the submesh is ready to be used and all its information available.
  40904. * Child classes can use it to update shaders
  40905. * @param mesh defines the mesh to check
  40906. * @param subMesh defines which submesh to check
  40907. * @param useInstances specifies that instances should be used
  40908. * @returns a boolean indicating that the submesh is ready or not
  40909. */
  40910. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40911. /**
  40912. * Builds the material UBO layouts.
  40913. * Used internally during the effect preparation.
  40914. */
  40915. buildUniformLayout(): void;
  40916. /**
  40917. * Unbinds the material from the mesh
  40918. */
  40919. unbind(): void;
  40920. /**
  40921. * Binds the submesh to this material by preparing the effect and shader to draw
  40922. * @param world defines the world transformation matrix
  40923. * @param mesh defines the mesh containing the submesh
  40924. * @param subMesh defines the submesh to bind the material to
  40925. */
  40926. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40927. /**
  40928. * Get the list of animatables in the material.
  40929. * @returns the list of animatables object used in the material
  40930. */
  40931. getAnimatables(): IAnimatable[];
  40932. /**
  40933. * Gets the active textures from the material
  40934. * @returns an array of textures
  40935. */
  40936. getActiveTextures(): BaseTexture[];
  40937. /**
  40938. * Specifies if the material uses a texture
  40939. * @param texture defines the texture to check against the material
  40940. * @returns a boolean specifying if the material uses the texture
  40941. */
  40942. hasTexture(texture: BaseTexture): boolean;
  40943. /**
  40944. * Disposes the material
  40945. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40946. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40947. */
  40948. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40949. /**
  40950. * Makes a duplicate of the material, and gives it a new name
  40951. * @param name defines the new name for the duplicated material
  40952. * @returns the cloned material
  40953. */
  40954. clone(name: string): StandardMaterial;
  40955. /**
  40956. * Serializes this material in a JSON representation
  40957. * @returns the serialized material object
  40958. */
  40959. serialize(): any;
  40960. /**
  40961. * Creates a standard material from parsed material data
  40962. * @param source defines the JSON representation of the material
  40963. * @param scene defines the hosting scene
  40964. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40965. * @returns a new standard material
  40966. */
  40967. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40968. /**
  40969. * Are diffuse textures enabled in the application.
  40970. */
  40971. static DiffuseTextureEnabled: boolean;
  40972. /**
  40973. * Are ambient textures enabled in the application.
  40974. */
  40975. static AmbientTextureEnabled: boolean;
  40976. /**
  40977. * Are opacity textures enabled in the application.
  40978. */
  40979. static OpacityTextureEnabled: boolean;
  40980. /**
  40981. * Are reflection textures enabled in the application.
  40982. */
  40983. static ReflectionTextureEnabled: boolean;
  40984. /**
  40985. * Are emissive textures enabled in the application.
  40986. */
  40987. static EmissiveTextureEnabled: boolean;
  40988. /**
  40989. * Are specular textures enabled in the application.
  40990. */
  40991. static SpecularTextureEnabled: boolean;
  40992. /**
  40993. * Are bump textures enabled in the application.
  40994. */
  40995. static BumpTextureEnabled: boolean;
  40996. /**
  40997. * Are lightmap textures enabled in the application.
  40998. */
  40999. static LightmapTextureEnabled: boolean;
  41000. /**
  41001. * Are refraction textures enabled in the application.
  41002. */
  41003. static RefractionTextureEnabled: boolean;
  41004. /**
  41005. * Are color grading textures enabled in the application.
  41006. */
  41007. static ColorGradingTextureEnabled: boolean;
  41008. /**
  41009. * Are fresnels enabled in the application.
  41010. */
  41011. static FresnelEnabled: boolean;
  41012. }
  41013. }
  41014. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  41015. import { Scene } from "babylonjs/scene";
  41016. import { Texture } from "babylonjs/Materials/Textures/texture";
  41017. /**
  41018. * A class extending Texture allowing drawing on a texture
  41019. * @see http://doc.babylonjs.com/how_to/dynamictexture
  41020. */
  41021. export class DynamicTexture extends Texture {
  41022. private _generateMipMaps;
  41023. private _canvas;
  41024. private _context;
  41025. private _engine;
  41026. /**
  41027. * Creates a DynamicTexture
  41028. * @param name defines the name of the texture
  41029. * @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
  41030. * @param scene defines the scene where you want the texture
  41031. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  41032. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  41033. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  41034. */
  41035. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  41036. /**
  41037. * Get the current class name of the texture useful for serialization or dynamic coding.
  41038. * @returns "DynamicTexture"
  41039. */
  41040. getClassName(): string;
  41041. /**
  41042. * Gets the current state of canRescale
  41043. */
  41044. readonly canRescale: boolean;
  41045. private _recreate;
  41046. /**
  41047. * Scales the texture
  41048. * @param ratio the scale factor to apply to both width and height
  41049. */
  41050. scale(ratio: number): void;
  41051. /**
  41052. * Resizes the texture
  41053. * @param width the new width
  41054. * @param height the new height
  41055. */
  41056. scaleTo(width: number, height: number): void;
  41057. /**
  41058. * Gets the context of the canvas used by the texture
  41059. * @returns the canvas context of the dynamic texture
  41060. */
  41061. getContext(): CanvasRenderingContext2D;
  41062. /**
  41063. * Clears the texture
  41064. */
  41065. clear(): void;
  41066. /**
  41067. * Updates the texture
  41068. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41069. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  41070. */
  41071. update(invertY?: boolean, premulAlpha?: boolean): void;
  41072. /**
  41073. * Draws text onto the texture
  41074. * @param text defines the text to be drawn
  41075. * @param x defines the placement of the text from the left
  41076. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  41077. * @param font defines the font to be used with font-style, font-size, font-name
  41078. * @param color defines the color used for the text
  41079. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  41080. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  41081. * @param update defines whether texture is immediately update (default is true)
  41082. */
  41083. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  41084. /**
  41085. * Clones the texture
  41086. * @returns the clone of the texture.
  41087. */
  41088. clone(): DynamicTexture;
  41089. /**
  41090. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  41091. * @returns a serialized dynamic texture object
  41092. */
  41093. serialize(): any;
  41094. /** @hidden */
  41095. _rebuild(): void;
  41096. }
  41097. }
  41098. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  41099. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41100. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41101. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41102. /** @hidden */
  41103. export var imageProcessingPixelShader: {
  41104. name: string;
  41105. shader: string;
  41106. };
  41107. }
  41108. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  41109. import { Nullable } from "babylonjs/types";
  41110. import { Color4 } from "babylonjs/Maths/math";
  41111. import { Camera } from "babylonjs/Cameras/camera";
  41112. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41113. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41114. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  41115. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  41116. import { Engine } from "babylonjs/Engines/engine";
  41117. import "babylonjs/Shaders/imageProcessing.fragment";
  41118. import "babylonjs/Shaders/postprocess.vertex";
  41119. /**
  41120. * ImageProcessingPostProcess
  41121. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41122. */
  41123. export class ImageProcessingPostProcess extends PostProcess {
  41124. /**
  41125. * Default configuration related to image processing available in the PBR Material.
  41126. */
  41127. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41128. /**
  41129. * Gets the image processing configuration used either in this material.
  41130. */
  41131. /**
  41132. * Sets the Default image processing configuration used either in the this material.
  41133. *
  41134. * If sets to null, the scene one is in use.
  41135. */
  41136. imageProcessingConfiguration: ImageProcessingConfiguration;
  41137. /**
  41138. * Keep track of the image processing observer to allow dispose and replace.
  41139. */
  41140. private _imageProcessingObserver;
  41141. /**
  41142. * Attaches a new image processing configuration to the PBR Material.
  41143. * @param configuration
  41144. */
  41145. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41146. /**
  41147. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41148. */
  41149. /**
  41150. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  41151. */
  41152. colorCurves: Nullable<ColorCurves>;
  41153. /**
  41154. * Gets wether the color curves effect is enabled.
  41155. */
  41156. /**
  41157. * Sets wether the color curves effect is enabled.
  41158. */
  41159. colorCurvesEnabled: boolean;
  41160. /**
  41161. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41162. */
  41163. /**
  41164. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  41165. */
  41166. colorGradingTexture: Nullable<BaseTexture>;
  41167. /**
  41168. * Gets wether the color grading effect is enabled.
  41169. */
  41170. /**
  41171. * Gets wether the color grading effect is enabled.
  41172. */
  41173. colorGradingEnabled: boolean;
  41174. /**
  41175. * Gets exposure used in the effect.
  41176. */
  41177. /**
  41178. * Sets exposure used in the effect.
  41179. */
  41180. exposure: number;
  41181. /**
  41182. * Gets wether tonemapping is enabled or not.
  41183. */
  41184. /**
  41185. * Sets wether tonemapping is enabled or not
  41186. */
  41187. toneMappingEnabled: boolean;
  41188. /**
  41189. * Gets the type of tone mapping effect.
  41190. */
  41191. /**
  41192. * Sets the type of tone mapping effect.
  41193. */
  41194. toneMappingType: number;
  41195. /**
  41196. * Gets contrast used in the effect.
  41197. */
  41198. /**
  41199. * Sets contrast used in the effect.
  41200. */
  41201. contrast: number;
  41202. /**
  41203. * Gets Vignette stretch size.
  41204. */
  41205. /**
  41206. * Sets Vignette stretch size.
  41207. */
  41208. vignetteStretch: number;
  41209. /**
  41210. * Gets Vignette centre X Offset.
  41211. */
  41212. /**
  41213. * Sets Vignette centre X Offset.
  41214. */
  41215. vignetteCentreX: number;
  41216. /**
  41217. * Gets Vignette centre Y Offset.
  41218. */
  41219. /**
  41220. * Sets Vignette centre Y Offset.
  41221. */
  41222. vignetteCentreY: number;
  41223. /**
  41224. * Gets Vignette weight or intensity of the vignette effect.
  41225. */
  41226. /**
  41227. * Sets Vignette weight or intensity of the vignette effect.
  41228. */
  41229. vignetteWeight: number;
  41230. /**
  41231. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41232. * if vignetteEnabled is set to true.
  41233. */
  41234. /**
  41235. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  41236. * if vignetteEnabled is set to true.
  41237. */
  41238. vignetteColor: Color4;
  41239. /**
  41240. * Gets Camera field of view used by the Vignette effect.
  41241. */
  41242. /**
  41243. * Sets Camera field of view used by the Vignette effect.
  41244. */
  41245. vignetteCameraFov: number;
  41246. /**
  41247. * Gets the vignette blend mode allowing different kind of effect.
  41248. */
  41249. /**
  41250. * Sets the vignette blend mode allowing different kind of effect.
  41251. */
  41252. vignetteBlendMode: number;
  41253. /**
  41254. * Gets wether the vignette effect is enabled.
  41255. */
  41256. /**
  41257. * Sets wether the vignette effect is enabled.
  41258. */
  41259. vignetteEnabled: boolean;
  41260. private _fromLinearSpace;
  41261. /**
  41262. * Gets wether the input of the processing is in Gamma or Linear Space.
  41263. */
  41264. /**
  41265. * Sets wether the input of the processing is in Gamma or Linear Space.
  41266. */
  41267. fromLinearSpace: boolean;
  41268. /**
  41269. * Defines cache preventing GC.
  41270. */
  41271. private _defines;
  41272. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  41273. /**
  41274. * "ImageProcessingPostProcess"
  41275. * @returns "ImageProcessingPostProcess"
  41276. */
  41277. getClassName(): string;
  41278. protected _updateParameters(): void;
  41279. dispose(camera?: Camera): void;
  41280. }
  41281. }
  41282. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  41283. import { Scene } from "babylonjs/scene";
  41284. import { Color3 } from "babylonjs/Maths/math";
  41285. import { Mesh } from "babylonjs/Meshes/mesh";
  41286. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  41287. import { Nullable } from "babylonjs/types";
  41288. /**
  41289. * Class containing static functions to help procedurally build meshes
  41290. */
  41291. export class GroundBuilder {
  41292. /**
  41293. * Creates a ground mesh
  41294. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  41295. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  41296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41297. * @param name defines the name of the mesh
  41298. * @param options defines the options used to create the mesh
  41299. * @param scene defines the hosting scene
  41300. * @returns the ground mesh
  41301. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  41302. */
  41303. static CreateGround(name: string, options: {
  41304. width?: number;
  41305. height?: number;
  41306. subdivisions?: number;
  41307. subdivisionsX?: number;
  41308. subdivisionsY?: number;
  41309. updatable?: boolean;
  41310. }, scene: any): Mesh;
  41311. /**
  41312. * Creates a tiled ground mesh
  41313. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  41314. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  41315. * * 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
  41316. * * 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
  41317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41318. * @param name defines the name of the mesh
  41319. * @param options defines the options used to create the mesh
  41320. * @param scene defines the hosting scene
  41321. * @returns the tiled ground mesh
  41322. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  41323. */
  41324. static CreateTiledGround(name: string, options: {
  41325. xmin: number;
  41326. zmin: number;
  41327. xmax: number;
  41328. zmax: number;
  41329. subdivisions?: {
  41330. w: number;
  41331. h: number;
  41332. };
  41333. precision?: {
  41334. w: number;
  41335. h: number;
  41336. };
  41337. updatable?: boolean;
  41338. }, scene?: Nullable<Scene>): Mesh;
  41339. /**
  41340. * Creates a ground mesh from a height map
  41341. * * The parameter `url` sets the URL of the height map image resource.
  41342. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  41343. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  41344. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  41345. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  41346. * * 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.
  41347. * * 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).
  41348. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  41349. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41350. * @param name defines the name of the mesh
  41351. * @param url defines the url to the height map
  41352. * @param options defines the options used to create the mesh
  41353. * @param scene defines the hosting scene
  41354. * @returns the ground mesh
  41355. * @see https://doc.babylonjs.com/babylon101/height_map
  41356. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  41357. */
  41358. static CreateGroundFromHeightMap(name: string, url: string, options: {
  41359. width?: number;
  41360. height?: number;
  41361. subdivisions?: number;
  41362. minHeight?: number;
  41363. maxHeight?: number;
  41364. colorFilter?: Color3;
  41365. alphaFilter?: number;
  41366. updatable?: boolean;
  41367. onReady?: (mesh: GroundMesh) => void;
  41368. }, scene?: Nullable<Scene>): GroundMesh;
  41369. }
  41370. }
  41371. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  41372. import { Vector4 } from "babylonjs/Maths/math";
  41373. import { Mesh } from "babylonjs/Meshes/mesh";
  41374. /**
  41375. * Class containing static functions to help procedurally build meshes
  41376. */
  41377. export class TorusBuilder {
  41378. /**
  41379. * Creates a torus mesh
  41380. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  41381. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  41382. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  41383. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41384. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41385. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41386. * @param name defines the name of the mesh
  41387. * @param options defines the options used to create the mesh
  41388. * @param scene defines the hosting scene
  41389. * @returns the torus mesh
  41390. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  41391. */
  41392. static CreateTorus(name: string, options: {
  41393. diameter?: number;
  41394. thickness?: number;
  41395. tessellation?: number;
  41396. updatable?: boolean;
  41397. sideOrientation?: number;
  41398. frontUVs?: Vector4;
  41399. backUVs?: Vector4;
  41400. }, scene: any): Mesh;
  41401. }
  41402. }
  41403. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  41404. import { Color4, Vector4 } from "babylonjs/Maths/math";
  41405. import { Mesh } from "babylonjs/Meshes/mesh";
  41406. /**
  41407. * Class containing static functions to help procedurally build meshes
  41408. */
  41409. export class CylinderBuilder {
  41410. /**
  41411. * Creates a cylinder or a cone mesh
  41412. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  41413. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  41414. * * 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.
  41415. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  41416. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  41417. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  41418. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  41419. * * 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).
  41420. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  41421. * * 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).
  41422. * * 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
  41423. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  41424. * * 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
  41425. * * 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.
  41426. * * If `enclose` is false, a ring surface is one element.
  41427. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  41428. * * 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
  41429. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41430. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41432. * @param name defines the name of the mesh
  41433. * @param options defines the options used to create the mesh
  41434. * @param scene defines the hosting scene
  41435. * @returns the cylinder mesh
  41436. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41437. */
  41438. static CreateCylinder(name: string, options: {
  41439. height?: number;
  41440. diameterTop?: number;
  41441. diameterBottom?: number;
  41442. diameter?: number;
  41443. tessellation?: number;
  41444. subdivisions?: number;
  41445. arc?: number;
  41446. faceColors?: Color4[];
  41447. faceUV?: Vector4[];
  41448. updatable?: boolean;
  41449. hasRings?: boolean;
  41450. enclose?: boolean;
  41451. cap?: number;
  41452. sideOrientation?: number;
  41453. frontUVs?: Vector4;
  41454. backUVs?: Vector4;
  41455. }, scene: any): Mesh;
  41456. }
  41457. }
  41458. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  41459. import { Observable } from "babylonjs/Misc/observable";
  41460. import { Nullable } from "babylonjs/types";
  41461. import { Camera } from "babylonjs/Cameras/camera";
  41462. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41463. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41464. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  41465. import { Scene } from "babylonjs/scene";
  41466. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41467. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  41468. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41469. import { Mesh } from "babylonjs/Meshes/mesh";
  41470. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  41471. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41472. import "babylonjs/Meshes/Builders/groundBuilder";
  41473. import "babylonjs/Meshes/Builders/torusBuilder";
  41474. import "babylonjs/Meshes/Builders/cylinderBuilder";
  41475. import "babylonjs/Gamepads/gamepadSceneComponent";
  41476. import "babylonjs/Animations/animatable";
  41477. /**
  41478. * Options to modify the vr teleportation behavior.
  41479. */
  41480. export interface VRTeleportationOptions {
  41481. /**
  41482. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41483. */
  41484. floorMeshName?: string;
  41485. /**
  41486. * A list of meshes to be used as the teleportation floor. (default: empty)
  41487. */
  41488. floorMeshes?: Mesh[];
  41489. }
  41490. /**
  41491. * Options to modify the vr experience helper's behavior.
  41492. */
  41493. export interface VRExperienceHelperOptions extends WebVROptions {
  41494. /**
  41495. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41496. */
  41497. createDeviceOrientationCamera?: boolean;
  41498. /**
  41499. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41500. */
  41501. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41502. /**
  41503. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41504. */
  41505. laserToggle?: boolean;
  41506. /**
  41507. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41508. */
  41509. floorMeshes?: Mesh[];
  41510. /**
  41511. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41512. */
  41513. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41514. }
  41515. /**
  41516. * Event containing information after VR has been entered
  41517. */
  41518. export class OnAfterEnteringVRObservableEvent {
  41519. /**
  41520. * If entering vr was successful
  41521. */
  41522. success: boolean;
  41523. }
  41524. /**
  41525. * Helps to quickly add VR support to an existing scene.
  41526. * See http://doc.babylonjs.com/how_to/webvr_helper
  41527. */
  41528. export class VRExperienceHelper {
  41529. /** Options to modify the vr experience helper's behavior. */
  41530. webVROptions: VRExperienceHelperOptions;
  41531. private _scene;
  41532. private _position;
  41533. private _btnVR;
  41534. private _btnVRDisplayed;
  41535. private _webVRsupported;
  41536. private _webVRready;
  41537. private _webVRrequesting;
  41538. private _webVRpresenting;
  41539. private _hasEnteredVR;
  41540. private _fullscreenVRpresenting;
  41541. private _canvas;
  41542. private _webVRCamera;
  41543. private _vrDeviceOrientationCamera;
  41544. private _deviceOrientationCamera;
  41545. private _existingCamera;
  41546. private _onKeyDown;
  41547. private _onVrDisplayPresentChange;
  41548. private _onVRDisplayChanged;
  41549. private _onVRRequestPresentStart;
  41550. private _onVRRequestPresentComplete;
  41551. /**
  41552. * Observable raised right before entering VR.
  41553. */
  41554. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41555. /**
  41556. * Observable raised when entering VR has completed.
  41557. */
  41558. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41559. /**
  41560. * Observable raised when exiting VR.
  41561. */
  41562. onExitingVRObservable: Observable<VRExperienceHelper>;
  41563. /**
  41564. * Observable raised when controller mesh is loaded.
  41565. */
  41566. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41567. /** Return this.onEnteringVRObservable
  41568. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41569. */
  41570. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41571. /** Return this.onExitingVRObservable
  41572. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41573. */
  41574. readonly onExitingVR: Observable<VRExperienceHelper>;
  41575. /** Return this.onControllerMeshLoadedObservable
  41576. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41577. */
  41578. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41579. private _rayLength;
  41580. private _useCustomVRButton;
  41581. private _teleportationRequested;
  41582. private _teleportActive;
  41583. private _floorMeshName;
  41584. private _floorMeshesCollection;
  41585. private _rotationAllowed;
  41586. private _teleportBackwardsVector;
  41587. private _teleportationTarget;
  41588. private _isDefaultTeleportationTarget;
  41589. private _postProcessMove;
  41590. private _teleportationFillColor;
  41591. private _teleportationBorderColor;
  41592. private _rotationAngle;
  41593. private _haloCenter;
  41594. private _cameraGazer;
  41595. private _padSensibilityUp;
  41596. private _padSensibilityDown;
  41597. private _leftController;
  41598. private _rightController;
  41599. /**
  41600. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41601. */
  41602. onNewMeshSelected: Observable<AbstractMesh>;
  41603. /**
  41604. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41605. */
  41606. onNewMeshPicked: Observable<PickingInfo>;
  41607. private _circleEase;
  41608. /**
  41609. * Observable raised before camera teleportation
  41610. */
  41611. onBeforeCameraTeleport: Observable<Vector3>;
  41612. /**
  41613. * Observable raised after camera teleportation
  41614. */
  41615. onAfterCameraTeleport: Observable<Vector3>;
  41616. /**
  41617. * Observable raised when current selected mesh gets unselected
  41618. */
  41619. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41620. private _raySelectionPredicate;
  41621. /**
  41622. * To be optionaly changed by user to define custom ray selection
  41623. */
  41624. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41625. /**
  41626. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41627. */
  41628. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41629. /**
  41630. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41631. */
  41632. teleportationEnabled: boolean;
  41633. private _defaultHeight;
  41634. private _teleportationInitialized;
  41635. private _interactionsEnabled;
  41636. private _interactionsRequested;
  41637. private _displayGaze;
  41638. private _displayLaserPointer;
  41639. /**
  41640. * The mesh used to display where the user is going to teleport.
  41641. */
  41642. /**
  41643. * Sets the mesh to be used to display where the user is going to teleport.
  41644. */
  41645. teleportationTarget: Mesh;
  41646. /**
  41647. * 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
  41648. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41649. * See http://doc.babylonjs.com/resources/baking_transformations
  41650. */
  41651. gazeTrackerMesh: Mesh;
  41652. /**
  41653. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41654. */
  41655. updateGazeTrackerScale: boolean;
  41656. /**
  41657. * If the gaze trackers color should be updated when selecting meshes
  41658. */
  41659. updateGazeTrackerColor: boolean;
  41660. /**
  41661. * The gaze tracking mesh corresponding to the left controller
  41662. */
  41663. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41664. /**
  41665. * The gaze tracking mesh corresponding to the right controller
  41666. */
  41667. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41668. /**
  41669. * If the ray of the gaze should be displayed.
  41670. */
  41671. /**
  41672. * Sets if the ray of the gaze should be displayed.
  41673. */
  41674. displayGaze: boolean;
  41675. /**
  41676. * If the ray of the LaserPointer should be displayed.
  41677. */
  41678. /**
  41679. * Sets if the ray of the LaserPointer should be displayed.
  41680. */
  41681. displayLaserPointer: boolean;
  41682. /**
  41683. * The deviceOrientationCamera used as the camera when not in VR.
  41684. */
  41685. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41686. /**
  41687. * Based on the current WebVR support, returns the current VR camera used.
  41688. */
  41689. readonly currentVRCamera: Nullable<Camera>;
  41690. /**
  41691. * The webVRCamera which is used when in VR.
  41692. */
  41693. readonly webVRCamera: WebVRFreeCamera;
  41694. /**
  41695. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41696. */
  41697. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41698. private readonly _teleportationRequestInitiated;
  41699. /**
  41700. * Defines wether or not Pointer lock should be requested when switching to
  41701. * full screen.
  41702. */
  41703. requestPointerLockOnFullScreen: boolean;
  41704. /**
  41705. * Instantiates a VRExperienceHelper.
  41706. * Helps to quickly add VR support to an existing scene.
  41707. * @param scene The scene the VRExperienceHelper belongs to.
  41708. * @param webVROptions Options to modify the vr experience helper's behavior.
  41709. */
  41710. constructor(scene: Scene,
  41711. /** Options to modify the vr experience helper's behavior. */
  41712. webVROptions?: VRExperienceHelperOptions);
  41713. private _onDefaultMeshLoaded;
  41714. private _onResize;
  41715. private _onFullscreenChange;
  41716. /**
  41717. * Gets a value indicating if we are currently in VR mode.
  41718. */
  41719. readonly isInVRMode: boolean;
  41720. private onVrDisplayPresentChange;
  41721. private onVRDisplayChanged;
  41722. private moveButtonToBottomRight;
  41723. private displayVRButton;
  41724. private updateButtonVisibility;
  41725. private _cachedAngularSensibility;
  41726. /**
  41727. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41728. * Otherwise, will use the fullscreen API.
  41729. */
  41730. enterVR(): void;
  41731. /**
  41732. * Attempt to exit VR, or fullscreen.
  41733. */
  41734. exitVR(): void;
  41735. /**
  41736. * The position of the vr experience helper.
  41737. */
  41738. /**
  41739. * Sets the position of the vr experience helper.
  41740. */
  41741. position: Vector3;
  41742. /**
  41743. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41744. */
  41745. enableInteractions(): void;
  41746. private readonly _noControllerIsActive;
  41747. private beforeRender;
  41748. private _isTeleportationFloor;
  41749. /**
  41750. * Adds a floor mesh to be used for teleportation.
  41751. * @param floorMesh the mesh to be used for teleportation.
  41752. */
  41753. addFloorMesh(floorMesh: Mesh): void;
  41754. /**
  41755. * Removes a floor mesh from being used for teleportation.
  41756. * @param floorMesh the mesh to be removed.
  41757. */
  41758. removeFloorMesh(floorMesh: Mesh): void;
  41759. /**
  41760. * Enables interactions and teleportation using the VR controllers and gaze.
  41761. * @param vrTeleportationOptions options to modify teleportation behavior.
  41762. */
  41763. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41764. private _onNewGamepadConnected;
  41765. private _tryEnableInteractionOnController;
  41766. private _onNewGamepadDisconnected;
  41767. private _enableInteractionOnController;
  41768. private _checkTeleportWithRay;
  41769. private _checkRotate;
  41770. private _checkTeleportBackwards;
  41771. private _enableTeleportationOnController;
  41772. private _createTeleportationCircles;
  41773. private _displayTeleportationTarget;
  41774. private _hideTeleportationTarget;
  41775. private _rotateCamera;
  41776. private _moveTeleportationSelectorTo;
  41777. private _workingVector;
  41778. private _workingQuaternion;
  41779. private _workingMatrix;
  41780. /**
  41781. * Teleports the users feet to the desired location
  41782. * @param location The location where the user's feet should be placed
  41783. */
  41784. teleportCamera(location: Vector3): void;
  41785. private _convertNormalToDirectionOfRay;
  41786. private _castRayAndSelectObject;
  41787. private _notifySelectedMeshUnselected;
  41788. /**
  41789. * Sets the color of the laser ray from the vr controllers.
  41790. * @param color new color for the ray.
  41791. */
  41792. changeLaserColor(color: Color3): void;
  41793. /**
  41794. * Sets the color of the ray from the vr headsets gaze.
  41795. * @param color new color for the ray.
  41796. */
  41797. changeGazeColor(color: Color3): void;
  41798. /**
  41799. * Exits VR and disposes of the vr experience helper
  41800. */
  41801. dispose(): void;
  41802. /**
  41803. * Gets the name of the VRExperienceHelper class
  41804. * @returns "VRExperienceHelper"
  41805. */
  41806. getClassName(): string;
  41807. }
  41808. }
  41809. declare module "babylonjs/Cameras/VR/index" {
  41810. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  41811. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  41812. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41813. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  41814. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  41815. export * from "babylonjs/Cameras/VR/webVRCamera";
  41816. }
  41817. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  41818. import { Observable } from "babylonjs/Misc/observable";
  41819. import { Nullable } from "babylonjs/types";
  41820. import { IDisposable, Scene } from "babylonjs/scene";
  41821. import { Vector3 } from "babylonjs/Maths/math";
  41822. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41823. import { Ray } from "babylonjs/Culling/ray";
  41824. /**
  41825. * Manages an XRSession
  41826. * @see https://doc.babylonjs.com/how_to/webxr
  41827. */
  41828. export class WebXRSessionManager implements IDisposable {
  41829. private scene;
  41830. /**
  41831. * Fires every time a new xrFrame arrives which can be used to update the camera
  41832. */
  41833. onXRFrameObservable: Observable<any>;
  41834. /**
  41835. * Fires when the xr session is ended either by the device or manually done
  41836. */
  41837. onXRSessionEnded: Observable<any>;
  41838. /** @hidden */
  41839. _xrSession: XRSession;
  41840. /** @hidden */
  41841. _frameOfReference: XRFrameOfReference;
  41842. /** @hidden */
  41843. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41844. /** @hidden */
  41845. _currentXRFrame: Nullable<XRFrame>;
  41846. private _xrNavigator;
  41847. private _xrDevice;
  41848. private _tmpMatrix;
  41849. /**
  41850. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41851. * @param scene The scene which the session should be created for
  41852. */
  41853. constructor(scene: Scene);
  41854. /**
  41855. * Initializes the manager
  41856. * After initialization enterXR can be called to start an XR session
  41857. * @returns Promise which resolves after it is initialized
  41858. */
  41859. initializeAsync(): Promise<void>;
  41860. /**
  41861. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  41862. * @param sessionCreationOptions xr options to create the session with
  41863. * @param frameOfReferenceType option to configure how the xr pose is expressed
  41864. * @returns Promise which resolves after it enters XR
  41865. */
  41866. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  41867. /**
  41868. * Stops the xrSession and restores the renderloop
  41869. * @returns Promise which resolves after it exits XR
  41870. */
  41871. exitXRAsync(): Promise<void>;
  41872. /**
  41873. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41874. * @param ray ray to cast into the environment
  41875. * @returns Promise which resolves with a collision point in the environment if it exists
  41876. */
  41877. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41878. /**
  41879. * Checks if a session would be supported for the creation options specified
  41880. * @param options creation options to check if they are supported
  41881. * @returns true if supported
  41882. */
  41883. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41884. /**
  41885. * @hidden
  41886. * Converts the render layer of xrSession to a render target
  41887. * @param session session to create render target for
  41888. * @param scene scene the new render target should be created for
  41889. */
  41890. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  41891. /**
  41892. * Disposes of the session manager
  41893. */
  41894. dispose(): void;
  41895. }
  41896. }
  41897. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41898. import { Scene } from "babylonjs/scene";
  41899. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41900. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41901. /**
  41902. * WebXR Camera which holds the views for the xrSession
  41903. * @see https://doc.babylonjs.com/how_to/webxr
  41904. */
  41905. export class WebXRCamera extends FreeCamera {
  41906. private static _TmpMatrix;
  41907. /**
  41908. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41909. * @param name the name of the camera
  41910. * @param scene the scene to add the camera to
  41911. */
  41912. constructor(name: string, scene: Scene);
  41913. private _updateNumberOfRigCameras;
  41914. /** @hidden */
  41915. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41916. /**
  41917. * Updates the cameras position from the current pose information of the XR session
  41918. * @param xrSessionManager the session containing pose information
  41919. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41920. */
  41921. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41922. }
  41923. }
  41924. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  41925. import { Nullable } from "babylonjs/types";
  41926. import { Observable } from "babylonjs/Misc/observable";
  41927. import { IDisposable, Scene } from "babylonjs/scene";
  41928. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  41929. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41930. import { Ray } from "babylonjs/Culling/ray";
  41931. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41932. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  41933. /**
  41934. * States of the webXR experience
  41935. */
  41936. export enum WebXRState {
  41937. /**
  41938. * Transitioning to being in XR mode
  41939. */
  41940. ENTERING_XR = 0,
  41941. /**
  41942. * Transitioning to non XR mode
  41943. */
  41944. EXITING_XR = 1,
  41945. /**
  41946. * In XR mode and presenting
  41947. */
  41948. IN_XR = 2,
  41949. /**
  41950. * Not entered XR mode
  41951. */
  41952. NOT_IN_XR = 3
  41953. }
  41954. /**
  41955. * Helper class used to enable XR
  41956. * @see https://doc.babylonjs.com/how_to/webxr
  41957. */
  41958. export class WebXRExperienceHelper implements IDisposable {
  41959. private scene;
  41960. /**
  41961. * 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
  41962. */
  41963. container: AbstractMesh;
  41964. /**
  41965. * Camera used to render xr content
  41966. */
  41967. camera: WebXRCamera;
  41968. /**
  41969. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41970. */
  41971. state: WebXRState;
  41972. private _setState;
  41973. private static _TmpVector;
  41974. /**
  41975. * Fires when the state of the experience helper has changed
  41976. */
  41977. onStateChangedObservable: Observable<WebXRState>;
  41978. /** @hidden */
  41979. _sessionManager: WebXRSessionManager;
  41980. private _nonVRCamera;
  41981. private _originalSceneAutoClear;
  41982. private _supported;
  41983. /**
  41984. * Creates the experience helper
  41985. * @param scene the scene to attach the experience helper to
  41986. * @returns a promise for the experience helper
  41987. */
  41988. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41989. /**
  41990. * Creates a WebXRExperienceHelper
  41991. * @param scene The scene the helper should be created in
  41992. */
  41993. private constructor();
  41994. /**
  41995. * Exits XR mode and returns the scene to its original state
  41996. * @returns promise that resolves after xr mode has exited
  41997. */
  41998. exitXRAsync(): Promise<void>;
  41999. /**
  42000. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42001. * @param sessionCreationOptions options for the XR session
  42002. * @param frameOfReference frame of reference of the XR session
  42003. * @returns promise that resolves after xr mode has entered
  42004. */
  42005. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  42006. /**
  42007. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  42008. * @param ray ray to cast into the environment
  42009. * @returns Promise which resolves with a collision point in the environment if it exists
  42010. */
  42011. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  42012. /**
  42013. * Updates the global position of the camera by moving the camera's container
  42014. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  42015. * @param position The desired global position of the camera
  42016. */
  42017. setPositionOfCameraUsingContainer(position: Vector3): void;
  42018. /**
  42019. * Rotates the xr camera by rotating the camera's container around the camera's position
  42020. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  42021. * @param rotation the desired quaternion rotation to apply to the camera
  42022. */
  42023. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  42024. /**
  42025. * Checks if the creation options are supported by the xr session
  42026. * @param options creation options
  42027. * @returns true if supported
  42028. */
  42029. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  42030. /**
  42031. * Disposes of the experience helper
  42032. */
  42033. dispose(): void;
  42034. }
  42035. }
  42036. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  42037. import { Nullable } from "babylonjs/types";
  42038. import { Observable } from "babylonjs/Misc/observable";
  42039. import { IDisposable, Scene } from "babylonjs/scene";
  42040. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42041. /**
  42042. * Button which can be used to enter a different mode of XR
  42043. */
  42044. export class WebXREnterExitUIButton {
  42045. /** button element */
  42046. element: HTMLElement;
  42047. /** XR initialization options for the button */
  42048. initializationOptions: XRSessionCreationOptions;
  42049. /**
  42050. * Creates a WebXREnterExitUIButton
  42051. * @param element button element
  42052. * @param initializationOptions XR initialization options for the button
  42053. */
  42054. constructor(
  42055. /** button element */
  42056. element: HTMLElement,
  42057. /** XR initialization options for the button */
  42058. initializationOptions: XRSessionCreationOptions);
  42059. /**
  42060. * Overwritable function which can be used to update the button's visuals when the state changes
  42061. * @param activeButton the current active button in the UI
  42062. */
  42063. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  42064. }
  42065. /**
  42066. * Options to create the webXR UI
  42067. */
  42068. export class WebXREnterExitUIOptions {
  42069. /**
  42070. * Context to enter xr with
  42071. */
  42072. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  42073. /**
  42074. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  42075. */
  42076. customButtons?: Array<WebXREnterExitUIButton>;
  42077. }
  42078. /**
  42079. * UI to allow the user to enter/exit XR mode
  42080. */
  42081. export class WebXREnterExitUI implements IDisposable {
  42082. private scene;
  42083. private _overlay;
  42084. private _buttons;
  42085. private _activeButton;
  42086. /**
  42087. * Fired every time the active button is changed.
  42088. *
  42089. * When xr is entered via a button that launches xr that button will be the callback parameter
  42090. *
  42091. * When exiting xr the callback parameter will be null)
  42092. */
  42093. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  42094. /**
  42095. * Creates UI to allow the user to enter/exit XR mode
  42096. * @param scene the scene to add the ui to
  42097. * @param helper the xr experience helper to enter/exit xr with
  42098. * @param options options to configure the UI
  42099. * @returns the created ui
  42100. */
  42101. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  42102. private constructor();
  42103. private _updateButtons;
  42104. /**
  42105. * Disposes of the object
  42106. */
  42107. dispose(): void;
  42108. }
  42109. }
  42110. declare module "babylonjs/Cameras/XR/webXRInput" {
  42111. import { IDisposable, Scene } from "babylonjs/scene";
  42112. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42113. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42114. /**
  42115. * Represents an XR input
  42116. */
  42117. export class WebXRController {
  42118. /**
  42119. * 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
  42120. */
  42121. grip?: AbstractMesh;
  42122. /**
  42123. * Pointer which can be used to select objects or attach a visible laser to
  42124. */
  42125. pointer: AbstractMesh;
  42126. /**
  42127. * Creates the controller
  42128. * @see https://doc.babylonjs.com/how_to/webxr
  42129. * @param scene the scene which the controller should be associated to
  42130. */
  42131. constructor(scene: Scene);
  42132. /**
  42133. * Disposes of the object
  42134. */
  42135. dispose(): void;
  42136. }
  42137. /**
  42138. * XR input used to track XR inputs such as controllers/rays
  42139. */
  42140. export class WebXRInput implements IDisposable {
  42141. private helper;
  42142. /**
  42143. * XR controllers being tracked
  42144. */
  42145. controllers: Array<WebXRController>;
  42146. private _tmpMatrix;
  42147. private _frameObserver;
  42148. /**
  42149. * Initializes the WebXRInput
  42150. * @param helper experience helper which the input should be created for
  42151. */
  42152. constructor(helper: WebXRExperienceHelper);
  42153. /**
  42154. * Disposes of the object
  42155. */
  42156. dispose(): void;
  42157. }
  42158. }
  42159. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42160. import { Nullable } from "babylonjs/types";
  42161. import { IDisposable } from "babylonjs/scene";
  42162. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42163. /**
  42164. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42165. */
  42166. export class WebXRManagedOutputCanvas implements IDisposable {
  42167. private _canvas;
  42168. /**
  42169. * xrpresent context of the canvas which can be used to display/mirror xr content
  42170. */
  42171. canvasContext: Nullable<WebGLRenderingContext>;
  42172. /**
  42173. * Initializes the canvas to be added/removed upon entering/exiting xr
  42174. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42175. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42176. */
  42177. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42178. /**
  42179. * Disposes of the object
  42180. */
  42181. dispose(): void;
  42182. private _setManagedOutputCanvas;
  42183. private _addCanvas;
  42184. private _removeCanvas;
  42185. }
  42186. }
  42187. declare module "babylonjs/Cameras/XR/index" {
  42188. export * from "babylonjs/Cameras/XR/webXRCamera";
  42189. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  42190. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42191. export * from "babylonjs/Cameras/XR/webXRInput";
  42192. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42193. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  42194. }
  42195. declare module "babylonjs/Cameras/RigModes/index" {
  42196. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  42197. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  42198. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  42199. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  42200. }
  42201. declare module "babylonjs/Cameras/index" {
  42202. export * from "babylonjs/Cameras/Inputs/index";
  42203. export * from "babylonjs/Cameras/cameraInputsManager";
  42204. export * from "babylonjs/Cameras/camera";
  42205. export * from "babylonjs/Cameras/targetCamera";
  42206. export * from "babylonjs/Cameras/freeCamera";
  42207. export * from "babylonjs/Cameras/freeCameraInputsManager";
  42208. export * from "babylonjs/Cameras/touchCamera";
  42209. export * from "babylonjs/Cameras/arcRotateCamera";
  42210. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  42211. export * from "babylonjs/Cameras/deviceOrientationCamera";
  42212. export * from "babylonjs/Cameras/flyCamera";
  42213. export * from "babylonjs/Cameras/flyCameraInputsManager";
  42214. export * from "babylonjs/Cameras/followCamera";
  42215. export * from "babylonjs/Cameras/gamepadCamera";
  42216. export * from "babylonjs/Cameras/Stereoscopic/index";
  42217. export * from "babylonjs/Cameras/universalCamera";
  42218. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  42219. export * from "babylonjs/Cameras/VR/index";
  42220. export * from "babylonjs/Cameras/XR/index";
  42221. export * from "babylonjs/Cameras/RigModes/index";
  42222. }
  42223. declare module "babylonjs/Collisions/index" {
  42224. export * from "babylonjs/Collisions/collider";
  42225. export * from "babylonjs/Collisions/collisionCoordinator";
  42226. export * from "babylonjs/Collisions/pickingInfo";
  42227. export * from "babylonjs/Collisions/intersectionInfo";
  42228. export * from "babylonjs/Collisions/meshCollisionData";
  42229. }
  42230. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  42231. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  42232. import { Vector3, Plane } from "babylonjs/Maths/math";
  42233. import { Ray } from "babylonjs/Culling/ray";
  42234. /**
  42235. * Contains an array of blocks representing the octree
  42236. */
  42237. export interface IOctreeContainer<T> {
  42238. /**
  42239. * Blocks within the octree
  42240. */
  42241. blocks: Array<OctreeBlock<T>>;
  42242. }
  42243. /**
  42244. * Class used to store a cell in an octree
  42245. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42246. */
  42247. export class OctreeBlock<T> {
  42248. /**
  42249. * Gets the content of the current block
  42250. */
  42251. entries: T[];
  42252. /**
  42253. * Gets the list of block children
  42254. */
  42255. blocks: Array<OctreeBlock<T>>;
  42256. private _depth;
  42257. private _maxDepth;
  42258. private _capacity;
  42259. private _minPoint;
  42260. private _maxPoint;
  42261. private _boundingVectors;
  42262. private _creationFunc;
  42263. /**
  42264. * Creates a new block
  42265. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  42266. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  42267. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42268. * @param depth defines the current depth of this block in the octree
  42269. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  42270. * @param creationFunc defines a callback to call when an element is added to the block
  42271. */
  42272. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  42273. /**
  42274. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  42275. */
  42276. readonly capacity: number;
  42277. /**
  42278. * Gets the minimum vector (in world space) of the block's bounding box
  42279. */
  42280. readonly minPoint: Vector3;
  42281. /**
  42282. * Gets the maximum vector (in world space) of the block's bounding box
  42283. */
  42284. readonly maxPoint: Vector3;
  42285. /**
  42286. * Add a new element to this block
  42287. * @param entry defines the element to add
  42288. */
  42289. addEntry(entry: T): void;
  42290. /**
  42291. * Remove an element from this block
  42292. * @param entry defines the element to remove
  42293. */
  42294. removeEntry(entry: T): void;
  42295. /**
  42296. * Add an array of elements to this block
  42297. * @param entries defines the array of elements to add
  42298. */
  42299. addEntries(entries: T[]): void;
  42300. /**
  42301. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  42302. * @param frustumPlanes defines the frustum planes to test
  42303. * @param selection defines the array to store current content if selection is positive
  42304. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42305. */
  42306. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42307. /**
  42308. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  42309. * @param sphereCenter defines the bounding sphere center
  42310. * @param sphereRadius defines the bounding sphere radius
  42311. * @param selection defines the array to store current content if selection is positive
  42312. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42313. */
  42314. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  42315. /**
  42316. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  42317. * @param ray defines the ray to test with
  42318. * @param selection defines the array to store current content if selection is positive
  42319. */
  42320. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  42321. /**
  42322. * Subdivide the content into child blocks (this block will then be empty)
  42323. */
  42324. createInnerBlocks(): void;
  42325. /**
  42326. * @hidden
  42327. */
  42328. 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;
  42329. }
  42330. }
  42331. declare module "babylonjs/Culling/Octrees/octree" {
  42332. import { SmartArray } from "babylonjs/Misc/smartArray";
  42333. import { Vector3, Plane } from "babylonjs/Maths/math";
  42334. import { SubMesh } from "babylonjs/Meshes/subMesh";
  42335. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42336. import { Ray } from "babylonjs/Culling/ray";
  42337. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  42338. /**
  42339. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  42340. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42341. */
  42342. export class Octree<T> {
  42343. /** 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.) */
  42344. maxDepth: number;
  42345. /**
  42346. * Blocks within the octree containing objects
  42347. */
  42348. blocks: Array<OctreeBlock<T>>;
  42349. /**
  42350. * Content stored in the octree
  42351. */
  42352. dynamicContent: T[];
  42353. private _maxBlockCapacity;
  42354. private _selectionContent;
  42355. private _creationFunc;
  42356. /**
  42357. * Creates a octree
  42358. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42359. * @param creationFunc function to be used to instatiate the octree
  42360. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  42361. * @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.)
  42362. */
  42363. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  42364. /** 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.) */
  42365. maxDepth?: number);
  42366. /**
  42367. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  42368. * @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);
  42369. * @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);
  42370. * @param entries meshes to be added to the octree blocks
  42371. */
  42372. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  42373. /**
  42374. * Adds a mesh to the octree
  42375. * @param entry Mesh to add to the octree
  42376. */
  42377. addMesh(entry: T): void;
  42378. /**
  42379. * Remove an element from the octree
  42380. * @param entry defines the element to remove
  42381. */
  42382. removeMesh(entry: T): void;
  42383. /**
  42384. * Selects an array of meshes within the frustum
  42385. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  42386. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  42387. * @returns array of meshes within the frustum
  42388. */
  42389. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  42390. /**
  42391. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  42392. * @param sphereCenter defines the bounding sphere center
  42393. * @param sphereRadius defines the bounding sphere radius
  42394. * @param allowDuplicate defines if the selection array can contains duplicated entries
  42395. * @returns an array of objects that intersect the sphere
  42396. */
  42397. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  42398. /**
  42399. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  42400. * @param ray defines the ray to test with
  42401. * @returns array of intersected objects
  42402. */
  42403. intersectsRay(ray: Ray): SmartArray<T>;
  42404. /**
  42405. * Adds a mesh into the octree block if it intersects the block
  42406. */
  42407. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  42408. /**
  42409. * Adds a submesh into the octree block if it intersects the block
  42410. */
  42411. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  42412. }
  42413. }
  42414. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  42415. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  42416. import { Scene } from "babylonjs/scene";
  42417. import { SubMesh } from "babylonjs/Meshes/subMesh";
  42418. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42419. import { Ray } from "babylonjs/Culling/ray";
  42420. import { Octree } from "babylonjs/Culling/Octrees/octree";
  42421. import { Collider } from "babylonjs/Collisions/collider";
  42422. module "babylonjs/scene" {
  42423. interface Scene {
  42424. /**
  42425. * @hidden
  42426. * Backing Filed
  42427. */
  42428. _selectionOctree: Octree<AbstractMesh>;
  42429. /**
  42430. * Gets the octree used to boost mesh selection (picking)
  42431. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42432. */
  42433. selectionOctree: Octree<AbstractMesh>;
  42434. /**
  42435. * Creates or updates the octree used to boost selection (picking)
  42436. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42437. * @param maxCapacity defines the maximum capacity per leaf
  42438. * @param maxDepth defines the maximum depth of the octree
  42439. * @returns an octree of AbstractMesh
  42440. */
  42441. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42442. }
  42443. }
  42444. module "babylonjs/Meshes/abstractMesh" {
  42445. interface AbstractMesh {
  42446. /**
  42447. * @hidden
  42448. * Backing Field
  42449. */
  42450. _submeshesOctree: Octree<SubMesh>;
  42451. /**
  42452. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42453. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42454. * @param maxCapacity defines the maximum size of each block (64 by default)
  42455. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42456. * @returns the new octree
  42457. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42458. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42459. */
  42460. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42461. }
  42462. }
  42463. /**
  42464. * Defines the octree scene component responsible to manage any octrees
  42465. * in a given scene.
  42466. */
  42467. export class OctreeSceneComponent {
  42468. /**
  42469. * The component name help to identify the component in the list of scene components.
  42470. */
  42471. readonly name: string;
  42472. /**
  42473. * The scene the component belongs to.
  42474. */
  42475. scene: Scene;
  42476. /**
  42477. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42478. */
  42479. readonly checksIsEnabled: boolean;
  42480. /**
  42481. * Creates a new instance of the component for the given scene
  42482. * @param scene Defines the scene to register the component in
  42483. */
  42484. constructor(scene: Scene);
  42485. /**
  42486. * Registers the component in a given scene
  42487. */
  42488. register(): void;
  42489. /**
  42490. * Return the list of active meshes
  42491. * @returns the list of active meshes
  42492. */
  42493. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42494. /**
  42495. * Return the list of active sub meshes
  42496. * @param mesh The mesh to get the candidates sub meshes from
  42497. * @returns the list of active sub meshes
  42498. */
  42499. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42500. private _tempRay;
  42501. /**
  42502. * Return the list of sub meshes intersecting with a given local ray
  42503. * @param mesh defines the mesh to find the submesh for
  42504. * @param localRay defines the ray in local space
  42505. * @returns the list of intersecting sub meshes
  42506. */
  42507. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42508. /**
  42509. * Return the list of sub meshes colliding with a collider
  42510. * @param mesh defines the mesh to find the submesh for
  42511. * @param collider defines the collider to evaluate the collision against
  42512. * @returns the list of colliding sub meshes
  42513. */
  42514. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42515. /**
  42516. * Rebuilds the elements related to this component in case of
  42517. * context lost for instance.
  42518. */
  42519. rebuild(): void;
  42520. /**
  42521. * Disposes the component and the associated ressources.
  42522. */
  42523. dispose(): void;
  42524. }
  42525. }
  42526. declare module "babylonjs/Culling/Octrees/index" {
  42527. export * from "babylonjs/Culling/Octrees/octree";
  42528. export * from "babylonjs/Culling/Octrees/octreeBlock";
  42529. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  42530. }
  42531. declare module "babylonjs/Culling/index" {
  42532. export * from "babylonjs/Culling/boundingBox";
  42533. export * from "babylonjs/Culling/boundingInfo";
  42534. export * from "babylonjs/Culling/boundingSphere";
  42535. export * from "babylonjs/Culling/Octrees/index";
  42536. export * from "babylonjs/Culling/ray";
  42537. }
  42538. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  42539. import { IDisposable, Scene } from "babylonjs/scene";
  42540. import { Nullable } from "babylonjs/types";
  42541. import { Observable } from "babylonjs/Misc/observable";
  42542. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42543. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  42544. import { Camera } from "babylonjs/Cameras/camera";
  42545. /**
  42546. * Renders a layer on top of an existing scene
  42547. */
  42548. export class UtilityLayerRenderer implements IDisposable {
  42549. /** the original scene that will be rendered on top of */
  42550. originalScene: Scene;
  42551. private _pointerCaptures;
  42552. private _lastPointerEvents;
  42553. private static _DefaultUtilityLayer;
  42554. private static _DefaultKeepDepthUtilityLayer;
  42555. private _sharedGizmoLight;
  42556. private _renderCamera;
  42557. /**
  42558. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  42559. * @returns the camera that is used when rendering the utility layer
  42560. */
  42561. getRenderCamera(): Nullable<Camera>;
  42562. /**
  42563. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  42564. * @param cam the camera that should be used when rendering the utility layer
  42565. */
  42566. setRenderCamera(cam: Nullable<Camera>): void;
  42567. /**
  42568. * @hidden
  42569. * Light which used by gizmos to get light shading
  42570. */
  42571. _getSharedGizmoLight(): HemisphericLight;
  42572. /**
  42573. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42574. */
  42575. pickUtilitySceneFirst: boolean;
  42576. /**
  42577. * 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)
  42578. */
  42579. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42580. /**
  42581. * 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)
  42582. */
  42583. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42584. /**
  42585. * The scene that is rendered on top of the original scene
  42586. */
  42587. utilityLayerScene: Scene;
  42588. /**
  42589. * If the utility layer should automatically be rendered on top of existing scene
  42590. */
  42591. shouldRender: boolean;
  42592. /**
  42593. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42594. */
  42595. onlyCheckPointerDownEvents: boolean;
  42596. /**
  42597. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42598. */
  42599. processAllEvents: boolean;
  42600. /**
  42601. * Observable raised when the pointer move from the utility layer scene to the main scene
  42602. */
  42603. onPointerOutObservable: Observable<number>;
  42604. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42605. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42606. private _afterRenderObserver;
  42607. private _sceneDisposeObserver;
  42608. private _originalPointerObserver;
  42609. /**
  42610. * Instantiates a UtilityLayerRenderer
  42611. * @param originalScene the original scene that will be rendered on top of
  42612. * @param handleEvents boolean indicating if the utility layer should handle events
  42613. */
  42614. constructor(
  42615. /** the original scene that will be rendered on top of */
  42616. originalScene: Scene, handleEvents?: boolean);
  42617. private _notifyObservers;
  42618. /**
  42619. * Renders the utility layers scene on top of the original scene
  42620. */
  42621. render(): void;
  42622. /**
  42623. * Disposes of the renderer
  42624. */
  42625. dispose(): void;
  42626. private _updateCamera;
  42627. }
  42628. }
  42629. declare module "babylonjs/Gizmos/gizmo" {
  42630. import { Nullable } from "babylonjs/types";
  42631. import { IDisposable } from "babylonjs/scene";
  42632. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42633. import { Mesh } from "babylonjs/Meshes/mesh";
  42634. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42635. /**
  42636. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42637. */
  42638. export class Gizmo implements IDisposable {
  42639. /** The utility layer the gizmo will be added to */
  42640. gizmoLayer: UtilityLayerRenderer;
  42641. /**
  42642. * The root mesh of the gizmo
  42643. */
  42644. _rootMesh: Mesh;
  42645. private _attachedMesh;
  42646. /**
  42647. * Ratio for the scale of the gizmo (Default: 1)
  42648. */
  42649. scaleRatio: number;
  42650. /**
  42651. * If a custom mesh has been set (Default: false)
  42652. */
  42653. protected _customMeshSet: boolean;
  42654. /**
  42655. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42656. * * When set, interactions will be enabled
  42657. */
  42658. attachedMesh: Nullable<AbstractMesh>;
  42659. /**
  42660. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42661. * @param mesh The mesh to replace the default mesh of the gizmo
  42662. */
  42663. setCustomMesh(mesh: Mesh): void;
  42664. /**
  42665. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42666. */
  42667. updateGizmoRotationToMatchAttachedMesh: boolean;
  42668. /**
  42669. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42670. */
  42671. updateGizmoPositionToMatchAttachedMesh: boolean;
  42672. /**
  42673. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  42674. */
  42675. protected _updateScale: boolean;
  42676. protected _interactionsEnabled: boolean;
  42677. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42678. private _beforeRenderObserver;
  42679. private _tempVector;
  42680. /**
  42681. * Creates a gizmo
  42682. * @param gizmoLayer The utility layer the gizmo will be added to
  42683. */
  42684. constructor(
  42685. /** The utility layer the gizmo will be added to */
  42686. gizmoLayer?: UtilityLayerRenderer);
  42687. /**
  42688. * Updates the gizmo to match the attached mesh's position/rotation
  42689. */
  42690. protected _update(): void;
  42691. /**
  42692. * Disposes of the gizmo
  42693. */
  42694. dispose(): void;
  42695. }
  42696. }
  42697. declare module "babylonjs/Gizmos/planeDragGizmo" {
  42698. import { Observable } from "babylonjs/Misc/observable";
  42699. import { Nullable } from "babylonjs/types";
  42700. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42701. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42702. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42703. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42704. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42705. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42706. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42707. import { Scene } from "babylonjs/scene";
  42708. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  42709. /**
  42710. * Single plane drag gizmo
  42711. */
  42712. export class PlaneDragGizmo extends Gizmo {
  42713. /**
  42714. * Drag behavior responsible for the gizmos dragging interactions
  42715. */
  42716. dragBehavior: PointerDragBehavior;
  42717. private _pointerObserver;
  42718. /**
  42719. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42720. */
  42721. snapDistance: number;
  42722. /**
  42723. * Event that fires each time the gizmo snaps to a new location.
  42724. * * snapDistance is the the change in distance
  42725. */
  42726. onSnapObservable: Observable<{
  42727. snapDistance: number;
  42728. }>;
  42729. private _plane;
  42730. private _coloredMaterial;
  42731. private _hoverMaterial;
  42732. private _isEnabled;
  42733. private _parent;
  42734. /** @hidden */
  42735. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42736. /** @hidden */
  42737. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42738. /**
  42739. * Creates a PlaneDragGizmo
  42740. * @param gizmoLayer The utility layer the gizmo will be added to
  42741. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42742. * @param color The color of the gizmo
  42743. */
  42744. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42745. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42746. /**
  42747. * If the gizmo is enabled
  42748. */
  42749. isEnabled: boolean;
  42750. /**
  42751. * Disposes of the gizmo
  42752. */
  42753. dispose(): void;
  42754. }
  42755. }
  42756. declare module "babylonjs/Gizmos/positionGizmo" {
  42757. import { Observable } from "babylonjs/Misc/observable";
  42758. import { Nullable } from "babylonjs/types";
  42759. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42760. import { Mesh } from "babylonjs/Meshes/mesh";
  42761. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42762. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  42763. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  42764. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42765. /**
  42766. * Gizmo that enables dragging a mesh along 3 axis
  42767. */
  42768. export class PositionGizmo extends Gizmo {
  42769. /**
  42770. * Internal gizmo used for interactions on the x axis
  42771. */
  42772. xGizmo: AxisDragGizmo;
  42773. /**
  42774. * Internal gizmo used for interactions on the y axis
  42775. */
  42776. yGizmo: AxisDragGizmo;
  42777. /**
  42778. * Internal gizmo used for interactions on the z axis
  42779. */
  42780. zGizmo: AxisDragGizmo;
  42781. /**
  42782. * Internal gizmo used for interactions on the yz plane
  42783. */
  42784. xPlaneGizmo: PlaneDragGizmo;
  42785. /**
  42786. * Internal gizmo used for interactions on the xz plane
  42787. */
  42788. yPlaneGizmo: PlaneDragGizmo;
  42789. /**
  42790. * Internal gizmo used for interactions on the xy plane
  42791. */
  42792. zPlaneGizmo: PlaneDragGizmo;
  42793. /**
  42794. * private variables
  42795. */
  42796. private _meshAttached;
  42797. private _updateGizmoRotationToMatchAttachedMesh;
  42798. private _snapDistance;
  42799. private _scaleRatio;
  42800. /** Fires an event when any of it's sub gizmos are dragged */
  42801. onDragStartObservable: Observable<unknown>;
  42802. /** Fires an event when any of it's sub gizmos are released from dragging */
  42803. onDragEndObservable: Observable<unknown>;
  42804. /**
  42805. * If set to true, planar drag is enabled
  42806. */
  42807. private _planarGizmoEnabled;
  42808. attachedMesh: Nullable<AbstractMesh>;
  42809. /**
  42810. * Creates a PositionGizmo
  42811. * @param gizmoLayer The utility layer the gizmo will be added to
  42812. */
  42813. constructor(gizmoLayer?: UtilityLayerRenderer);
  42814. /**
  42815. * If the planar drag gizmo is enabled
  42816. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42817. */
  42818. planarGizmoEnabled: boolean;
  42819. updateGizmoRotationToMatchAttachedMesh: boolean;
  42820. /**
  42821. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42822. */
  42823. snapDistance: number;
  42824. /**
  42825. * Ratio for the scale of the gizmo (Default: 1)
  42826. */
  42827. scaleRatio: number;
  42828. /**
  42829. * Disposes of the gizmo
  42830. */
  42831. dispose(): void;
  42832. /**
  42833. * CustomMeshes are not supported by this gizmo
  42834. * @param mesh The mesh to replace the default mesh of the gizmo
  42835. */
  42836. setCustomMesh(mesh: Mesh): void;
  42837. }
  42838. }
  42839. declare module "babylonjs/Gizmos/axisDragGizmo" {
  42840. import { Observable } from "babylonjs/Misc/observable";
  42841. import { Nullable } from "babylonjs/types";
  42842. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42843. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42844. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42845. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42846. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42847. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42848. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42849. import { Scene } from "babylonjs/scene";
  42850. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  42851. /**
  42852. * Single axis drag gizmo
  42853. */
  42854. export class AxisDragGizmo extends Gizmo {
  42855. /**
  42856. * Drag behavior responsible for the gizmos dragging interactions
  42857. */
  42858. dragBehavior: PointerDragBehavior;
  42859. private _pointerObserver;
  42860. /**
  42861. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42862. */
  42863. snapDistance: number;
  42864. /**
  42865. * Event that fires each time the gizmo snaps to a new location.
  42866. * * snapDistance is the the change in distance
  42867. */
  42868. onSnapObservable: Observable<{
  42869. snapDistance: number;
  42870. }>;
  42871. private _isEnabled;
  42872. private _parent;
  42873. private _arrow;
  42874. private _coloredMaterial;
  42875. private _hoverMaterial;
  42876. /** @hidden */
  42877. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42878. /** @hidden */
  42879. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42880. /**
  42881. * Creates an AxisDragGizmo
  42882. * @param gizmoLayer The utility layer the gizmo will be added to
  42883. * @param dragAxis The axis which the gizmo will be able to drag on
  42884. * @param color The color of the gizmo
  42885. */
  42886. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42887. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42888. /**
  42889. * If the gizmo is enabled
  42890. */
  42891. isEnabled: boolean;
  42892. /**
  42893. * Disposes of the gizmo
  42894. */
  42895. dispose(): void;
  42896. }
  42897. }
  42898. declare module "babylonjs/Debug/axesViewer" {
  42899. import { Vector3 } from "babylonjs/Maths/math";
  42900. import { Nullable } from "babylonjs/types";
  42901. import { Scene } from "babylonjs/scene";
  42902. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42903. /**
  42904. * The Axes viewer will show 3 axes in a specific point in space
  42905. */
  42906. export class AxesViewer {
  42907. private _xAxis;
  42908. private _yAxis;
  42909. private _zAxis;
  42910. private _scaleLinesFactor;
  42911. private _instanced;
  42912. /**
  42913. * Gets the hosting scene
  42914. */
  42915. scene: Scene;
  42916. /**
  42917. * Gets or sets a number used to scale line length
  42918. */
  42919. scaleLines: number;
  42920. /** Gets the node hierarchy used to render x-axis */
  42921. readonly xAxis: TransformNode;
  42922. /** Gets the node hierarchy used to render y-axis */
  42923. readonly yAxis: TransformNode;
  42924. /** Gets the node hierarchy used to render z-axis */
  42925. readonly zAxis: TransformNode;
  42926. /**
  42927. * Creates a new AxesViewer
  42928. * @param scene defines the hosting scene
  42929. * @param scaleLines defines a number used to scale line length (1 by default)
  42930. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42931. * @param xAxis defines the node hierarchy used to render the x-axis
  42932. * @param yAxis defines the node hierarchy used to render the y-axis
  42933. * @param zAxis defines the node hierarchy used to render the z-axis
  42934. */
  42935. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42936. /**
  42937. * Force the viewer to update
  42938. * @param position defines the position of the viewer
  42939. * @param xaxis defines the x axis of the viewer
  42940. * @param yaxis defines the y axis of the viewer
  42941. * @param zaxis defines the z axis of the viewer
  42942. */
  42943. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42944. /**
  42945. * Creates an instance of this axes viewer.
  42946. * @returns a new axes viewer with instanced meshes
  42947. */
  42948. createInstance(): AxesViewer;
  42949. /** Releases resources */
  42950. dispose(): void;
  42951. private static _SetRenderingGroupId;
  42952. }
  42953. }
  42954. declare module "babylonjs/Debug/boneAxesViewer" {
  42955. import { Nullable } from "babylonjs/types";
  42956. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  42957. import { Vector3 } from "babylonjs/Maths/math";
  42958. import { Mesh } from "babylonjs/Meshes/mesh";
  42959. import { Bone } from "babylonjs/Bones/bone";
  42960. import { Scene } from "babylonjs/scene";
  42961. /**
  42962. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42963. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42964. */
  42965. export class BoneAxesViewer extends AxesViewer {
  42966. /**
  42967. * Gets or sets the target mesh where to display the axes viewer
  42968. */
  42969. mesh: Nullable<Mesh>;
  42970. /**
  42971. * Gets or sets the target bone where to display the axes viewer
  42972. */
  42973. bone: Nullable<Bone>;
  42974. /** Gets current position */
  42975. pos: Vector3;
  42976. /** Gets direction of X axis */
  42977. xaxis: Vector3;
  42978. /** Gets direction of Y axis */
  42979. yaxis: Vector3;
  42980. /** Gets direction of Z axis */
  42981. zaxis: Vector3;
  42982. /**
  42983. * Creates a new BoneAxesViewer
  42984. * @param scene defines the hosting scene
  42985. * @param bone defines the target bone
  42986. * @param mesh defines the target mesh
  42987. * @param scaleLines defines a scaling factor for line length (1 by default)
  42988. */
  42989. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42990. /**
  42991. * Force the viewer to update
  42992. */
  42993. update(): void;
  42994. /** Releases resources */
  42995. dispose(): void;
  42996. }
  42997. }
  42998. declare module "babylonjs/Debug/debugLayer" {
  42999. import { Scene } from "babylonjs/scene";
  43000. /**
  43001. * Interface used to define scene explorer extensibility option
  43002. */
  43003. export interface IExplorerExtensibilityOption {
  43004. /**
  43005. * Define the option label
  43006. */
  43007. label: string;
  43008. /**
  43009. * Defines the action to execute on click
  43010. */
  43011. action: (entity: any) => void;
  43012. }
  43013. /**
  43014. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  43015. */
  43016. export interface IExplorerExtensibilityGroup {
  43017. /**
  43018. * Defines a predicate to test if a given type mut be extended
  43019. */
  43020. predicate: (entity: any) => boolean;
  43021. /**
  43022. * Gets the list of options added to a type
  43023. */
  43024. entries: IExplorerExtensibilityOption[];
  43025. }
  43026. /**
  43027. * Interface used to define the options to use to create the Inspector
  43028. */
  43029. export interface IInspectorOptions {
  43030. /**
  43031. * Display in overlay mode (default: false)
  43032. */
  43033. overlay?: boolean;
  43034. /**
  43035. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  43036. */
  43037. globalRoot?: HTMLElement;
  43038. /**
  43039. * Display the Scene explorer
  43040. */
  43041. showExplorer?: boolean;
  43042. /**
  43043. * Display the property inspector
  43044. */
  43045. showInspector?: boolean;
  43046. /**
  43047. * Display in embed mode (both panes on the right)
  43048. */
  43049. embedMode?: boolean;
  43050. /**
  43051. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  43052. */
  43053. handleResize?: boolean;
  43054. /**
  43055. * Allow the panes to popup (default: true)
  43056. */
  43057. enablePopup?: boolean;
  43058. /**
  43059. * Allow the panes to be closed by users (default: true)
  43060. */
  43061. enableClose?: boolean;
  43062. /**
  43063. * Optional list of extensibility entries
  43064. */
  43065. explorerExtensibility?: IExplorerExtensibilityGroup[];
  43066. /**
  43067. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  43068. */
  43069. inspectorURL?: string;
  43070. }
  43071. module "babylonjs/scene" {
  43072. interface Scene {
  43073. /**
  43074. * @hidden
  43075. * Backing field
  43076. */
  43077. _debugLayer: DebugLayer;
  43078. /**
  43079. * Gets the debug layer (aka Inspector) associated with the scene
  43080. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43081. */
  43082. debugLayer: DebugLayer;
  43083. }
  43084. }
  43085. /**
  43086. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43087. * what is happening in your scene
  43088. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43089. */
  43090. export class DebugLayer {
  43091. /**
  43092. * Define the url to get the inspector script from.
  43093. * By default it uses the babylonjs CDN.
  43094. * @ignoreNaming
  43095. */
  43096. static InspectorURL: string;
  43097. private _scene;
  43098. private BJSINSPECTOR;
  43099. private _onPropertyChangedObservable?;
  43100. /**
  43101. * Observable triggered when a property is changed through the inspector.
  43102. */
  43103. readonly onPropertyChangedObservable: any;
  43104. /**
  43105. * Instantiates a new debug layer.
  43106. * The debug layer (aka Inspector) is the go to tool in order to better understand
  43107. * what is happening in your scene
  43108. * @see http://doc.babylonjs.com/features/playground_debuglayer
  43109. * @param scene Defines the scene to inspect
  43110. */
  43111. constructor(scene: Scene);
  43112. /** Creates the inspector window. */
  43113. private _createInspector;
  43114. /**
  43115. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  43116. * @param entity defines the entity to select
  43117. * @param lineContainerTitle defines the specific block to highlight
  43118. */
  43119. select(entity: any, lineContainerTitle?: string): void;
  43120. /** Get the inspector from bundle or global */
  43121. private _getGlobalInspector;
  43122. /**
  43123. * Get if the inspector is visible or not.
  43124. * @returns true if visible otherwise, false
  43125. */
  43126. isVisible(): boolean;
  43127. /**
  43128. * Hide the inspector and close its window.
  43129. */
  43130. hide(): void;
  43131. /**
  43132. * Launch the debugLayer.
  43133. * @param config Define the configuration of the inspector
  43134. * @return a promise fulfilled when the debug layer is visible
  43135. */
  43136. show(config?: IInspectorOptions): Promise<DebugLayer>;
  43137. }
  43138. }
  43139. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  43140. import { Nullable } from "babylonjs/types";
  43141. import { Scene } from "babylonjs/scene";
  43142. import { Vector4, Color4 } from "babylonjs/Maths/math";
  43143. import { Mesh } from "babylonjs/Meshes/mesh";
  43144. /**
  43145. * Class containing static functions to help procedurally build meshes
  43146. */
  43147. export class BoxBuilder {
  43148. /**
  43149. * Creates a box mesh
  43150. * * The parameter `size` sets the size (float) of each box side (default 1)
  43151. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  43152. * * 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)
  43153. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  43154. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43155. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43157. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  43158. * @param name defines the name of the mesh
  43159. * @param options defines the options used to create the mesh
  43160. * @param scene defines the hosting scene
  43161. * @returns the box mesh
  43162. */
  43163. static CreateBox(name: string, options: {
  43164. size?: number;
  43165. width?: number;
  43166. height?: number;
  43167. depth?: number;
  43168. faceUV?: Vector4[];
  43169. faceColors?: Color4[];
  43170. sideOrientation?: number;
  43171. frontUVs?: Vector4;
  43172. backUVs?: Vector4;
  43173. wrap?: boolean;
  43174. topBaseAt?: number;
  43175. bottomBaseAt?: number;
  43176. updatable?: boolean;
  43177. }, scene?: Nullable<Scene>): Mesh;
  43178. }
  43179. }
  43180. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  43181. import { Vector4 } from "babylonjs/Maths/math";
  43182. import { Mesh } from "babylonjs/Meshes/mesh";
  43183. /**
  43184. * Class containing static functions to help procedurally build meshes
  43185. */
  43186. export class SphereBuilder {
  43187. /**
  43188. * Creates a sphere mesh
  43189. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43190. * * 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`)
  43191. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43192. * * 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
  43193. * * 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)
  43194. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43195. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43196. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43197. * @param name defines the name of the mesh
  43198. * @param options defines the options used to create the mesh
  43199. * @param scene defines the hosting scene
  43200. * @returns the sphere mesh
  43201. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43202. */
  43203. static CreateSphere(name: string, options: {
  43204. segments?: number;
  43205. diameter?: number;
  43206. diameterX?: number;
  43207. diameterY?: number;
  43208. diameterZ?: number;
  43209. arc?: number;
  43210. slice?: number;
  43211. sideOrientation?: number;
  43212. frontUVs?: Vector4;
  43213. backUVs?: Vector4;
  43214. updatable?: boolean;
  43215. }, scene: any): Mesh;
  43216. }
  43217. }
  43218. declare module "babylonjs/Debug/physicsViewer" {
  43219. import { Nullable } from "babylonjs/types";
  43220. import { Scene } from "babylonjs/scene";
  43221. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43222. import { Mesh } from "babylonjs/Meshes/mesh";
  43223. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  43224. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  43225. /**
  43226. * Used to show the physics impostor around the specific mesh
  43227. */
  43228. export class PhysicsViewer {
  43229. /** @hidden */
  43230. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  43231. /** @hidden */
  43232. protected _meshes: Array<Nullable<AbstractMesh>>;
  43233. /** @hidden */
  43234. protected _scene: Nullable<Scene>;
  43235. /** @hidden */
  43236. protected _numMeshes: number;
  43237. /** @hidden */
  43238. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  43239. private _renderFunction;
  43240. private _utilityLayer;
  43241. private _debugBoxMesh;
  43242. private _debugSphereMesh;
  43243. private _debugCylinderMesh;
  43244. private _debugMaterial;
  43245. private _debugMeshMeshes;
  43246. /**
  43247. * Creates a new PhysicsViewer
  43248. * @param scene defines the hosting scene
  43249. */
  43250. constructor(scene: Scene);
  43251. /** @hidden */
  43252. protected _updateDebugMeshes(): void;
  43253. /**
  43254. * Renders a specified physic impostor
  43255. * @param impostor defines the impostor to render
  43256. * @param targetMesh defines the mesh represented by the impostor
  43257. * @returns the new debug mesh used to render the impostor
  43258. */
  43259. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  43260. /**
  43261. * Hides a specified physic impostor
  43262. * @param impostor defines the impostor to hide
  43263. */
  43264. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  43265. private _getDebugMaterial;
  43266. private _getDebugBoxMesh;
  43267. private _getDebugSphereMesh;
  43268. private _getDebugCylinderMesh;
  43269. private _getDebugMeshMesh;
  43270. private _getDebugMesh;
  43271. /** Releases all resources */
  43272. dispose(): void;
  43273. }
  43274. }
  43275. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  43276. import { Vector3, Color4 } from "babylonjs/Maths/math";
  43277. import { Nullable } from "babylonjs/types";
  43278. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  43279. import { Scene } from "babylonjs/scene";
  43280. /**
  43281. * Class containing static functions to help procedurally build meshes
  43282. */
  43283. export class LinesBuilder {
  43284. /**
  43285. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  43286. * * 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
  43287. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  43288. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  43289. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  43290. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  43291. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  43292. * * 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
  43293. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  43294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43295. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  43296. * @param name defines the name of the new line system
  43297. * @param options defines the options used to create the line system
  43298. * @param scene defines the hosting scene
  43299. * @returns a new line system mesh
  43300. */
  43301. static CreateLineSystem(name: string, options: {
  43302. lines: Vector3[][];
  43303. updatable?: boolean;
  43304. instance?: Nullable<LinesMesh>;
  43305. colors?: Nullable<Color4[][]>;
  43306. useVertexAlpha?: boolean;
  43307. }, scene: Nullable<Scene>): LinesMesh;
  43308. /**
  43309. * Creates a line mesh
  43310. * 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
  43311. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43312. * * The parameter `points` is an array successive Vector3
  43313. * * 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
  43314. * * The optional parameter `colors` is an array of successive Color4, one per line point
  43315. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  43316. * * When updating an instance, remember that only point positions can change, not the number of points
  43317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43318. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  43319. * @param name defines the name of the new line system
  43320. * @param options defines the options used to create the line system
  43321. * @param scene defines the hosting scene
  43322. * @returns a new line mesh
  43323. */
  43324. static CreateLines(name: string, options: {
  43325. points: Vector3[];
  43326. updatable?: boolean;
  43327. instance?: Nullable<LinesMesh>;
  43328. colors?: Color4[];
  43329. useVertexAlpha?: boolean;
  43330. }, scene?: Nullable<Scene>): LinesMesh;
  43331. /**
  43332. * Creates a dashed line mesh
  43333. * * 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
  43334. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  43335. * * The parameter `points` is an array successive Vector3
  43336. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  43337. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  43338. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  43339. * * 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
  43340. * * When updating an instance, remember that only point positions can change, not the number of points
  43341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43342. * @param name defines the name of the mesh
  43343. * @param options defines the options used to create the mesh
  43344. * @param scene defines the hosting scene
  43345. * @returns the dashed line mesh
  43346. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  43347. */
  43348. static CreateDashedLines(name: string, options: {
  43349. points: Vector3[];
  43350. dashSize?: number;
  43351. gapSize?: number;
  43352. dashNb?: number;
  43353. updatable?: boolean;
  43354. instance?: LinesMesh;
  43355. }, scene?: Nullable<Scene>): LinesMesh;
  43356. }
  43357. }
  43358. declare module "babylonjs/Debug/rayHelper" {
  43359. import { Nullable } from "babylonjs/types";
  43360. import { Ray } from "babylonjs/Culling/ray";
  43361. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43362. import { Scene } from "babylonjs/scene";
  43363. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43364. import "babylonjs/Meshes/Builders/linesBuilder";
  43365. /**
  43366. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43367. * in order to better appreciate the issue one might have.
  43368. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43369. */
  43370. export class RayHelper {
  43371. /**
  43372. * Defines the ray we are currently tryin to visualize.
  43373. */
  43374. ray: Nullable<Ray>;
  43375. private _renderPoints;
  43376. private _renderLine;
  43377. private _renderFunction;
  43378. private _scene;
  43379. private _updateToMeshFunction;
  43380. private _attachedToMesh;
  43381. private _meshSpaceDirection;
  43382. private _meshSpaceOrigin;
  43383. /**
  43384. * Helper function to create a colored helper in a scene in one line.
  43385. * @param ray Defines the ray we are currently tryin to visualize
  43386. * @param scene Defines the scene the ray is used in
  43387. * @param color Defines the color we want to see the ray in
  43388. * @returns The newly created ray helper.
  43389. */
  43390. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  43391. /**
  43392. * Instantiate a new ray helper.
  43393. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  43394. * in order to better appreciate the issue one might have.
  43395. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  43396. * @param ray Defines the ray we are currently tryin to visualize
  43397. */
  43398. constructor(ray: Ray);
  43399. /**
  43400. * Shows the ray we are willing to debug.
  43401. * @param scene Defines the scene the ray needs to be rendered in
  43402. * @param color Defines the color the ray needs to be rendered in
  43403. */
  43404. show(scene: Scene, color?: Color3): void;
  43405. /**
  43406. * Hides the ray we are debugging.
  43407. */
  43408. hide(): void;
  43409. private _render;
  43410. /**
  43411. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  43412. * @param mesh Defines the mesh we want the helper attached to
  43413. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  43414. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  43415. * @param length Defines the length of the ray
  43416. */
  43417. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  43418. /**
  43419. * Detach the ray helper from the mesh it has previously been attached to.
  43420. */
  43421. detachFromMesh(): void;
  43422. private _updateToMesh;
  43423. /**
  43424. * Dispose the helper and release its associated resources.
  43425. */
  43426. dispose(): void;
  43427. }
  43428. }
  43429. declare module "babylonjs/Debug/skeletonViewer" {
  43430. import { Color3 } from "babylonjs/Maths/math";
  43431. import { Scene } from "babylonjs/scene";
  43432. import { Nullable } from "babylonjs/types";
  43433. import { Skeleton } from "babylonjs/Bones/skeleton";
  43434. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43435. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  43436. /**
  43437. * Class used to render a debug view of a given skeleton
  43438. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43439. */
  43440. export class SkeletonViewer {
  43441. /** defines the skeleton to render */
  43442. skeleton: Skeleton;
  43443. /** defines the mesh attached to the skeleton */
  43444. mesh: AbstractMesh;
  43445. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43446. autoUpdateBonesMatrices: boolean;
  43447. /** defines the rendering group id to use with the viewer */
  43448. renderingGroupId: number;
  43449. /** Gets or sets the color used to render the skeleton */
  43450. color: Color3;
  43451. private _scene;
  43452. private _debugLines;
  43453. private _debugMesh;
  43454. private _isEnabled;
  43455. private _renderFunction;
  43456. private _utilityLayer;
  43457. /**
  43458. * Returns the mesh used to render the bones
  43459. */
  43460. readonly debugMesh: Nullable<LinesMesh>;
  43461. /**
  43462. * Creates a new SkeletonViewer
  43463. * @param skeleton defines the skeleton to render
  43464. * @param mesh defines the mesh attached to the skeleton
  43465. * @param scene defines the hosting scene
  43466. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43467. * @param renderingGroupId defines the rendering group id to use with the viewer
  43468. */
  43469. constructor(
  43470. /** defines the skeleton to render */
  43471. skeleton: Skeleton,
  43472. /** defines the mesh attached to the skeleton */
  43473. mesh: AbstractMesh, scene: Scene,
  43474. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43475. autoUpdateBonesMatrices?: boolean,
  43476. /** defines the rendering group id to use with the viewer */
  43477. renderingGroupId?: number);
  43478. /** Gets or sets a boolean indicating if the viewer is enabled */
  43479. isEnabled: boolean;
  43480. private _getBonePosition;
  43481. private _getLinesForBonesWithLength;
  43482. private _getLinesForBonesNoLength;
  43483. /** Update the viewer to sync with current skeleton state */
  43484. update(): void;
  43485. /** Release associated resources */
  43486. dispose(): void;
  43487. }
  43488. }
  43489. declare module "babylonjs/Debug/index" {
  43490. export * from "babylonjs/Debug/axesViewer";
  43491. export * from "babylonjs/Debug/boneAxesViewer";
  43492. export * from "babylonjs/Debug/debugLayer";
  43493. export * from "babylonjs/Debug/physicsViewer";
  43494. export * from "babylonjs/Debug/rayHelper";
  43495. export * from "babylonjs/Debug/skeletonViewer";
  43496. }
  43497. declare module "babylonjs/Engines/nullEngine" {
  43498. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  43499. import { Scene } from "babylonjs/scene";
  43500. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  43501. import { Engine } from "babylonjs/Engines/engine";
  43502. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  43503. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  43504. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43505. import { Effect } from "babylonjs/Materials/effect";
  43506. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  43507. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43508. /**
  43509. * Options to create the null engine
  43510. */
  43511. export class NullEngineOptions {
  43512. /**
  43513. * Render width (Default: 512)
  43514. */
  43515. renderWidth: number;
  43516. /**
  43517. * Render height (Default: 256)
  43518. */
  43519. renderHeight: number;
  43520. /**
  43521. * Texture size (Default: 512)
  43522. */
  43523. textureSize: number;
  43524. /**
  43525. * If delta time between frames should be constant
  43526. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43527. */
  43528. deterministicLockstep: boolean;
  43529. /**
  43530. * Maximum about of steps between frames (Default: 4)
  43531. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43532. */
  43533. lockstepMaxSteps: number;
  43534. }
  43535. /**
  43536. * The null engine class provides support for headless version of babylon.js.
  43537. * This can be used in server side scenario or for testing purposes
  43538. */
  43539. export class NullEngine extends Engine {
  43540. private _options;
  43541. /**
  43542. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43543. */
  43544. isDeterministicLockStep(): boolean;
  43545. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  43546. getLockstepMaxSteps(): number;
  43547. /**
  43548. * Sets hardware scaling, used to save performance if needed
  43549. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  43550. */
  43551. getHardwareScalingLevel(): number;
  43552. constructor(options?: NullEngineOptions);
  43553. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43554. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43555. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43556. getRenderWidth(useScreen?: boolean): number;
  43557. getRenderHeight(useScreen?: boolean): number;
  43558. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  43559. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43560. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43561. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43562. bindSamplers(effect: Effect): void;
  43563. enableEffect(effect: Effect): void;
  43564. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43565. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43566. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43567. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43568. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43569. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43570. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43571. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43572. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43573. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43574. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43575. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43576. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43577. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43578. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  43579. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43580. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43581. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43582. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43583. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43584. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43585. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43586. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  43587. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  43588. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43589. bindBuffers(vertexBuffers: {
  43590. [key: string]: VertexBuffer;
  43591. }, indexBuffer: DataBuffer, effect: Effect): void;
  43592. wipeCaches(bruteForce?: boolean): void;
  43593. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43594. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43595. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43596. /** @hidden */
  43597. _createTexture(): WebGLTexture;
  43598. /** @hidden */
  43599. _releaseTexture(texture: InternalTexture): void;
  43600. 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;
  43601. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43602. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43603. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43604. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43605. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43606. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43607. areAllEffectsReady(): boolean;
  43608. /**
  43609. * @hidden
  43610. * Get the current error code of the webGL context
  43611. * @returns the error code
  43612. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43613. */
  43614. getError(): number;
  43615. /** @hidden */
  43616. _getUnpackAlignement(): number;
  43617. /** @hidden */
  43618. _unpackFlipY(value: boolean): void;
  43619. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43620. /**
  43621. * Updates a dynamic vertex buffer.
  43622. * @param vertexBuffer the vertex buffer to update
  43623. * @param data the data used to update the vertex buffer
  43624. * @param byteOffset the byte offset of the data (optional)
  43625. * @param byteLength the byte length of the data (optional)
  43626. */
  43627. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43628. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43629. /** @hidden */
  43630. _bindTexture(channel: number, texture: InternalTexture): void;
  43631. /** @hidden */
  43632. _releaseBuffer(buffer: DataBuffer): boolean;
  43633. releaseEffects(): void;
  43634. displayLoadingUI(): void;
  43635. hideLoadingUI(): void;
  43636. /** @hidden */
  43637. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43638. /** @hidden */
  43639. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43640. /** @hidden */
  43641. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43642. /** @hidden */
  43643. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43644. }
  43645. }
  43646. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  43647. import { Nullable, int } from "babylonjs/types";
  43648. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  43649. /** @hidden */
  43650. export class _OcclusionDataStorage {
  43651. /** @hidden */
  43652. occlusionInternalRetryCounter: number;
  43653. /** @hidden */
  43654. isOcclusionQueryInProgress: boolean;
  43655. /** @hidden */
  43656. isOccluded: boolean;
  43657. /** @hidden */
  43658. occlusionRetryCount: number;
  43659. /** @hidden */
  43660. occlusionType: number;
  43661. /** @hidden */
  43662. occlusionQueryAlgorithmType: number;
  43663. }
  43664. module "babylonjs/Engines/engine" {
  43665. interface Engine {
  43666. /**
  43667. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43668. * @return the new query
  43669. */
  43670. createQuery(): WebGLQuery;
  43671. /**
  43672. * Delete and release a webGL query
  43673. * @param query defines the query to delete
  43674. * @return the current engine
  43675. */
  43676. deleteQuery(query: WebGLQuery): Engine;
  43677. /**
  43678. * Check if a given query has resolved and got its value
  43679. * @param query defines the query to check
  43680. * @returns true if the query got its value
  43681. */
  43682. isQueryResultAvailable(query: WebGLQuery): boolean;
  43683. /**
  43684. * Gets the value of a given query
  43685. * @param query defines the query to check
  43686. * @returns the value of the query
  43687. */
  43688. getQueryResult(query: WebGLQuery): number;
  43689. /**
  43690. * Initiates an occlusion query
  43691. * @param algorithmType defines the algorithm to use
  43692. * @param query defines the query to use
  43693. * @returns the current engine
  43694. * @see http://doc.babylonjs.com/features/occlusionquery
  43695. */
  43696. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43697. /**
  43698. * Ends an occlusion query
  43699. * @see http://doc.babylonjs.com/features/occlusionquery
  43700. * @param algorithmType defines the algorithm to use
  43701. * @returns the current engine
  43702. */
  43703. endOcclusionQuery(algorithmType: number): Engine;
  43704. /**
  43705. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43706. * Please note that only one query can be issued at a time
  43707. * @returns a time token used to track the time span
  43708. */
  43709. startTimeQuery(): Nullable<_TimeToken>;
  43710. /**
  43711. * Ends a time query
  43712. * @param token defines the token used to measure the time span
  43713. * @returns the time spent (in ns)
  43714. */
  43715. endTimeQuery(token: _TimeToken): int;
  43716. /** @hidden */
  43717. _currentNonTimestampToken: Nullable<_TimeToken>;
  43718. /** @hidden */
  43719. _createTimeQuery(): WebGLQuery;
  43720. /** @hidden */
  43721. _deleteTimeQuery(query: WebGLQuery): void;
  43722. /** @hidden */
  43723. _getGlAlgorithmType(algorithmType: number): number;
  43724. /** @hidden */
  43725. _getTimeQueryResult(query: WebGLQuery): any;
  43726. /** @hidden */
  43727. _getTimeQueryAvailability(query: WebGLQuery): any;
  43728. }
  43729. }
  43730. module "babylonjs/Meshes/abstractMesh" {
  43731. interface AbstractMesh {
  43732. /**
  43733. * Backing filed
  43734. * @hidden
  43735. */
  43736. __occlusionDataStorage: _OcclusionDataStorage;
  43737. /**
  43738. * Access property
  43739. * @hidden
  43740. */
  43741. _occlusionDataStorage: _OcclusionDataStorage;
  43742. /**
  43743. * 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.
  43744. * The default value is -1 which means don't break the query and wait till the result
  43745. * @see http://doc.babylonjs.com/features/occlusionquery
  43746. */
  43747. occlusionRetryCount: number;
  43748. /**
  43749. * 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:
  43750. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43751. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43752. * * 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.
  43753. * @see http://doc.babylonjs.com/features/occlusionquery
  43754. */
  43755. occlusionType: number;
  43756. /**
  43757. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43758. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43759. * * 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.
  43760. * @see http://doc.babylonjs.com/features/occlusionquery
  43761. */
  43762. occlusionQueryAlgorithmType: number;
  43763. /**
  43764. * 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
  43765. * @see http://doc.babylonjs.com/features/occlusionquery
  43766. */
  43767. isOccluded: boolean;
  43768. /**
  43769. * Flag to check the progress status of the query
  43770. * @see http://doc.babylonjs.com/features/occlusionquery
  43771. */
  43772. isOcclusionQueryInProgress: boolean;
  43773. }
  43774. }
  43775. }
  43776. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  43777. import { Nullable } from "babylonjs/types";
  43778. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43779. /** @hidden */
  43780. export var _forceTransformFeedbackToBundle: boolean;
  43781. module "babylonjs/Engines/engine" {
  43782. interface Engine {
  43783. /**
  43784. * Creates a webGL transform feedback object
  43785. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43786. * @returns the webGL transform feedback object
  43787. */
  43788. createTransformFeedback(): WebGLTransformFeedback;
  43789. /**
  43790. * Delete a webGL transform feedback object
  43791. * @param value defines the webGL transform feedback object to delete
  43792. */
  43793. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43794. /**
  43795. * Bind a webGL transform feedback object to the webgl context
  43796. * @param value defines the webGL transform feedback object to bind
  43797. */
  43798. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43799. /**
  43800. * Begins a transform feedback operation
  43801. * @param usePoints defines if points or triangles must be used
  43802. */
  43803. beginTransformFeedback(usePoints: boolean): void;
  43804. /**
  43805. * Ends a transform feedback operation
  43806. */
  43807. endTransformFeedback(): void;
  43808. /**
  43809. * Specify the varyings to use with transform feedback
  43810. * @param program defines the associated webGL program
  43811. * @param value defines the list of strings representing the varying names
  43812. */
  43813. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43814. /**
  43815. * Bind a webGL buffer for a transform feedback operation
  43816. * @param value defines the webGL buffer to bind
  43817. */
  43818. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43819. }
  43820. }
  43821. }
  43822. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  43823. import { Scene } from "babylonjs/scene";
  43824. import { Engine } from "babylonjs/Engines/engine";
  43825. import { Texture } from "babylonjs/Materials/Textures/texture";
  43826. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43827. import "babylonjs/Engines/Extensions/engine.multiRender";
  43828. /**
  43829. * Creation options of the multi render target texture.
  43830. */
  43831. export interface IMultiRenderTargetOptions {
  43832. /**
  43833. * Define if the texture needs to create mip maps after render.
  43834. */
  43835. generateMipMaps?: boolean;
  43836. /**
  43837. * Define the types of all the draw buffers we want to create
  43838. */
  43839. types?: number[];
  43840. /**
  43841. * Define the sampling modes of all the draw buffers we want to create
  43842. */
  43843. samplingModes?: number[];
  43844. /**
  43845. * Define if a depth buffer is required
  43846. */
  43847. generateDepthBuffer?: boolean;
  43848. /**
  43849. * Define if a stencil buffer is required
  43850. */
  43851. generateStencilBuffer?: boolean;
  43852. /**
  43853. * Define if a depth texture is required instead of a depth buffer
  43854. */
  43855. generateDepthTexture?: boolean;
  43856. /**
  43857. * Define the number of desired draw buffers
  43858. */
  43859. textureCount?: number;
  43860. /**
  43861. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43862. */
  43863. doNotChangeAspectRatio?: boolean;
  43864. /**
  43865. * Define the default type of the buffers we are creating
  43866. */
  43867. defaultType?: number;
  43868. }
  43869. /**
  43870. * A multi render target, like a render target provides the ability to render to a texture.
  43871. * Unlike the render target, it can render to several draw buffers in one draw.
  43872. * This is specially interesting in deferred rendering or for any effects requiring more than
  43873. * just one color from a single pass.
  43874. */
  43875. export class MultiRenderTarget extends RenderTargetTexture {
  43876. private _internalTextures;
  43877. private _textures;
  43878. private _multiRenderTargetOptions;
  43879. /**
  43880. * Get if draw buffers are currently supported by the used hardware and browser.
  43881. */
  43882. readonly isSupported: boolean;
  43883. /**
  43884. * Get the list of textures generated by the multi render target.
  43885. */
  43886. readonly textures: Texture[];
  43887. /**
  43888. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43889. */
  43890. readonly depthTexture: Texture;
  43891. /**
  43892. * Set the wrapping mode on U of all the textures we are rendering to.
  43893. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43894. */
  43895. wrapU: number;
  43896. /**
  43897. * Set the wrapping mode on V of all the textures we are rendering to.
  43898. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43899. */
  43900. wrapV: number;
  43901. /**
  43902. * Instantiate a new multi render target texture.
  43903. * A multi render target, like a render target provides the ability to render to a texture.
  43904. * Unlike the render target, it can render to several draw buffers in one draw.
  43905. * This is specially interesting in deferred rendering or for any effects requiring more than
  43906. * just one color from a single pass.
  43907. * @param name Define the name of the texture
  43908. * @param size Define the size of the buffers to render to
  43909. * @param count Define the number of target we are rendering into
  43910. * @param scene Define the scene the texture belongs to
  43911. * @param options Define the options used to create the multi render target
  43912. */
  43913. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43914. /** @hidden */
  43915. _rebuild(): void;
  43916. private _createInternalTextures;
  43917. private _createTextures;
  43918. /**
  43919. * Define the number of samples used if MSAA is enabled.
  43920. */
  43921. samples: number;
  43922. /**
  43923. * Resize all the textures in the multi render target.
  43924. * Be carrefull as it will recreate all the data in the new texture.
  43925. * @param size Define the new size
  43926. */
  43927. resize(size: any): void;
  43928. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43929. /**
  43930. * Dispose the render targets and their associated resources
  43931. */
  43932. dispose(): void;
  43933. /**
  43934. * Release all the underlying texture used as draw buffers.
  43935. */
  43936. releaseInternalTextures(): void;
  43937. }
  43938. }
  43939. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  43940. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43941. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  43942. import { Nullable } from "babylonjs/types";
  43943. module "babylonjs/Engines/engine" {
  43944. interface Engine {
  43945. /**
  43946. * Unbind a list of render target textures from the webGL context
  43947. * This is used only when drawBuffer extension or webGL2 are active
  43948. * @param textures defines the render target textures to unbind
  43949. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43950. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43951. */
  43952. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43953. /**
  43954. * Create a multi render target texture
  43955. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43956. * @param size defines the size of the texture
  43957. * @param options defines the creation options
  43958. * @returns the cube texture as an InternalTexture
  43959. */
  43960. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43961. /**
  43962. * Update the sample count for a given multiple render target texture
  43963. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43964. * @param textures defines the textures to update
  43965. * @param samples defines the sample count to set
  43966. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43967. */
  43968. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43969. }
  43970. }
  43971. }
  43972. declare module "babylonjs/Engines/Extensions/index" {
  43973. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  43974. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  43975. export * from "babylonjs/Engines/Extensions/engine.multiview";
  43976. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  43977. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  43978. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  43979. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  43980. export * from "babylonjs/Engines/Extensions/engine.webVR";
  43981. }
  43982. declare module "babylonjs/Engines/index" {
  43983. export * from "babylonjs/Engines/constants";
  43984. export * from "babylonjs/Engines/engine";
  43985. export * from "babylonjs/Engines/engineStore";
  43986. export * from "babylonjs/Engines/nullEngine";
  43987. export * from "babylonjs/Engines/Extensions/index";
  43988. export * from "babylonjs/Engines/IPipelineContext";
  43989. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  43990. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  43991. }
  43992. declare module "babylonjs/Events/clipboardEvents" {
  43993. /**
  43994. * Gather the list of clipboard event types as constants.
  43995. */
  43996. export class ClipboardEventTypes {
  43997. /**
  43998. * The clipboard event is fired when a copy command is active (pressed).
  43999. */
  44000. static readonly COPY: number;
  44001. /**
  44002. * The clipboard event is fired when a cut command is active (pressed).
  44003. */
  44004. static readonly CUT: number;
  44005. /**
  44006. * The clipboard event is fired when a paste command is active (pressed).
  44007. */
  44008. static readonly PASTE: number;
  44009. }
  44010. /**
  44011. * This class is used to store clipboard related info for the onClipboardObservable event.
  44012. */
  44013. export class ClipboardInfo {
  44014. /**
  44015. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44016. */
  44017. type: number;
  44018. /**
  44019. * Defines the related dom event
  44020. */
  44021. event: ClipboardEvent;
  44022. /**
  44023. *Creates an instance of ClipboardInfo.
  44024. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  44025. * @param event Defines the related dom event
  44026. */
  44027. constructor(
  44028. /**
  44029. * Defines the type of event (BABYLON.ClipboardEventTypes)
  44030. */
  44031. type: number,
  44032. /**
  44033. * Defines the related dom event
  44034. */
  44035. event: ClipboardEvent);
  44036. /**
  44037. * Get the clipboard event's type from the keycode.
  44038. * @param keyCode Defines the keyCode for the current keyboard event.
  44039. * @return {number}
  44040. */
  44041. static GetTypeFromCharacter(keyCode: number): number;
  44042. }
  44043. }
  44044. declare module "babylonjs/Events/index" {
  44045. export * from "babylonjs/Events/keyboardEvents";
  44046. export * from "babylonjs/Events/pointerEvents";
  44047. export * from "babylonjs/Events/clipboardEvents";
  44048. }
  44049. declare module "babylonjs/Loading/sceneLoader" {
  44050. import { Observable } from "babylonjs/Misc/observable";
  44051. import { Nullable } from "babylonjs/types";
  44052. import { Scene } from "babylonjs/scene";
  44053. import { Engine } from "babylonjs/Engines/engine";
  44054. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44055. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44056. import { AssetContainer } from "babylonjs/assetContainer";
  44057. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44058. import { Skeleton } from "babylonjs/Bones/skeleton";
  44059. /**
  44060. * Class used to represent data loading progression
  44061. */
  44062. export class SceneLoaderProgressEvent {
  44063. /** defines if data length to load can be evaluated */
  44064. readonly lengthComputable: boolean;
  44065. /** defines the loaded data length */
  44066. readonly loaded: number;
  44067. /** defines the data length to load */
  44068. readonly total: number;
  44069. /**
  44070. * Create a new progress event
  44071. * @param lengthComputable defines if data length to load can be evaluated
  44072. * @param loaded defines the loaded data length
  44073. * @param total defines the data length to load
  44074. */
  44075. constructor(
  44076. /** defines if data length to load can be evaluated */
  44077. lengthComputable: boolean,
  44078. /** defines the loaded data length */
  44079. loaded: number,
  44080. /** defines the data length to load */
  44081. total: number);
  44082. /**
  44083. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44084. * @param event defines the source event
  44085. * @returns a new SceneLoaderProgressEvent
  44086. */
  44087. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44088. }
  44089. /**
  44090. * Interface used by SceneLoader plugins to define supported file extensions
  44091. */
  44092. export interface ISceneLoaderPluginExtensions {
  44093. /**
  44094. * Defines the list of supported extensions
  44095. */
  44096. [extension: string]: {
  44097. isBinary: boolean;
  44098. };
  44099. }
  44100. /**
  44101. * Interface used by SceneLoader plugin factory
  44102. */
  44103. export interface ISceneLoaderPluginFactory {
  44104. /**
  44105. * Defines the name of the factory
  44106. */
  44107. name: string;
  44108. /**
  44109. * Function called to create a new plugin
  44110. * @return the new plugin
  44111. */
  44112. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44113. /**
  44114. * Boolean indicating if the plugin can direct load specific data
  44115. */
  44116. canDirectLoad?: (data: string) => boolean;
  44117. }
  44118. /**
  44119. * Interface used to define a SceneLoader plugin
  44120. */
  44121. export interface ISceneLoaderPlugin {
  44122. /**
  44123. * The friendly name of this plugin.
  44124. */
  44125. name: string;
  44126. /**
  44127. * The file extensions supported by this plugin.
  44128. */
  44129. extensions: string | ISceneLoaderPluginExtensions;
  44130. /**
  44131. * Import meshes into a scene.
  44132. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44133. * @param scene The scene to import into
  44134. * @param data The data to import
  44135. * @param rootUrl The root url for scene and resources
  44136. * @param meshes The meshes array to import into
  44137. * @param particleSystems The particle systems array to import into
  44138. * @param skeletons The skeletons array to import into
  44139. * @param onError The callback when import fails
  44140. * @returns True if successful or false otherwise
  44141. */
  44142. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44143. /**
  44144. * Load into a scene.
  44145. * @param scene The scene to load into
  44146. * @param data The data to import
  44147. * @param rootUrl The root url for scene and resources
  44148. * @param onError The callback when import fails
  44149. * @returns true if successful or false otherwise
  44150. */
  44151. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44152. /**
  44153. * The callback that returns true if the data can be directly loaded.
  44154. */
  44155. canDirectLoad?: (data: string) => boolean;
  44156. /**
  44157. * The callback that allows custom handling of the root url based on the response url.
  44158. */
  44159. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  44160. /**
  44161. * Load into an asset container.
  44162. * @param scene The scene to load into
  44163. * @param data The data to import
  44164. * @param rootUrl The root url for scene and resources
  44165. * @param onError The callback when import fails
  44166. * @returns The loaded asset container
  44167. */
  44168. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44169. }
  44170. /**
  44171. * Interface used to define an async SceneLoader plugin
  44172. */
  44173. export interface ISceneLoaderPluginAsync {
  44174. /**
  44175. * The friendly name of this plugin.
  44176. */
  44177. name: string;
  44178. /**
  44179. * The file extensions supported by this plugin.
  44180. */
  44181. extensions: string | ISceneLoaderPluginExtensions;
  44182. /**
  44183. * Import meshes into a scene.
  44184. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44185. * @param scene The scene to import into
  44186. * @param data The data to import
  44187. * @param rootUrl The root url for scene and resources
  44188. * @param onProgress The callback when the load progresses
  44189. * @param fileName Defines the name of the file to load
  44190. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44191. */
  44192. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44193. meshes: AbstractMesh[];
  44194. particleSystems: IParticleSystem[];
  44195. skeletons: Skeleton[];
  44196. animationGroups: AnimationGroup[];
  44197. }>;
  44198. /**
  44199. * Load into a scene.
  44200. * @param scene The scene to load into
  44201. * @param data The data to import
  44202. * @param rootUrl The root url for scene and resources
  44203. * @param onProgress The callback when the load progresses
  44204. * @param fileName Defines the name of the file to load
  44205. * @returns Nothing
  44206. */
  44207. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44208. /**
  44209. * The callback that returns true if the data can be directly loaded.
  44210. */
  44211. canDirectLoad?: (data: string) => boolean;
  44212. /**
  44213. * The callback that allows custom handling of the root url based on the response url.
  44214. */
  44215. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  44216. /**
  44217. * Load into an asset container.
  44218. * @param scene The scene to load into
  44219. * @param data The data to import
  44220. * @param rootUrl The root url for scene and resources
  44221. * @param onProgress The callback when the load progresses
  44222. * @param fileName Defines the name of the file to load
  44223. * @returns The loaded asset container
  44224. */
  44225. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44226. }
  44227. /**
  44228. * Class used to load scene from various file formats using registered plugins
  44229. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44230. */
  44231. export class SceneLoader {
  44232. /**
  44233. * No logging while loading
  44234. */
  44235. static readonly NO_LOGGING: number;
  44236. /**
  44237. * Minimal logging while loading
  44238. */
  44239. static readonly MINIMAL_LOGGING: number;
  44240. /**
  44241. * Summary logging while loading
  44242. */
  44243. static readonly SUMMARY_LOGGING: number;
  44244. /**
  44245. * Detailled logging while loading
  44246. */
  44247. static readonly DETAILED_LOGGING: number;
  44248. /**
  44249. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44250. */
  44251. static ForceFullSceneLoadingForIncremental: boolean;
  44252. /**
  44253. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44254. */
  44255. static ShowLoadingScreen: boolean;
  44256. /**
  44257. * Defines the current logging level (while loading the scene)
  44258. * @ignorenaming
  44259. */
  44260. static loggingLevel: number;
  44261. /**
  44262. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44263. */
  44264. static CleanBoneMatrixWeights: boolean;
  44265. /**
  44266. * Event raised when a plugin is used to load a scene
  44267. */
  44268. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44269. private static _registeredPlugins;
  44270. private static _getDefaultPlugin;
  44271. private static _getPluginForExtension;
  44272. private static _getPluginForDirectLoad;
  44273. private static _getPluginForFilename;
  44274. private static _getDirectLoad;
  44275. private static _loadData;
  44276. private static _getFileInfo;
  44277. /**
  44278. * Gets a plugin that can load the given extension
  44279. * @param extension defines the extension to load
  44280. * @returns a plugin or null if none works
  44281. */
  44282. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44283. /**
  44284. * Gets a boolean indicating that the given extension can be loaded
  44285. * @param extension defines the extension to load
  44286. * @returns true if the extension is supported
  44287. */
  44288. static IsPluginForExtensionAvailable(extension: string): boolean;
  44289. /**
  44290. * Adds a new plugin to the list of registered plugins
  44291. * @param plugin defines the plugin to add
  44292. */
  44293. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44294. /**
  44295. * Import meshes into a scene
  44296. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44297. * @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)
  44298. * @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)
  44299. * @param scene the instance of BABYLON.Scene to append to
  44300. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44301. * @param onProgress a callback with a progress event for each file being loaded
  44302. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44303. * @param pluginExtension the extension used to determine the plugin
  44304. * @returns The loaded plugin
  44305. */
  44306. 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>;
  44307. /**
  44308. * Import meshes into a scene
  44309. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44310. * @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)
  44311. * @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)
  44312. * @param scene the instance of BABYLON.Scene to append to
  44313. * @param onProgress a callback with a progress event for each file being loaded
  44314. * @param pluginExtension the extension used to determine the plugin
  44315. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44316. */
  44317. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44318. meshes: AbstractMesh[];
  44319. particleSystems: IParticleSystem[];
  44320. skeletons: Skeleton[];
  44321. animationGroups: AnimationGroup[];
  44322. }>;
  44323. /**
  44324. * Load 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 engine is the instance of BABYLON.Engine to use to create the scene
  44328. * @param onSuccess a callback with the scene when import succeeds
  44329. * @param onProgress a callback with a progress event for each file being loaded
  44330. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44331. * @param pluginExtension the extension used to determine the plugin
  44332. * @returns The loaded plugin
  44333. */
  44334. 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>;
  44335. /**
  44336. * Load a scene
  44337. * @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)
  44338. * @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)
  44339. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44340. * @param onProgress a callback with a progress event for each file being loaded
  44341. * @param pluginExtension the extension used to determine the plugin
  44342. * @returns The loaded scene
  44343. */
  44344. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44345. /**
  44346. * Append a scene
  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 or a File object (default: empty string)
  44349. * @param scene is the instance of BABYLON.Scene to append to
  44350. * @param onSuccess a callback with the scene when import succeeds
  44351. * @param onProgress a callback with a progress event for each file being loaded
  44352. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44353. * @param pluginExtension the extension used to determine the plugin
  44354. * @returns The loaded plugin
  44355. */
  44356. 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>;
  44357. /**
  44358. * Append a scene
  44359. * @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)
  44360. * @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)
  44361. * @param scene is the instance of BABYLON.Scene to append to
  44362. * @param onProgress a callback with a progress event for each file being loaded
  44363. * @param pluginExtension the extension used to determine the plugin
  44364. * @returns The given scene
  44365. */
  44366. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44367. /**
  44368. * Load a scene into an asset container
  44369. * @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)
  44370. * @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)
  44371. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44372. * @param onSuccess a callback with the scene when import succeeds
  44373. * @param onProgress a callback with a progress event for each file being loaded
  44374. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44375. * @param pluginExtension the extension used to determine the plugin
  44376. * @returns The loaded plugin
  44377. */
  44378. 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>;
  44379. /**
  44380. * Load a scene into an asset container
  44381. * @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)
  44382. * @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)
  44383. * @param scene is the instance of Scene to append to
  44384. * @param onProgress a callback with a progress event for each file being loaded
  44385. * @param pluginExtension the extension used to determine the plugin
  44386. * @returns The loaded asset container
  44387. */
  44388. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  44389. }
  44390. }
  44391. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  44392. import { Scene } from "babylonjs/scene";
  44393. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44394. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44395. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44396. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44397. /**
  44398. * Google Daydream controller
  44399. */
  44400. export class DaydreamController extends WebVRController {
  44401. /**
  44402. * Base Url for the controller model.
  44403. */
  44404. static MODEL_BASE_URL: string;
  44405. /**
  44406. * File name for the controller model.
  44407. */
  44408. static MODEL_FILENAME: string;
  44409. /**
  44410. * Gamepad Id prefix used to identify Daydream Controller.
  44411. */
  44412. static readonly GAMEPAD_ID_PREFIX: string;
  44413. /**
  44414. * Creates a new DaydreamController from a gamepad
  44415. * @param vrGamepad the gamepad that the controller should be created from
  44416. */
  44417. constructor(vrGamepad: any);
  44418. /**
  44419. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44420. * @param scene scene in which to add meshes
  44421. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44422. */
  44423. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44424. /**
  44425. * Called once for each button that changed state since the last frame
  44426. * @param buttonIdx Which button index changed
  44427. * @param state New state of the button
  44428. * @param changes Which properties on the state changed since last frame
  44429. */
  44430. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44431. }
  44432. }
  44433. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  44434. import { Scene } from "babylonjs/scene";
  44435. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44436. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44437. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44438. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44439. /**
  44440. * Gear VR Controller
  44441. */
  44442. export class GearVRController extends WebVRController {
  44443. /**
  44444. * Base Url for the controller model.
  44445. */
  44446. static MODEL_BASE_URL: string;
  44447. /**
  44448. * File name for the controller model.
  44449. */
  44450. static MODEL_FILENAME: string;
  44451. /**
  44452. * Gamepad Id prefix used to identify this controller.
  44453. */
  44454. static readonly GAMEPAD_ID_PREFIX: string;
  44455. private readonly _buttonIndexToObservableNameMap;
  44456. /**
  44457. * Creates a new GearVRController from a gamepad
  44458. * @param vrGamepad the gamepad that the controller should be created from
  44459. */
  44460. constructor(vrGamepad: any);
  44461. /**
  44462. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44463. * @param scene scene in which to add meshes
  44464. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44465. */
  44466. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44467. /**
  44468. * Called once for each button that changed state since the last frame
  44469. * @param buttonIdx Which button index changed
  44470. * @param state New state of the button
  44471. * @param changes Which properties on the state changed since last frame
  44472. */
  44473. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44474. }
  44475. }
  44476. declare module "babylonjs/Gamepads/Controllers/genericController" {
  44477. import { Scene } from "babylonjs/scene";
  44478. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44479. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44480. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44481. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44482. /**
  44483. * Generic Controller
  44484. */
  44485. export class GenericController extends WebVRController {
  44486. /**
  44487. * Base Url for the controller model.
  44488. */
  44489. static readonly MODEL_BASE_URL: string;
  44490. /**
  44491. * File name for the controller model.
  44492. */
  44493. static readonly MODEL_FILENAME: string;
  44494. /**
  44495. * Creates a new GenericController from a gamepad
  44496. * @param vrGamepad the gamepad that the controller should be created from
  44497. */
  44498. constructor(vrGamepad: any);
  44499. /**
  44500. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44501. * @param scene scene in which to add meshes
  44502. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44503. */
  44504. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44505. /**
  44506. * Called once for each button that changed state since the last frame
  44507. * @param buttonIdx Which button index changed
  44508. * @param state New state of the button
  44509. * @param changes Which properties on the state changed since last frame
  44510. */
  44511. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44512. }
  44513. }
  44514. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44515. import { Observable } from "babylonjs/Misc/observable";
  44516. import { Scene } from "babylonjs/scene";
  44517. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44518. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44519. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44520. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44521. /**
  44522. * Oculus Touch Controller
  44523. */
  44524. export class OculusTouchController extends WebVRController {
  44525. /**
  44526. * Base Url for the controller model.
  44527. */
  44528. static MODEL_BASE_URL: string;
  44529. /**
  44530. * File name for the left controller model.
  44531. */
  44532. static MODEL_LEFT_FILENAME: string;
  44533. /**
  44534. * File name for the right controller model.
  44535. */
  44536. static MODEL_RIGHT_FILENAME: string;
  44537. /**
  44538. * Base Url for the Quest controller model.
  44539. */
  44540. static QUEST_MODEL_BASE_URL: string;
  44541. /**
  44542. * @hidden
  44543. * If the controllers are running on a device that needs the updated Quest controller models
  44544. */
  44545. static _IsQuest: boolean;
  44546. /**
  44547. * Fired when the secondary trigger on this controller is modified
  44548. */
  44549. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44550. /**
  44551. * Fired when the thumb rest on this controller is modified
  44552. */
  44553. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44554. /**
  44555. * Creates a new OculusTouchController from a gamepad
  44556. * @param vrGamepad the gamepad that the controller should be created from
  44557. */
  44558. constructor(vrGamepad: any);
  44559. /**
  44560. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44561. * @param scene scene in which to add meshes
  44562. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44563. */
  44564. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44565. /**
  44566. * Fired when the A button on this controller is modified
  44567. */
  44568. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44569. /**
  44570. * Fired when the B button on this controller is modified
  44571. */
  44572. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44573. /**
  44574. * Fired when the X button on this controller is modified
  44575. */
  44576. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44577. /**
  44578. * Fired when the Y button on this controller is modified
  44579. */
  44580. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44581. /**
  44582. * Called once for each button that changed state since the last frame
  44583. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44584. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44585. * 2) secondary trigger (same)
  44586. * 3) A (right) X (left), touch, pressed = value
  44587. * 4) B / Y
  44588. * 5) thumb rest
  44589. * @param buttonIdx Which button index changed
  44590. * @param state New state of the button
  44591. * @param changes Which properties on the state changed since last frame
  44592. */
  44593. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44594. }
  44595. }
  44596. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44597. import { Scene } from "babylonjs/scene";
  44598. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44599. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44600. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44601. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44602. import { Observable } from "babylonjs/Misc/observable";
  44603. /**
  44604. * Vive Controller
  44605. */
  44606. export class ViveController extends WebVRController {
  44607. /**
  44608. * Base Url for the controller model.
  44609. */
  44610. static MODEL_BASE_URL: string;
  44611. /**
  44612. * File name for the controller model.
  44613. */
  44614. static MODEL_FILENAME: string;
  44615. /**
  44616. * Creates a new ViveController from a gamepad
  44617. * @param vrGamepad the gamepad that the controller should be created from
  44618. */
  44619. constructor(vrGamepad: any);
  44620. /**
  44621. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44622. * @param scene scene in which to add meshes
  44623. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44624. */
  44625. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44626. /**
  44627. * Fired when the left button on this controller is modified
  44628. */
  44629. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44630. /**
  44631. * Fired when the right button on this controller is modified
  44632. */
  44633. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44634. /**
  44635. * Fired when the menu button on this controller is modified
  44636. */
  44637. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44638. /**
  44639. * Called once for each button that changed state since the last frame
  44640. * Vive mapping:
  44641. * 0: touchpad
  44642. * 1: trigger
  44643. * 2: left AND right buttons
  44644. * 3: menu button
  44645. * @param buttonIdx Which button index changed
  44646. * @param state New state of the button
  44647. * @param changes Which properties on the state changed since last frame
  44648. */
  44649. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44650. }
  44651. }
  44652. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44653. import { Observable } from "babylonjs/Misc/observable";
  44654. import { Scene } from "babylonjs/scene";
  44655. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44656. import { Ray } from "babylonjs/Culling/ray";
  44657. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44658. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44659. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44660. /**
  44661. * Defines the WindowsMotionController object that the state of the windows motion controller
  44662. */
  44663. export class WindowsMotionController extends WebVRController {
  44664. /**
  44665. * The base url used to load the left and right controller models
  44666. */
  44667. static MODEL_BASE_URL: string;
  44668. /**
  44669. * The name of the left controller model file
  44670. */
  44671. static MODEL_LEFT_FILENAME: string;
  44672. /**
  44673. * The name of the right controller model file
  44674. */
  44675. static MODEL_RIGHT_FILENAME: string;
  44676. /**
  44677. * The controller name prefix for this controller type
  44678. */
  44679. static readonly GAMEPAD_ID_PREFIX: string;
  44680. /**
  44681. * The controller id pattern for this controller type
  44682. */
  44683. private static readonly GAMEPAD_ID_PATTERN;
  44684. private _loadedMeshInfo;
  44685. private readonly _mapping;
  44686. /**
  44687. * Fired when the trackpad on this controller is clicked
  44688. */
  44689. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44690. /**
  44691. * Fired when the trackpad on this controller is modified
  44692. */
  44693. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44694. /**
  44695. * The current x and y values of this controller's trackpad
  44696. */
  44697. trackpad: StickValues;
  44698. /**
  44699. * Creates a new WindowsMotionController from a gamepad
  44700. * @param vrGamepad the gamepad that the controller should be created from
  44701. */
  44702. constructor(vrGamepad: any);
  44703. /**
  44704. * Fired when the trigger on this controller is modified
  44705. */
  44706. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44707. /**
  44708. * Fired when the menu button on this controller is modified
  44709. */
  44710. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44711. /**
  44712. * Fired when the grip button on this controller is modified
  44713. */
  44714. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44715. /**
  44716. * Fired when the thumbstick button on this controller is modified
  44717. */
  44718. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44719. /**
  44720. * Fired when the touchpad button on this controller is modified
  44721. */
  44722. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44723. /**
  44724. * Fired when the touchpad values on this controller are modified
  44725. */
  44726. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44727. private _updateTrackpad;
  44728. /**
  44729. * Called once per frame by the engine.
  44730. */
  44731. update(): void;
  44732. /**
  44733. * Called once for each button that changed state since the last frame
  44734. * @param buttonIdx Which button index changed
  44735. * @param state New state of the button
  44736. * @param changes Which properties on the state changed since last frame
  44737. */
  44738. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44739. /**
  44740. * Moves the buttons on the controller mesh based on their current state
  44741. * @param buttonName the name of the button to move
  44742. * @param buttonValue the value of the button which determines the buttons new position
  44743. */
  44744. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44745. /**
  44746. * Moves the axis on the controller mesh based on its current state
  44747. * @param axis the index of the axis
  44748. * @param axisValue the value of the axis which determines the meshes new position
  44749. * @hidden
  44750. */
  44751. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44752. /**
  44753. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44754. * @param scene scene in which to add meshes
  44755. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44756. */
  44757. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44758. /**
  44759. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44760. * can be transformed by button presses and axes values, based on this._mapping.
  44761. *
  44762. * @param scene scene in which the meshes exist
  44763. * @param meshes list of meshes that make up the controller model to process
  44764. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44765. */
  44766. private processModel;
  44767. private createMeshInfo;
  44768. /**
  44769. * Gets the ray of the controller in the direction the controller is pointing
  44770. * @param length the length the resulting ray should be
  44771. * @returns a ray in the direction the controller is pointing
  44772. */
  44773. getForwardRay(length?: number): Ray;
  44774. /**
  44775. * Disposes of the controller
  44776. */
  44777. dispose(): void;
  44778. }
  44779. }
  44780. declare module "babylonjs/Gamepads/Controllers/index" {
  44781. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  44782. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  44783. export * from "babylonjs/Gamepads/Controllers/genericController";
  44784. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  44785. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44786. export * from "babylonjs/Gamepads/Controllers/viveController";
  44787. export * from "babylonjs/Gamepads/Controllers/webVRController";
  44788. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  44789. }
  44790. declare module "babylonjs/Gamepads/index" {
  44791. export * from "babylonjs/Gamepads/Controllers/index";
  44792. export * from "babylonjs/Gamepads/gamepad";
  44793. export * from "babylonjs/Gamepads/gamepadManager";
  44794. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  44795. export * from "babylonjs/Gamepads/xboxGamepad";
  44796. }
  44797. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  44798. import { Scene } from "babylonjs/scene";
  44799. import { Color4, Vector4 } from "babylonjs/Maths/math";
  44800. import { Mesh } from "babylonjs/Meshes/mesh";
  44801. import { Nullable } from "babylonjs/types";
  44802. /**
  44803. * Class containing static functions to help procedurally build meshes
  44804. */
  44805. export class PolyhedronBuilder {
  44806. /**
  44807. * Creates a polyhedron mesh
  44808. * * 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
  44809. * * The parameter `size` (positive float, default 1) sets the polygon size
  44810. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44811. * * 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`
  44812. * * 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
  44813. * * 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)`)
  44814. * * 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
  44815. * * 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
  44816. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44817. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44818. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44819. * @param name defines the name of the mesh
  44820. * @param options defines the options used to create the mesh
  44821. * @param scene defines the hosting scene
  44822. * @returns the polyhedron mesh
  44823. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44824. */
  44825. static CreatePolyhedron(name: string, options: {
  44826. type?: number;
  44827. size?: number;
  44828. sizeX?: number;
  44829. sizeY?: number;
  44830. sizeZ?: number;
  44831. custom?: any;
  44832. faceUV?: Vector4[];
  44833. faceColors?: Color4[];
  44834. flat?: boolean;
  44835. updatable?: boolean;
  44836. sideOrientation?: number;
  44837. frontUVs?: Vector4;
  44838. backUVs?: Vector4;
  44839. }, scene?: Nullable<Scene>): Mesh;
  44840. }
  44841. }
  44842. declare module "babylonjs/Gizmos/scaleGizmo" {
  44843. import { Observable } from "babylonjs/Misc/observable";
  44844. import { Nullable } from "babylonjs/types";
  44845. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44846. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44847. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44848. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44849. /**
  44850. * Gizmo that enables scaling a mesh along 3 axis
  44851. */
  44852. export class ScaleGizmo extends Gizmo {
  44853. /**
  44854. * Internal gizmo used for interactions on the x axis
  44855. */
  44856. xGizmo: AxisScaleGizmo;
  44857. /**
  44858. * Internal gizmo used for interactions on the y axis
  44859. */
  44860. yGizmo: AxisScaleGizmo;
  44861. /**
  44862. * Internal gizmo used for interactions on the z axis
  44863. */
  44864. zGizmo: AxisScaleGizmo;
  44865. /**
  44866. * Internal gizmo used to scale all axis equally
  44867. */
  44868. uniformScaleGizmo: AxisScaleGizmo;
  44869. private _meshAttached;
  44870. private _updateGizmoRotationToMatchAttachedMesh;
  44871. private _snapDistance;
  44872. private _scaleRatio;
  44873. private _uniformScalingMesh;
  44874. private _octahedron;
  44875. /** Fires an event when any of it's sub gizmos are dragged */
  44876. onDragStartObservable: Observable<unknown>;
  44877. /** Fires an event when any of it's sub gizmos are released from dragging */
  44878. onDragEndObservable: Observable<unknown>;
  44879. attachedMesh: Nullable<AbstractMesh>;
  44880. /**
  44881. * Creates a ScaleGizmo
  44882. * @param gizmoLayer The utility layer the gizmo will be added to
  44883. */
  44884. constructor(gizmoLayer?: UtilityLayerRenderer);
  44885. updateGizmoRotationToMatchAttachedMesh: boolean;
  44886. /**
  44887. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44888. */
  44889. snapDistance: number;
  44890. /**
  44891. * Ratio for the scale of the gizmo (Default: 1)
  44892. */
  44893. scaleRatio: number;
  44894. /**
  44895. * Disposes of the gizmo
  44896. */
  44897. dispose(): void;
  44898. }
  44899. }
  44900. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  44901. import { Observable } from "babylonjs/Misc/observable";
  44902. import { Nullable } from "babylonjs/types";
  44903. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44904. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44905. import { Mesh } from "babylonjs/Meshes/mesh";
  44906. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44907. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44908. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44909. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44910. /**
  44911. * Single axis scale gizmo
  44912. */
  44913. export class AxisScaleGizmo extends Gizmo {
  44914. /**
  44915. * Drag behavior responsible for the gizmos dragging interactions
  44916. */
  44917. dragBehavior: PointerDragBehavior;
  44918. private _pointerObserver;
  44919. /**
  44920. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44921. */
  44922. snapDistance: number;
  44923. /**
  44924. * Event that fires each time the gizmo snaps to a new location.
  44925. * * snapDistance is the the change in distance
  44926. */
  44927. onSnapObservable: Observable<{
  44928. snapDistance: number;
  44929. }>;
  44930. /**
  44931. * If the scaling operation should be done on all axis (default: false)
  44932. */
  44933. uniformScaling: boolean;
  44934. private _isEnabled;
  44935. private _parent;
  44936. private _arrow;
  44937. private _coloredMaterial;
  44938. private _hoverMaterial;
  44939. /**
  44940. * Creates an AxisScaleGizmo
  44941. * @param gizmoLayer The utility layer the gizmo will be added to
  44942. * @param dragAxis The axis which the gizmo will be able to scale on
  44943. * @param color The color of the gizmo
  44944. */
  44945. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  44946. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44947. /**
  44948. * If the gizmo is enabled
  44949. */
  44950. isEnabled: boolean;
  44951. /**
  44952. * Disposes of the gizmo
  44953. */
  44954. dispose(): void;
  44955. /**
  44956. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44957. * @param mesh The mesh to replace the default mesh of the gizmo
  44958. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44959. */
  44960. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44961. }
  44962. }
  44963. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  44964. import { Observable } from "babylonjs/Misc/observable";
  44965. import { Nullable } from "babylonjs/types";
  44966. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44968. import { Mesh } from "babylonjs/Meshes/mesh";
  44969. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44970. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44971. import "babylonjs/Meshes/Builders/boxBuilder";
  44972. /**
  44973. * Bounding box gizmo
  44974. */
  44975. export class BoundingBoxGizmo extends Gizmo {
  44976. private _lineBoundingBox;
  44977. private _rotateSpheresParent;
  44978. private _scaleBoxesParent;
  44979. private _boundingDimensions;
  44980. private _renderObserver;
  44981. private _pointerObserver;
  44982. private _scaleDragSpeed;
  44983. private _tmpQuaternion;
  44984. private _tmpVector;
  44985. private _tmpRotationMatrix;
  44986. /**
  44987. * 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)
  44988. */
  44989. ignoreChildren: boolean;
  44990. /**
  44991. * 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)
  44992. */
  44993. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44994. /**
  44995. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44996. */
  44997. rotationSphereSize: number;
  44998. /**
  44999. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  45000. */
  45001. scaleBoxSize: number;
  45002. /**
  45003. * 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)
  45004. */
  45005. fixedDragMeshScreenSize: boolean;
  45006. /**
  45007. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  45008. */
  45009. fixedDragMeshScreenSizeDistanceFactor: number;
  45010. /**
  45011. * Fired when a rotation sphere or scale box is dragged
  45012. */
  45013. onDragStartObservable: Observable<{}>;
  45014. /**
  45015. * Fired when a scale box is dragged
  45016. */
  45017. onScaleBoxDragObservable: Observable<{}>;
  45018. /**
  45019. * Fired when a scale box drag is ended
  45020. */
  45021. onScaleBoxDragEndObservable: Observable<{}>;
  45022. /**
  45023. * Fired when a rotation sphere is dragged
  45024. */
  45025. onRotationSphereDragObservable: Observable<{}>;
  45026. /**
  45027. * Fired when a rotation sphere drag is ended
  45028. */
  45029. onRotationSphereDragEndObservable: Observable<{}>;
  45030. /**
  45031. * 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)
  45032. */
  45033. scalePivot: Nullable<Vector3>;
  45034. /**
  45035. * Mesh used as a pivot to rotate the attached mesh
  45036. */
  45037. private _anchorMesh;
  45038. private _existingMeshScale;
  45039. private _dragMesh;
  45040. private pointerDragBehavior;
  45041. private coloredMaterial;
  45042. private hoverColoredMaterial;
  45043. /**
  45044. * Sets the color of the bounding box gizmo
  45045. * @param color the color to set
  45046. */
  45047. setColor(color: Color3): void;
  45048. /**
  45049. * Creates an BoundingBoxGizmo
  45050. * @param gizmoLayer The utility layer the gizmo will be added to
  45051. * @param color The color of the gizmo
  45052. */
  45053. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  45054. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45055. private _selectNode;
  45056. /**
  45057. * Updates the bounding box information for the Gizmo
  45058. */
  45059. updateBoundingBox(): void;
  45060. private _updateRotationSpheres;
  45061. private _updateScaleBoxes;
  45062. /**
  45063. * Enables rotation on the specified axis and disables rotation on the others
  45064. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  45065. */
  45066. setEnabledRotationAxis(axis: string): void;
  45067. /**
  45068. * Enables/disables scaling
  45069. * @param enable if scaling should be enabled
  45070. */
  45071. setEnabledScaling(enable: boolean): void;
  45072. private _updateDummy;
  45073. /**
  45074. * Enables a pointer drag behavior on the bounding box of the gizmo
  45075. */
  45076. enableDragBehavior(): void;
  45077. /**
  45078. * Disposes of the gizmo
  45079. */
  45080. dispose(): void;
  45081. /**
  45082. * 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)
  45083. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  45084. * @returns the bounding box mesh with the passed in mesh as a child
  45085. */
  45086. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  45087. /**
  45088. * CustomMeshes are not supported by this gizmo
  45089. * @param mesh The mesh to replace the default mesh of the gizmo
  45090. */
  45091. setCustomMesh(mesh: Mesh): void;
  45092. }
  45093. }
  45094. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  45095. import { Observable } from "babylonjs/Misc/observable";
  45096. import { Nullable } from "babylonjs/types";
  45097. import { Vector3, Color3 } from "babylonjs/Maths/math";
  45098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45099. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45100. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45101. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45102. import "babylonjs/Meshes/Builders/linesBuilder";
  45103. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45104. /**
  45105. * Single plane rotation gizmo
  45106. */
  45107. export class PlaneRotationGizmo extends Gizmo {
  45108. /**
  45109. * Drag behavior responsible for the gizmos dragging interactions
  45110. */
  45111. dragBehavior: PointerDragBehavior;
  45112. private _pointerObserver;
  45113. /**
  45114. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  45115. */
  45116. snapDistance: number;
  45117. /**
  45118. * Event that fires each time the gizmo snaps to a new location.
  45119. * * snapDistance is the the change in distance
  45120. */
  45121. onSnapObservable: Observable<{
  45122. snapDistance: number;
  45123. }>;
  45124. private _isEnabled;
  45125. private _parent;
  45126. /**
  45127. * Creates a PlaneRotationGizmo
  45128. * @param gizmoLayer The utility layer the gizmo will be added to
  45129. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  45130. * @param color The color of the gizmo
  45131. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45132. */
  45133. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  45134. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45135. /**
  45136. * If the gizmo is enabled
  45137. */
  45138. isEnabled: boolean;
  45139. /**
  45140. * Disposes of the gizmo
  45141. */
  45142. dispose(): void;
  45143. }
  45144. }
  45145. declare module "babylonjs/Gizmos/rotationGizmo" {
  45146. import { Observable } from "babylonjs/Misc/observable";
  45147. import { Nullable } from "babylonjs/types";
  45148. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45149. import { Mesh } from "babylonjs/Meshes/mesh";
  45150. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45151. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  45152. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45153. /**
  45154. * Gizmo that enables rotating a mesh along 3 axis
  45155. */
  45156. export class RotationGizmo extends Gizmo {
  45157. /**
  45158. * Internal gizmo used for interactions on the x axis
  45159. */
  45160. xGizmo: PlaneRotationGizmo;
  45161. /**
  45162. * Internal gizmo used for interactions on the y axis
  45163. */
  45164. yGizmo: PlaneRotationGizmo;
  45165. /**
  45166. * Internal gizmo used for interactions on the z axis
  45167. */
  45168. zGizmo: PlaneRotationGizmo;
  45169. /** Fires an event when any of it's sub gizmos are dragged */
  45170. onDragStartObservable: Observable<unknown>;
  45171. /** Fires an event when any of it's sub gizmos are released from dragging */
  45172. onDragEndObservable: Observable<unknown>;
  45173. private _meshAttached;
  45174. attachedMesh: Nullable<AbstractMesh>;
  45175. /**
  45176. * Creates a RotationGizmo
  45177. * @param gizmoLayer The utility layer the gizmo will be added to
  45178. * @param tessellation Amount of tessellation to be used when creating rotation circles
  45179. */
  45180. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  45181. updateGizmoRotationToMatchAttachedMesh: boolean;
  45182. /**
  45183. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45184. */
  45185. snapDistance: number;
  45186. /**
  45187. * Ratio for the scale of the gizmo (Default: 1)
  45188. */
  45189. scaleRatio: number;
  45190. /**
  45191. * Disposes of the gizmo
  45192. */
  45193. dispose(): void;
  45194. /**
  45195. * CustomMeshes are not supported by this gizmo
  45196. * @param mesh The mesh to replace the default mesh of the gizmo
  45197. */
  45198. setCustomMesh(mesh: Mesh): void;
  45199. }
  45200. }
  45201. declare module "babylonjs/Gizmos/gizmoManager" {
  45202. import { Observable } from "babylonjs/Misc/observable";
  45203. import { Nullable } from "babylonjs/types";
  45204. import { Scene, IDisposable } from "babylonjs/scene";
  45205. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45206. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45207. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45208. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  45209. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  45210. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  45211. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  45212. /**
  45213. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  45214. */
  45215. export class GizmoManager implements IDisposable {
  45216. private scene;
  45217. /**
  45218. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  45219. */
  45220. gizmos: {
  45221. positionGizmo: Nullable<PositionGizmo>;
  45222. rotationGizmo: Nullable<RotationGizmo>;
  45223. scaleGizmo: Nullable<ScaleGizmo>;
  45224. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  45225. };
  45226. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  45227. clearGizmoOnEmptyPointerEvent: boolean;
  45228. /** Fires an event when the manager is attached to a mesh */
  45229. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  45230. private _gizmosEnabled;
  45231. private _pointerObserver;
  45232. private _attachedMesh;
  45233. private _boundingBoxColor;
  45234. private _defaultUtilityLayer;
  45235. private _defaultKeepDepthUtilityLayer;
  45236. /**
  45237. * When bounding box gizmo is enabled, this can be used to track drag/end events
  45238. */
  45239. boundingBoxDragBehavior: SixDofDragBehavior;
  45240. /**
  45241. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  45242. */
  45243. attachableMeshes: Nullable<Array<AbstractMesh>>;
  45244. /**
  45245. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  45246. */
  45247. usePointerToAttachGizmos: boolean;
  45248. /**
  45249. * Utility layer that the bounding box gizmo belongs to
  45250. */
  45251. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  45252. /**
  45253. * Utility layer that all gizmos besides bounding box belong to
  45254. */
  45255. readonly utilityLayer: UtilityLayerRenderer;
  45256. /**
  45257. * Instatiates a gizmo manager
  45258. * @param scene the scene to overlay the gizmos on top of
  45259. */
  45260. constructor(scene: Scene);
  45261. /**
  45262. * Attaches a set of gizmos to the specified mesh
  45263. * @param mesh The mesh the gizmo's should be attached to
  45264. */
  45265. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  45266. /**
  45267. * If the position gizmo is enabled
  45268. */
  45269. positionGizmoEnabled: boolean;
  45270. /**
  45271. * If the rotation gizmo is enabled
  45272. */
  45273. rotationGizmoEnabled: boolean;
  45274. /**
  45275. * If the scale gizmo is enabled
  45276. */
  45277. scaleGizmoEnabled: boolean;
  45278. /**
  45279. * If the boundingBox gizmo is enabled
  45280. */
  45281. boundingBoxGizmoEnabled: boolean;
  45282. /**
  45283. * Disposes of the gizmo manager
  45284. */
  45285. dispose(): void;
  45286. }
  45287. }
  45288. declare module "babylonjs/Lights/directionalLight" {
  45289. import { Camera } from "babylonjs/Cameras/camera";
  45290. import { Scene } from "babylonjs/scene";
  45291. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  45292. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45293. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45294. import { Effect } from "babylonjs/Materials/effect";
  45295. /**
  45296. * A directional light is defined by a direction (what a surprise!).
  45297. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45298. * 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.
  45299. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45300. */
  45301. export class DirectionalLight extends ShadowLight {
  45302. private _shadowFrustumSize;
  45303. /**
  45304. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45305. */
  45306. /**
  45307. * Specifies a fix frustum size for the shadow generation.
  45308. */
  45309. shadowFrustumSize: number;
  45310. private _shadowOrthoScale;
  45311. /**
  45312. * Gets the shadow projection scale against the optimal computed one.
  45313. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45314. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45315. */
  45316. /**
  45317. * Sets the shadow projection scale against the optimal computed one.
  45318. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45319. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45320. */
  45321. shadowOrthoScale: number;
  45322. /**
  45323. * Automatically compute the projection matrix to best fit (including all the casters)
  45324. * on each frame.
  45325. */
  45326. autoUpdateExtends: boolean;
  45327. private _orthoLeft;
  45328. private _orthoRight;
  45329. private _orthoTop;
  45330. private _orthoBottom;
  45331. /**
  45332. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45333. * The directional light is emitted from everywhere in the given direction.
  45334. * It can cast shadows.
  45335. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45336. * @param name The friendly name of the light
  45337. * @param direction The direction of the light
  45338. * @param scene The scene the light belongs to
  45339. */
  45340. constructor(name: string, direction: Vector3, scene: Scene);
  45341. /**
  45342. * Returns the string "DirectionalLight".
  45343. * @return The class name
  45344. */
  45345. getClassName(): string;
  45346. /**
  45347. * Returns the integer 1.
  45348. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45349. */
  45350. getTypeID(): number;
  45351. /**
  45352. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45353. * Returns the DirectionalLight Shadow projection matrix.
  45354. */
  45355. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45356. /**
  45357. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45358. * Returns the DirectionalLight Shadow projection matrix.
  45359. */
  45360. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  45361. /**
  45362. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45363. * Returns the DirectionalLight Shadow projection matrix.
  45364. */
  45365. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45366. protected _buildUniformLayout(): void;
  45367. /**
  45368. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45369. * @param effect The effect to update
  45370. * @param lightIndex The index of the light in the effect to update
  45371. * @returns The directional light
  45372. */
  45373. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  45374. /**
  45375. * Gets the minZ used for shadow according to both the scene and the light.
  45376. *
  45377. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45378. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45379. * @param activeCamera The camera we are returning the min for
  45380. * @returns the depth min z
  45381. */
  45382. getDepthMinZ(activeCamera: Camera): number;
  45383. /**
  45384. * Gets the maxZ used for shadow according to both the scene and the light.
  45385. *
  45386. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45387. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45388. * @param activeCamera The camera we are returning the max for
  45389. * @returns the depth max z
  45390. */
  45391. getDepthMaxZ(activeCamera: Camera): number;
  45392. /**
  45393. * Prepares the list of defines specific to the light type.
  45394. * @param defines the list of defines
  45395. * @param lightIndex defines the index of the light for the effect
  45396. */
  45397. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45398. }
  45399. }
  45400. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  45401. import { Mesh } from "babylonjs/Meshes/mesh";
  45402. /**
  45403. * Class containing static functions to help procedurally build meshes
  45404. */
  45405. export class HemisphereBuilder {
  45406. /**
  45407. * Creates a hemisphere mesh
  45408. * @param name defines the name of the mesh
  45409. * @param options defines the options used to create the mesh
  45410. * @param scene defines the hosting scene
  45411. * @returns the hemisphere mesh
  45412. */
  45413. static CreateHemisphere(name: string, options: {
  45414. segments?: number;
  45415. diameter?: number;
  45416. sideOrientation?: number;
  45417. }, scene: any): Mesh;
  45418. }
  45419. }
  45420. declare module "babylonjs/Lights/spotLight" {
  45421. import { Nullable } from "babylonjs/types";
  45422. import { Scene } from "babylonjs/scene";
  45423. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  45424. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45425. import { Effect } from "babylonjs/Materials/effect";
  45426. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45427. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  45428. /**
  45429. * A spot light is defined by a position, a direction, an angle, and an exponent.
  45430. * These values define a cone of light starting from the position, emitting toward the direction.
  45431. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  45432. * and the exponent defines the speed of the decay of the light with distance (reach).
  45433. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45434. */
  45435. export class SpotLight extends ShadowLight {
  45436. private _angle;
  45437. private _innerAngle;
  45438. private _cosHalfAngle;
  45439. private _lightAngleScale;
  45440. private _lightAngleOffset;
  45441. /**
  45442. * Gets the cone angle of the spot light in Radians.
  45443. */
  45444. /**
  45445. * Sets the cone angle of the spot light in Radians.
  45446. */
  45447. angle: number;
  45448. /**
  45449. * Only used in gltf falloff mode, this defines the angle where
  45450. * the directional falloff will start before cutting at angle which could be seen
  45451. * as outer angle.
  45452. */
  45453. /**
  45454. * Only used in gltf falloff mode, this defines the angle where
  45455. * the directional falloff will start before cutting at angle which could be seen
  45456. * as outer angle.
  45457. */
  45458. innerAngle: number;
  45459. private _shadowAngleScale;
  45460. /**
  45461. * Allows scaling the angle of the light for shadow generation only.
  45462. */
  45463. /**
  45464. * Allows scaling the angle of the light for shadow generation only.
  45465. */
  45466. shadowAngleScale: number;
  45467. /**
  45468. * The light decay speed with the distance from the emission spot.
  45469. */
  45470. exponent: number;
  45471. private _projectionTextureMatrix;
  45472. /**
  45473. * Allows reading the projecton texture
  45474. */
  45475. readonly projectionTextureMatrix: Matrix;
  45476. protected _projectionTextureLightNear: number;
  45477. /**
  45478. * Gets the near clip of the Spotlight for texture projection.
  45479. */
  45480. /**
  45481. * Sets the near clip of the Spotlight for texture projection.
  45482. */
  45483. projectionTextureLightNear: number;
  45484. protected _projectionTextureLightFar: number;
  45485. /**
  45486. * Gets the far clip of the Spotlight for texture projection.
  45487. */
  45488. /**
  45489. * Sets the far clip of the Spotlight for texture projection.
  45490. */
  45491. projectionTextureLightFar: number;
  45492. protected _projectionTextureUpDirection: Vector3;
  45493. /**
  45494. * Gets the Up vector of the Spotlight for texture projection.
  45495. */
  45496. /**
  45497. * Sets the Up vector of the Spotlight for texture projection.
  45498. */
  45499. projectionTextureUpDirection: Vector3;
  45500. private _projectionTexture;
  45501. /**
  45502. * Gets the projection texture of the light.
  45503. */
  45504. /**
  45505. * Sets the projection texture of the light.
  45506. */
  45507. projectionTexture: Nullable<BaseTexture>;
  45508. private _projectionTextureViewLightDirty;
  45509. private _projectionTextureProjectionLightDirty;
  45510. private _projectionTextureDirty;
  45511. private _projectionTextureViewTargetVector;
  45512. private _projectionTextureViewLightMatrix;
  45513. private _projectionTextureProjectionLightMatrix;
  45514. private _projectionTextureScalingMatrix;
  45515. /**
  45516. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45517. * It can cast shadows.
  45518. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45519. * @param name The light friendly name
  45520. * @param position The position of the spot light in the scene
  45521. * @param direction The direction of the light in the scene
  45522. * @param angle The cone angle of the light in Radians
  45523. * @param exponent The light decay speed with the distance from the emission spot
  45524. * @param scene The scene the lights belongs to
  45525. */
  45526. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45527. /**
  45528. * Returns the string "SpotLight".
  45529. * @returns the class name
  45530. */
  45531. getClassName(): string;
  45532. /**
  45533. * Returns the integer 2.
  45534. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45535. */
  45536. getTypeID(): number;
  45537. /**
  45538. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45539. */
  45540. protected _setDirection(value: Vector3): void;
  45541. /**
  45542. * Overrides the position setter to recompute the projection texture view light Matrix.
  45543. */
  45544. protected _setPosition(value: Vector3): void;
  45545. /**
  45546. * 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.
  45547. * Returns the SpotLight.
  45548. */
  45549. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45550. protected _computeProjectionTextureViewLightMatrix(): void;
  45551. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45552. /**
  45553. * Main function for light texture projection matrix computing.
  45554. */
  45555. protected _computeProjectionTextureMatrix(): void;
  45556. protected _buildUniformLayout(): void;
  45557. private _computeAngleValues;
  45558. /**
  45559. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45560. * @param effect The effect to update
  45561. * @param lightIndex The index of the light in the effect to update
  45562. * @returns The spot light
  45563. */
  45564. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45565. /**
  45566. * Disposes the light and the associated resources.
  45567. */
  45568. dispose(): void;
  45569. /**
  45570. * Prepares the list of defines specific to the light type.
  45571. * @param defines the list of defines
  45572. * @param lightIndex defines the index of the light for the effect
  45573. */
  45574. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45575. }
  45576. }
  45577. declare module "babylonjs/Gizmos/lightGizmo" {
  45578. import { Nullable } from "babylonjs/types";
  45579. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45580. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45581. import { Light } from "babylonjs/Lights/light";
  45582. /**
  45583. * Gizmo that enables viewing a light
  45584. */
  45585. export class LightGizmo extends Gizmo {
  45586. private _lightMesh;
  45587. private _material;
  45588. private cachedPosition;
  45589. private cachedForward;
  45590. /**
  45591. * Creates a LightGizmo
  45592. * @param gizmoLayer The utility layer the gizmo will be added to
  45593. */
  45594. constructor(gizmoLayer?: UtilityLayerRenderer);
  45595. private _light;
  45596. /**
  45597. * The light that the gizmo is attached to
  45598. */
  45599. light: Nullable<Light>;
  45600. /**
  45601. * @hidden
  45602. * Updates the gizmo to match the attached mesh's position/rotation
  45603. */
  45604. protected _update(): void;
  45605. private static _Scale;
  45606. /**
  45607. * Creates the lines for a light mesh
  45608. */
  45609. private static _createLightLines;
  45610. /**
  45611. * Disposes of the light gizmo
  45612. */
  45613. dispose(): void;
  45614. private static _CreateHemisphericLightMesh;
  45615. private static _CreatePointLightMesh;
  45616. private static _CreateSpotLightMesh;
  45617. private static _CreateDirectionalLightMesh;
  45618. }
  45619. }
  45620. declare module "babylonjs/Gizmos/index" {
  45621. export * from "babylonjs/Gizmos/axisDragGizmo";
  45622. export * from "babylonjs/Gizmos/axisScaleGizmo";
  45623. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  45624. export * from "babylonjs/Gizmos/gizmo";
  45625. export * from "babylonjs/Gizmos/gizmoManager";
  45626. export * from "babylonjs/Gizmos/planeRotationGizmo";
  45627. export * from "babylonjs/Gizmos/positionGizmo";
  45628. export * from "babylonjs/Gizmos/rotationGizmo";
  45629. export * from "babylonjs/Gizmos/scaleGizmo";
  45630. export * from "babylonjs/Gizmos/lightGizmo";
  45631. }
  45632. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  45633. /** @hidden */
  45634. export var backgroundFragmentDeclaration: {
  45635. name: string;
  45636. shader: string;
  45637. };
  45638. }
  45639. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  45640. /** @hidden */
  45641. export var backgroundUboDeclaration: {
  45642. name: string;
  45643. shader: string;
  45644. };
  45645. }
  45646. declare module "babylonjs/Shaders/background.fragment" {
  45647. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  45648. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45649. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  45650. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  45651. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45652. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45653. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45654. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  45655. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  45656. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  45657. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  45658. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45659. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45660. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45661. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45662. /** @hidden */
  45663. export var backgroundPixelShader: {
  45664. name: string;
  45665. shader: string;
  45666. };
  45667. }
  45668. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  45669. /** @hidden */
  45670. export var backgroundVertexDeclaration: {
  45671. name: string;
  45672. shader: string;
  45673. };
  45674. }
  45675. declare module "babylonjs/Shaders/background.vertex" {
  45676. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  45677. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45678. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45679. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45680. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45681. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45682. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45683. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45684. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45685. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45686. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45687. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45688. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45689. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45690. /** @hidden */
  45691. export var backgroundVertexShader: {
  45692. name: string;
  45693. shader: string;
  45694. };
  45695. }
  45696. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  45697. import { Nullable, int, float } from "babylonjs/types";
  45698. import { Scene } from "babylonjs/scene";
  45699. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  45700. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45701. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45702. import { Mesh } from "babylonjs/Meshes/mesh";
  45703. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45704. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45705. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45706. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45707. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  45708. import "babylonjs/Shaders/background.fragment";
  45709. import "babylonjs/Shaders/background.vertex";
  45710. /**
  45711. * Background material used to create an efficient environement around your scene.
  45712. */
  45713. export class BackgroundMaterial extends PushMaterial {
  45714. /**
  45715. * Standard reflectance value at parallel view angle.
  45716. */
  45717. static StandardReflectance0: number;
  45718. /**
  45719. * Standard reflectance value at grazing angle.
  45720. */
  45721. static StandardReflectance90: number;
  45722. protected _primaryColor: Color3;
  45723. /**
  45724. * Key light Color (multiply against the environement texture)
  45725. */
  45726. primaryColor: Color3;
  45727. protected __perceptualColor: Nullable<Color3>;
  45728. /**
  45729. * Experimental Internal Use Only.
  45730. *
  45731. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45732. * This acts as a helper to set the primary color to a more "human friendly" value.
  45733. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45734. * output color as close as possible from the chosen value.
  45735. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45736. * part of lighting setup.)
  45737. */
  45738. _perceptualColor: Nullable<Color3>;
  45739. protected _primaryColorShadowLevel: float;
  45740. /**
  45741. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45742. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45743. */
  45744. primaryColorShadowLevel: float;
  45745. protected _primaryColorHighlightLevel: float;
  45746. /**
  45747. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45748. * The primary color is used at the level chosen to define what the white area would look.
  45749. */
  45750. primaryColorHighlightLevel: float;
  45751. protected _reflectionTexture: Nullable<BaseTexture>;
  45752. /**
  45753. * Reflection Texture used in the material.
  45754. * Should be author in a specific way for the best result (refer to the documentation).
  45755. */
  45756. reflectionTexture: Nullable<BaseTexture>;
  45757. protected _reflectionBlur: float;
  45758. /**
  45759. * Reflection Texture level of blur.
  45760. *
  45761. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45762. * texture twice.
  45763. */
  45764. reflectionBlur: float;
  45765. protected _diffuseTexture: Nullable<BaseTexture>;
  45766. /**
  45767. * Diffuse Texture used in the material.
  45768. * Should be author in a specific way for the best result (refer to the documentation).
  45769. */
  45770. diffuseTexture: Nullable<BaseTexture>;
  45771. protected _shadowLights: Nullable<IShadowLight[]>;
  45772. /**
  45773. * Specify the list of lights casting shadow on the material.
  45774. * All scene shadow lights will be included if null.
  45775. */
  45776. shadowLights: Nullable<IShadowLight[]>;
  45777. protected _shadowLevel: float;
  45778. /**
  45779. * Helps adjusting the shadow to a softer level if required.
  45780. * 0 means black shadows and 1 means no shadows.
  45781. */
  45782. shadowLevel: float;
  45783. protected _sceneCenter: Vector3;
  45784. /**
  45785. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45786. * It is usually zero but might be interesting to modify according to your setup.
  45787. */
  45788. sceneCenter: Vector3;
  45789. protected _opacityFresnel: boolean;
  45790. /**
  45791. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45792. * This helps ensuring a nice transition when the camera goes under the ground.
  45793. */
  45794. opacityFresnel: boolean;
  45795. protected _reflectionFresnel: boolean;
  45796. /**
  45797. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45798. * This helps adding a mirror texture on the ground.
  45799. */
  45800. reflectionFresnel: boolean;
  45801. protected _reflectionFalloffDistance: number;
  45802. /**
  45803. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45804. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45805. */
  45806. reflectionFalloffDistance: number;
  45807. protected _reflectionAmount: number;
  45808. /**
  45809. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45810. */
  45811. reflectionAmount: number;
  45812. protected _reflectionReflectance0: number;
  45813. /**
  45814. * This specifies the weight of the reflection at grazing angle.
  45815. */
  45816. reflectionReflectance0: number;
  45817. protected _reflectionReflectance90: number;
  45818. /**
  45819. * This specifies the weight of the reflection at a perpendicular point of view.
  45820. */
  45821. reflectionReflectance90: number;
  45822. /**
  45823. * Sets the reflection reflectance fresnel values according to the default standard
  45824. * empirically know to work well :-)
  45825. */
  45826. reflectionStandardFresnelWeight: number;
  45827. protected _useRGBColor: boolean;
  45828. /**
  45829. * Helps to directly use the maps channels instead of their level.
  45830. */
  45831. useRGBColor: boolean;
  45832. protected _enableNoise: boolean;
  45833. /**
  45834. * This helps reducing the banding effect that could occur on the background.
  45835. */
  45836. enableNoise: boolean;
  45837. /**
  45838. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45839. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45840. * Recommended to be keep at 1.0 except for special cases.
  45841. */
  45842. fovMultiplier: number;
  45843. private _fovMultiplier;
  45844. /**
  45845. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45846. */
  45847. useEquirectangularFOV: boolean;
  45848. private _maxSimultaneousLights;
  45849. /**
  45850. * Number of Simultaneous lights allowed on the material.
  45851. */
  45852. maxSimultaneousLights: int;
  45853. /**
  45854. * Default configuration related to image processing available in the Background Material.
  45855. */
  45856. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45857. /**
  45858. * Keep track of the image processing observer to allow dispose and replace.
  45859. */
  45860. private _imageProcessingObserver;
  45861. /**
  45862. * Attaches a new image processing configuration to the PBR Material.
  45863. * @param configuration (if null the scene configuration will be use)
  45864. */
  45865. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45866. /**
  45867. * Gets the image processing configuration used either in this material.
  45868. */
  45869. /**
  45870. * Sets the Default image processing configuration used either in the this material.
  45871. *
  45872. * If sets to null, the scene one is in use.
  45873. */
  45874. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45875. /**
  45876. * Gets wether the color curves effect is enabled.
  45877. */
  45878. /**
  45879. * Sets wether the color curves effect is enabled.
  45880. */
  45881. cameraColorCurvesEnabled: boolean;
  45882. /**
  45883. * Gets wether the color grading effect is enabled.
  45884. */
  45885. /**
  45886. * Gets wether the color grading effect is enabled.
  45887. */
  45888. cameraColorGradingEnabled: boolean;
  45889. /**
  45890. * Gets wether tonemapping is enabled or not.
  45891. */
  45892. /**
  45893. * Sets wether tonemapping is enabled or not
  45894. */
  45895. cameraToneMappingEnabled: boolean;
  45896. /**
  45897. * The camera exposure used on this material.
  45898. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45899. * This corresponds to a photographic exposure.
  45900. */
  45901. /**
  45902. * The camera exposure used on this material.
  45903. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45904. * This corresponds to a photographic exposure.
  45905. */
  45906. cameraExposure: float;
  45907. /**
  45908. * Gets The camera contrast used on this material.
  45909. */
  45910. /**
  45911. * Sets The camera contrast used on this material.
  45912. */
  45913. cameraContrast: float;
  45914. /**
  45915. * Gets the Color Grading 2D Lookup Texture.
  45916. */
  45917. /**
  45918. * Sets the Color Grading 2D Lookup Texture.
  45919. */
  45920. cameraColorGradingTexture: Nullable<BaseTexture>;
  45921. /**
  45922. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45923. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45924. * 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;
  45925. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45926. */
  45927. /**
  45928. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45929. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45930. * 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;
  45931. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45932. */
  45933. cameraColorCurves: Nullable<ColorCurves>;
  45934. /**
  45935. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45936. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45937. */
  45938. switchToBGR: boolean;
  45939. private _renderTargets;
  45940. private _reflectionControls;
  45941. private _white;
  45942. private _primaryShadowColor;
  45943. private _primaryHighlightColor;
  45944. /**
  45945. * Instantiates a Background Material in the given scene
  45946. * @param name The friendly name of the material
  45947. * @param scene The scene to add the material to
  45948. */
  45949. constructor(name: string, scene: Scene);
  45950. /**
  45951. * Gets a boolean indicating that current material needs to register RTT
  45952. */
  45953. readonly hasRenderTargetTextures: boolean;
  45954. /**
  45955. * The entire material has been created in order to prevent overdraw.
  45956. * @returns false
  45957. */
  45958. needAlphaTesting(): boolean;
  45959. /**
  45960. * The entire material has been created in order to prevent overdraw.
  45961. * @returns true if blending is enable
  45962. */
  45963. needAlphaBlending(): boolean;
  45964. /**
  45965. * Checks wether the material is ready to be rendered for a given mesh.
  45966. * @param mesh The mesh to render
  45967. * @param subMesh The submesh to check against
  45968. * @param useInstances Specify wether or not the material is used with instances
  45969. * @returns true if all the dependencies are ready (Textures, Effects...)
  45970. */
  45971. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45972. /**
  45973. * Compute the primary color according to the chosen perceptual color.
  45974. */
  45975. private _computePrimaryColorFromPerceptualColor;
  45976. /**
  45977. * Compute the highlights and shadow colors according to their chosen levels.
  45978. */
  45979. private _computePrimaryColors;
  45980. /**
  45981. * Build the uniform buffer used in the material.
  45982. */
  45983. buildUniformLayout(): void;
  45984. /**
  45985. * Unbind the material.
  45986. */
  45987. unbind(): void;
  45988. /**
  45989. * Bind only the world matrix to the material.
  45990. * @param world The world matrix to bind.
  45991. */
  45992. bindOnlyWorldMatrix(world: Matrix): void;
  45993. /**
  45994. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45995. * @param world The world matrix to bind.
  45996. * @param subMesh The submesh to bind for.
  45997. */
  45998. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45999. /**
  46000. * Dispose the material.
  46001. * @param forceDisposeEffect Force disposal of the associated effect.
  46002. * @param forceDisposeTextures Force disposal of the associated textures.
  46003. */
  46004. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46005. /**
  46006. * Clones the material.
  46007. * @param name The cloned name.
  46008. * @returns The cloned material.
  46009. */
  46010. clone(name: string): BackgroundMaterial;
  46011. /**
  46012. * Serializes the current material to its JSON representation.
  46013. * @returns The JSON representation.
  46014. */
  46015. serialize(): any;
  46016. /**
  46017. * Gets the class name of the material
  46018. * @returns "BackgroundMaterial"
  46019. */
  46020. getClassName(): string;
  46021. /**
  46022. * Parse a JSON input to create back a background material.
  46023. * @param source The JSON data to parse
  46024. * @param scene The scene to create the parsed material in
  46025. * @param rootUrl The root url of the assets the material depends upon
  46026. * @returns the instantiated BackgroundMaterial.
  46027. */
  46028. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  46029. }
  46030. }
  46031. declare module "babylonjs/Helpers/environmentHelper" {
  46032. import { Observable } from "babylonjs/Misc/observable";
  46033. import { Nullable } from "babylonjs/types";
  46034. import { Scene } from "babylonjs/scene";
  46035. import { Vector3, Color3 } from "babylonjs/Maths/math";
  46036. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46037. import { Mesh } from "babylonjs/Meshes/mesh";
  46038. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46039. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  46040. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46041. import "babylonjs/Meshes/Builders/planeBuilder";
  46042. import "babylonjs/Meshes/Builders/boxBuilder";
  46043. /**
  46044. * Represents the different options available during the creation of
  46045. * a Environment helper.
  46046. *
  46047. * This can control the default ground, skybox and image processing setup of your scene.
  46048. */
  46049. export interface IEnvironmentHelperOptions {
  46050. /**
  46051. * Specifies wether or not to create a ground.
  46052. * True by default.
  46053. */
  46054. createGround: boolean;
  46055. /**
  46056. * Specifies the ground size.
  46057. * 15 by default.
  46058. */
  46059. groundSize: number;
  46060. /**
  46061. * The texture used on the ground for the main color.
  46062. * Comes from the BabylonJS CDN by default.
  46063. *
  46064. * Remarks: Can be either a texture or a url.
  46065. */
  46066. groundTexture: string | BaseTexture;
  46067. /**
  46068. * The color mixed in the ground texture by default.
  46069. * BabylonJS clearColor by default.
  46070. */
  46071. groundColor: Color3;
  46072. /**
  46073. * Specifies the ground opacity.
  46074. * 1 by default.
  46075. */
  46076. groundOpacity: number;
  46077. /**
  46078. * Enables the ground to receive shadows.
  46079. * True by default.
  46080. */
  46081. enableGroundShadow: boolean;
  46082. /**
  46083. * Helps preventing the shadow to be fully black on the ground.
  46084. * 0.5 by default.
  46085. */
  46086. groundShadowLevel: number;
  46087. /**
  46088. * Creates a mirror texture attach to the ground.
  46089. * false by default.
  46090. */
  46091. enableGroundMirror: boolean;
  46092. /**
  46093. * Specifies the ground mirror size ratio.
  46094. * 0.3 by default as the default kernel is 64.
  46095. */
  46096. groundMirrorSizeRatio: number;
  46097. /**
  46098. * Specifies the ground mirror blur kernel size.
  46099. * 64 by default.
  46100. */
  46101. groundMirrorBlurKernel: number;
  46102. /**
  46103. * Specifies the ground mirror visibility amount.
  46104. * 1 by default
  46105. */
  46106. groundMirrorAmount: number;
  46107. /**
  46108. * Specifies the ground mirror reflectance weight.
  46109. * This uses the standard weight of the background material to setup the fresnel effect
  46110. * of the mirror.
  46111. * 1 by default.
  46112. */
  46113. groundMirrorFresnelWeight: number;
  46114. /**
  46115. * Specifies the ground mirror Falloff distance.
  46116. * This can helps reducing the size of the reflection.
  46117. * 0 by Default.
  46118. */
  46119. groundMirrorFallOffDistance: number;
  46120. /**
  46121. * Specifies the ground mirror texture type.
  46122. * Unsigned Int by Default.
  46123. */
  46124. groundMirrorTextureType: number;
  46125. /**
  46126. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  46127. * the shown objects.
  46128. */
  46129. groundYBias: number;
  46130. /**
  46131. * Specifies wether or not to create a skybox.
  46132. * True by default.
  46133. */
  46134. createSkybox: boolean;
  46135. /**
  46136. * Specifies the skybox size.
  46137. * 20 by default.
  46138. */
  46139. skyboxSize: number;
  46140. /**
  46141. * The texture used on the skybox for the main color.
  46142. * Comes from the BabylonJS CDN by default.
  46143. *
  46144. * Remarks: Can be either a texture or a url.
  46145. */
  46146. skyboxTexture: string | BaseTexture;
  46147. /**
  46148. * The color mixed in the skybox texture by default.
  46149. * BabylonJS clearColor by default.
  46150. */
  46151. skyboxColor: Color3;
  46152. /**
  46153. * The background rotation around the Y axis of the scene.
  46154. * This helps aligning the key lights of your scene with the background.
  46155. * 0 by default.
  46156. */
  46157. backgroundYRotation: number;
  46158. /**
  46159. * Compute automatically the size of the elements to best fit with the scene.
  46160. */
  46161. sizeAuto: boolean;
  46162. /**
  46163. * Default position of the rootMesh if autoSize is not true.
  46164. */
  46165. rootPosition: Vector3;
  46166. /**
  46167. * Sets up the image processing in the scene.
  46168. * true by default.
  46169. */
  46170. setupImageProcessing: boolean;
  46171. /**
  46172. * The texture used as your environment texture in the scene.
  46173. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  46174. *
  46175. * Remarks: Can be either a texture or a url.
  46176. */
  46177. environmentTexture: string | BaseTexture;
  46178. /**
  46179. * The value of the exposure to apply to the scene.
  46180. * 0.6 by default if setupImageProcessing is true.
  46181. */
  46182. cameraExposure: number;
  46183. /**
  46184. * The value of the contrast to apply to the scene.
  46185. * 1.6 by default if setupImageProcessing is true.
  46186. */
  46187. cameraContrast: number;
  46188. /**
  46189. * Specifies wether or not tonemapping should be enabled in the scene.
  46190. * true by default if setupImageProcessing is true.
  46191. */
  46192. toneMappingEnabled: boolean;
  46193. }
  46194. /**
  46195. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  46196. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  46197. * It also helps with the default setup of your imageProcessing configuration.
  46198. */
  46199. export class EnvironmentHelper {
  46200. /**
  46201. * Default ground texture URL.
  46202. */
  46203. private static _groundTextureCDNUrl;
  46204. /**
  46205. * Default skybox texture URL.
  46206. */
  46207. private static _skyboxTextureCDNUrl;
  46208. /**
  46209. * Default environment texture URL.
  46210. */
  46211. private static _environmentTextureCDNUrl;
  46212. /**
  46213. * Creates the default options for the helper.
  46214. */
  46215. private static _getDefaultOptions;
  46216. private _rootMesh;
  46217. /**
  46218. * Gets the root mesh created by the helper.
  46219. */
  46220. readonly rootMesh: Mesh;
  46221. private _skybox;
  46222. /**
  46223. * Gets the skybox created by the helper.
  46224. */
  46225. readonly skybox: Nullable<Mesh>;
  46226. private _skyboxTexture;
  46227. /**
  46228. * Gets the skybox texture created by the helper.
  46229. */
  46230. readonly skyboxTexture: Nullable<BaseTexture>;
  46231. private _skyboxMaterial;
  46232. /**
  46233. * Gets the skybox material created by the helper.
  46234. */
  46235. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  46236. private _ground;
  46237. /**
  46238. * Gets the ground mesh created by the helper.
  46239. */
  46240. readonly ground: Nullable<Mesh>;
  46241. private _groundTexture;
  46242. /**
  46243. * Gets the ground texture created by the helper.
  46244. */
  46245. readonly groundTexture: Nullable<BaseTexture>;
  46246. private _groundMirror;
  46247. /**
  46248. * Gets the ground mirror created by the helper.
  46249. */
  46250. readonly groundMirror: Nullable<MirrorTexture>;
  46251. /**
  46252. * Gets the ground mirror render list to helps pushing the meshes
  46253. * you wish in the ground reflection.
  46254. */
  46255. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  46256. private _groundMaterial;
  46257. /**
  46258. * Gets the ground material created by the helper.
  46259. */
  46260. readonly groundMaterial: Nullable<BackgroundMaterial>;
  46261. /**
  46262. * Stores the creation options.
  46263. */
  46264. private readonly _scene;
  46265. private _options;
  46266. /**
  46267. * This observable will be notified with any error during the creation of the environment,
  46268. * mainly texture creation errors.
  46269. */
  46270. onErrorObservable: Observable<{
  46271. message?: string;
  46272. exception?: any;
  46273. }>;
  46274. /**
  46275. * constructor
  46276. * @param options Defines the options we want to customize the helper
  46277. * @param scene The scene to add the material to
  46278. */
  46279. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  46280. /**
  46281. * Updates the background according to the new options
  46282. * @param options
  46283. */
  46284. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  46285. /**
  46286. * Sets the primary color of all the available elements.
  46287. * @param color the main color to affect to the ground and the background
  46288. */
  46289. setMainColor(color: Color3): void;
  46290. /**
  46291. * Setup the image processing according to the specified options.
  46292. */
  46293. private _setupImageProcessing;
  46294. /**
  46295. * Setup the environment texture according to the specified options.
  46296. */
  46297. private _setupEnvironmentTexture;
  46298. /**
  46299. * Setup the background according to the specified options.
  46300. */
  46301. private _setupBackground;
  46302. /**
  46303. * Get the scene sizes according to the setup.
  46304. */
  46305. private _getSceneSize;
  46306. /**
  46307. * Setup the ground according to the specified options.
  46308. */
  46309. private _setupGround;
  46310. /**
  46311. * Setup the ground material according to the specified options.
  46312. */
  46313. private _setupGroundMaterial;
  46314. /**
  46315. * Setup the ground diffuse texture according to the specified options.
  46316. */
  46317. private _setupGroundDiffuseTexture;
  46318. /**
  46319. * Setup the ground mirror texture according to the specified options.
  46320. */
  46321. private _setupGroundMirrorTexture;
  46322. /**
  46323. * Setup the ground to receive the mirror texture.
  46324. */
  46325. private _setupMirrorInGroundMaterial;
  46326. /**
  46327. * Setup the skybox according to the specified options.
  46328. */
  46329. private _setupSkybox;
  46330. /**
  46331. * Setup the skybox material according to the specified options.
  46332. */
  46333. private _setupSkyboxMaterial;
  46334. /**
  46335. * Setup the skybox reflection texture according to the specified options.
  46336. */
  46337. private _setupSkyboxReflectionTexture;
  46338. private _errorHandler;
  46339. /**
  46340. * Dispose all the elements created by the Helper.
  46341. */
  46342. dispose(): void;
  46343. }
  46344. }
  46345. declare module "babylonjs/Helpers/photoDome" {
  46346. import { Observable } from "babylonjs/Misc/observable";
  46347. import { Nullable } from "babylonjs/types";
  46348. import { Scene } from "babylonjs/scene";
  46349. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46350. import { Mesh } from "babylonjs/Meshes/mesh";
  46351. import { Texture } from "babylonjs/Materials/Textures/texture";
  46352. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  46353. import "babylonjs/Meshes/Builders/sphereBuilder";
  46354. /**
  46355. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  46356. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  46357. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  46358. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  46359. */
  46360. export class PhotoDome extends TransformNode {
  46361. /**
  46362. * Define the image as a Monoscopic panoramic 360 image.
  46363. */
  46364. static readonly MODE_MONOSCOPIC: number;
  46365. /**
  46366. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46367. */
  46368. static readonly MODE_TOPBOTTOM: number;
  46369. /**
  46370. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46371. */
  46372. static readonly MODE_SIDEBYSIDE: number;
  46373. private _useDirectMapping;
  46374. /**
  46375. * The texture being displayed on the sphere
  46376. */
  46377. protected _photoTexture: Texture;
  46378. /**
  46379. * Gets or sets the texture being displayed on the sphere
  46380. */
  46381. photoTexture: Texture;
  46382. /**
  46383. * Observable raised when an error occured while loading the 360 image
  46384. */
  46385. onLoadErrorObservable: Observable<string>;
  46386. /**
  46387. * The skybox material
  46388. */
  46389. protected _material: BackgroundMaterial;
  46390. /**
  46391. * The surface used for the skybox
  46392. */
  46393. protected _mesh: Mesh;
  46394. /**
  46395. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  46396. * Also see the options.resolution property.
  46397. */
  46398. fovMultiplier: number;
  46399. private _imageMode;
  46400. /**
  46401. * Gets or set the current video mode for the video. It can be:
  46402. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  46403. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  46404. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  46405. */
  46406. imageMode: number;
  46407. /**
  46408. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  46409. * @param name Element's name, child elements will append suffixes for their own names.
  46410. * @param urlsOfPhoto defines the url of the photo to display
  46411. * @param options defines an object containing optional or exposed sub element properties
  46412. * @param onError defines a callback called when an error occured while loading the texture
  46413. */
  46414. constructor(name: string, urlOfPhoto: string, options: {
  46415. resolution?: number;
  46416. size?: number;
  46417. useDirectMapping?: boolean;
  46418. faceForward?: boolean;
  46419. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  46420. private _onBeforeCameraRenderObserver;
  46421. private _changeImageMode;
  46422. /**
  46423. * Releases resources associated with this node.
  46424. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46425. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46426. */
  46427. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  46428. }
  46429. }
  46430. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46431. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46432. /** @hidden */
  46433. export var rgbdDecodePixelShader: {
  46434. name: string;
  46435. shader: string;
  46436. };
  46437. }
  46438. declare module "babylonjs/Misc/brdfTextureTools" {
  46439. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46440. import { Scene } from "babylonjs/scene";
  46441. import "babylonjs/Shaders/rgbdDecode.fragment";
  46442. /**
  46443. * Class used to host texture specific utilities
  46444. */
  46445. export class BRDFTextureTools {
  46446. /**
  46447. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  46448. * @param texture the texture to expand.
  46449. */
  46450. private static _ExpandDefaultBRDFTexture;
  46451. /**
  46452. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  46453. * @param scene defines the hosting scene
  46454. * @returns the environment BRDF texture
  46455. */
  46456. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  46457. private static _environmentBRDFBase64Texture;
  46458. }
  46459. }
  46460. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  46461. import { Nullable } from "babylonjs/types";
  46462. import { IAnimatable } from "babylonjs/Misc/tools";
  46463. import { Color3 } from "babylonjs/Maths/math";
  46464. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46465. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46466. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46467. import { Engine } from "babylonjs/Engines/engine";
  46468. import { Scene } from "babylonjs/scene";
  46469. /**
  46470. * @hidden
  46471. */
  46472. export interface IMaterialClearCoatDefines {
  46473. CLEARCOAT: boolean;
  46474. CLEARCOAT_DEFAULTIOR: boolean;
  46475. CLEARCOAT_TEXTURE: boolean;
  46476. CLEARCOAT_TEXTUREDIRECTUV: number;
  46477. CLEARCOAT_BUMP: boolean;
  46478. CLEARCOAT_BUMPDIRECTUV: number;
  46479. CLEARCOAT_TINT: boolean;
  46480. CLEARCOAT_TINT_TEXTURE: boolean;
  46481. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46482. /** @hidden */
  46483. _areTexturesDirty: boolean;
  46484. }
  46485. /**
  46486. * Define the code related to the clear coat parameters of the pbr material.
  46487. */
  46488. export class PBRClearCoatConfiguration {
  46489. /**
  46490. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46491. * The default fits with a polyurethane material.
  46492. */
  46493. private static readonly _DefaultIndexOfRefraction;
  46494. private _isEnabled;
  46495. /**
  46496. * Defines if the clear coat is enabled in the material.
  46497. */
  46498. isEnabled: boolean;
  46499. /**
  46500. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  46501. */
  46502. intensity: number;
  46503. /**
  46504. * Defines the clear coat layer roughness.
  46505. */
  46506. roughness: number;
  46507. private _indexOfRefraction;
  46508. /**
  46509. * Defines the index of refraction of the clear coat.
  46510. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46511. * The default fits with a polyurethane material.
  46512. * Changing the default value is more performance intensive.
  46513. */
  46514. indexOfRefraction: number;
  46515. private _texture;
  46516. /**
  46517. * Stores the clear coat values in a texture.
  46518. */
  46519. texture: Nullable<BaseTexture>;
  46520. private _bumpTexture;
  46521. /**
  46522. * Define the clear coat specific bump texture.
  46523. */
  46524. bumpTexture: Nullable<BaseTexture>;
  46525. private _isTintEnabled;
  46526. /**
  46527. * Defines if the clear coat tint is enabled in the material.
  46528. */
  46529. isTintEnabled: boolean;
  46530. /**
  46531. * Defines the clear coat tint of the material.
  46532. * This is only use if tint is enabled
  46533. */
  46534. tintColor: Color3;
  46535. /**
  46536. * Defines the distance at which the tint color should be found in the
  46537. * clear coat media.
  46538. * This is only use if tint is enabled
  46539. */
  46540. tintColorAtDistance: number;
  46541. /**
  46542. * Defines the clear coat layer thickness.
  46543. * This is only use if tint is enabled
  46544. */
  46545. tintThickness: number;
  46546. private _tintTexture;
  46547. /**
  46548. * Stores the clear tint values in a texture.
  46549. * rgb is tint
  46550. * a is a thickness factor
  46551. */
  46552. tintTexture: Nullable<BaseTexture>;
  46553. /** @hidden */
  46554. private _internalMarkAllSubMeshesAsTexturesDirty;
  46555. /** @hidden */
  46556. _markAllSubMeshesAsTexturesDirty(): void;
  46557. /**
  46558. * Instantiate a new istance of clear coat configuration.
  46559. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46560. */
  46561. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46562. /**
  46563. * Gets wehter the submesh is ready to be used or not.
  46564. * @param defines the list of "defines" to update.
  46565. * @param scene defines the scene the material belongs to.
  46566. * @param engine defines the engine the material belongs to.
  46567. * @param disableBumpMap defines wether the material disables bump or not.
  46568. * @returns - boolean indicating that the submesh is ready or not.
  46569. */
  46570. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46571. /**
  46572. * Checks to see if a texture is used in the material.
  46573. * @param defines the list of "defines" to update.
  46574. * @param scene defines the scene to the material belongs to.
  46575. */
  46576. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46577. /**
  46578. * Binds the material data.
  46579. * @param uniformBuffer defines the Uniform buffer to fill in.
  46580. * @param scene defines the scene the material belongs to.
  46581. * @param engine defines the engine the material belongs to.
  46582. * @param disableBumpMap defines wether the material disables bump or not.
  46583. * @param isFrozen defines wether the material is frozen or not.
  46584. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46585. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46586. */
  46587. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46588. /**
  46589. * Checks to see if a texture is used in the material.
  46590. * @param texture - Base texture to use.
  46591. * @returns - Boolean specifying if a texture is used in the material.
  46592. */
  46593. hasTexture(texture: BaseTexture): boolean;
  46594. /**
  46595. * Returns an array of the actively used textures.
  46596. * @param activeTextures Array of BaseTextures
  46597. */
  46598. getActiveTextures(activeTextures: BaseTexture[]): void;
  46599. /**
  46600. * Returns the animatable textures.
  46601. * @param animatables Array of animatable textures.
  46602. */
  46603. getAnimatables(animatables: IAnimatable[]): void;
  46604. /**
  46605. * Disposes the resources of the material.
  46606. * @param forceDisposeTextures - Forces the disposal of all textures.
  46607. */
  46608. dispose(forceDisposeTextures?: boolean): void;
  46609. /**
  46610. * Get the current class name of the texture useful for serialization or dynamic coding.
  46611. * @returns "PBRClearCoatConfiguration"
  46612. */
  46613. getClassName(): string;
  46614. /**
  46615. * Add fallbacks to the effect fallbacks list.
  46616. * @param defines defines the Base texture to use.
  46617. * @param fallbacks defines the current fallback list.
  46618. * @param currentRank defines the current fallback rank.
  46619. * @returns the new fallback rank.
  46620. */
  46621. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46622. /**
  46623. * Add the required uniforms to the current list.
  46624. * @param uniforms defines the current uniform list.
  46625. */
  46626. static AddUniforms(uniforms: string[]): void;
  46627. /**
  46628. * Add the required samplers to the current list.
  46629. * @param samplers defines the current sampler list.
  46630. */
  46631. static AddSamplers(samplers: string[]): void;
  46632. /**
  46633. * Add the required uniforms to the current buffer.
  46634. * @param uniformBuffer defines the current uniform buffer.
  46635. */
  46636. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46637. /**
  46638. * Makes a duplicate of the current configuration into another one.
  46639. * @param clearCoatConfiguration define the config where to copy the info
  46640. */
  46641. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46642. /**
  46643. * Serializes this clear coat configuration.
  46644. * @returns - An object with the serialized config.
  46645. */
  46646. serialize(): any;
  46647. /**
  46648. * Parses a anisotropy Configuration from a serialized object.
  46649. * @param source - Serialized object.
  46650. * @param scene Defines the scene we are parsing for
  46651. * @param rootUrl Defines the rootUrl to load from
  46652. */
  46653. parse(source: any, scene: Scene, rootUrl: string): void;
  46654. }
  46655. }
  46656. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  46657. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46658. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46659. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46660. import { Vector2 } from "babylonjs/Maths/math";
  46661. import { Scene } from "babylonjs/scene";
  46662. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46663. import { IAnimatable } from "babylonjs/Misc/tools";
  46664. import { Nullable } from "babylonjs/types";
  46665. /**
  46666. * @hidden
  46667. */
  46668. export interface IMaterialAnisotropicDefines {
  46669. ANISOTROPIC: boolean;
  46670. ANISOTROPIC_TEXTURE: boolean;
  46671. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46672. MAINUV1: boolean;
  46673. _areTexturesDirty: boolean;
  46674. _needUVs: boolean;
  46675. }
  46676. /**
  46677. * Define the code related to the anisotropic parameters of the pbr material.
  46678. */
  46679. export class PBRAnisotropicConfiguration {
  46680. private _isEnabled;
  46681. /**
  46682. * Defines if the anisotropy is enabled in the material.
  46683. */
  46684. isEnabled: boolean;
  46685. /**
  46686. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46687. */
  46688. intensity: number;
  46689. /**
  46690. * Defines if the effect is along the tangents, bitangents or in between.
  46691. * By default, the effect is "strectching" the highlights along the tangents.
  46692. */
  46693. direction: Vector2;
  46694. private _texture;
  46695. /**
  46696. * Stores the anisotropy values in a texture.
  46697. * rg is direction (like normal from -1 to 1)
  46698. * b is a intensity
  46699. */
  46700. texture: Nullable<BaseTexture>;
  46701. /** @hidden */
  46702. private _internalMarkAllSubMeshesAsTexturesDirty;
  46703. /** @hidden */
  46704. _markAllSubMeshesAsTexturesDirty(): void;
  46705. /**
  46706. * Instantiate a new istance of anisotropy configuration.
  46707. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46708. */
  46709. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46710. /**
  46711. * Specifies that the submesh is ready to be used.
  46712. * @param defines the list of "defines" to update.
  46713. * @param scene defines the scene the material belongs to.
  46714. * @returns - boolean indicating that the submesh is ready or not.
  46715. */
  46716. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46717. /**
  46718. * Checks to see if a texture is used in the material.
  46719. * @param defines the list of "defines" to update.
  46720. * @param mesh the mesh we are preparing the defines for.
  46721. * @param scene defines the scene the material belongs to.
  46722. */
  46723. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46724. /**
  46725. * Binds the material data.
  46726. * @param uniformBuffer defines the Uniform buffer to fill in.
  46727. * @param scene defines the scene the material belongs to.
  46728. * @param isFrozen defines wether the material is frozen or not.
  46729. */
  46730. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46731. /**
  46732. * Checks to see if a texture is used in the material.
  46733. * @param texture - Base texture to use.
  46734. * @returns - Boolean specifying if a texture is used in the material.
  46735. */
  46736. hasTexture(texture: BaseTexture): boolean;
  46737. /**
  46738. * Returns an array of the actively used textures.
  46739. * @param activeTextures Array of BaseTextures
  46740. */
  46741. getActiveTextures(activeTextures: BaseTexture[]): void;
  46742. /**
  46743. * Returns the animatable textures.
  46744. * @param animatables Array of animatable textures.
  46745. */
  46746. getAnimatables(animatables: IAnimatable[]): void;
  46747. /**
  46748. * Disposes the resources of the material.
  46749. * @param forceDisposeTextures - Forces the disposal of all textures.
  46750. */
  46751. dispose(forceDisposeTextures?: boolean): void;
  46752. /**
  46753. * Get the current class name of the texture useful for serialization or dynamic coding.
  46754. * @returns "PBRAnisotropicConfiguration"
  46755. */
  46756. getClassName(): string;
  46757. /**
  46758. * Add fallbacks to the effect fallbacks list.
  46759. * @param defines defines the Base texture to use.
  46760. * @param fallbacks defines the current fallback list.
  46761. * @param currentRank defines the current fallback rank.
  46762. * @returns the new fallback rank.
  46763. */
  46764. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46765. /**
  46766. * Add the required uniforms to the current list.
  46767. * @param uniforms defines the current uniform list.
  46768. */
  46769. static AddUniforms(uniforms: string[]): void;
  46770. /**
  46771. * Add the required uniforms to the current buffer.
  46772. * @param uniformBuffer defines the current uniform buffer.
  46773. */
  46774. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46775. /**
  46776. * Add the required samplers to the current list.
  46777. * @param samplers defines the current sampler list.
  46778. */
  46779. static AddSamplers(samplers: string[]): void;
  46780. /**
  46781. * Makes a duplicate of the current configuration into another one.
  46782. * @param anisotropicConfiguration define the config where to copy the info
  46783. */
  46784. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46785. /**
  46786. * Serializes this anisotropy configuration.
  46787. * @returns - An object with the serialized config.
  46788. */
  46789. serialize(): any;
  46790. /**
  46791. * Parses a anisotropy Configuration from a serialized object.
  46792. * @param source - Serialized object.
  46793. * @param scene Defines the scene we are parsing for
  46794. * @param rootUrl Defines the rootUrl to load from
  46795. */
  46796. parse(source: any, scene: Scene, rootUrl: string): void;
  46797. }
  46798. }
  46799. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  46800. import { Scene } from "babylonjs/scene";
  46801. /**
  46802. * @hidden
  46803. */
  46804. export interface IMaterialBRDFDefines {
  46805. BRDF_V_HEIGHT_CORRELATED: boolean;
  46806. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46807. SPHERICAL_HARMONICS: boolean;
  46808. /** @hidden */
  46809. _areMiscDirty: boolean;
  46810. }
  46811. /**
  46812. * Define the code related to the BRDF parameters of the pbr material.
  46813. */
  46814. export class PBRBRDFConfiguration {
  46815. /**
  46816. * Default value used for the energy conservation.
  46817. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46818. */
  46819. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46820. /**
  46821. * Default value used for the Smith Visibility Height Correlated mode.
  46822. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46823. */
  46824. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46825. /**
  46826. * Default value used for the IBL diffuse part.
  46827. * This can help switching back to the polynomials mode globally which is a tiny bit
  46828. * less GPU intensive at the drawback of a lower quality.
  46829. */
  46830. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46831. private _useEnergyConservation;
  46832. /**
  46833. * Defines if the material uses energy conservation.
  46834. */
  46835. useEnergyConservation: boolean;
  46836. private _useSmithVisibilityHeightCorrelated;
  46837. /**
  46838. * LEGACY Mode set to false
  46839. * Defines if the material uses height smith correlated visibility term.
  46840. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46841. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46842. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46843. * Not relying on height correlated will also disable energy conservation.
  46844. */
  46845. useSmithVisibilityHeightCorrelated: boolean;
  46846. private _useSphericalHarmonics;
  46847. /**
  46848. * LEGACY Mode set to false
  46849. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46850. * diffuse part of the IBL.
  46851. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46852. * to the ground truth.
  46853. */
  46854. useSphericalHarmonics: boolean;
  46855. /** @hidden */
  46856. private _internalMarkAllSubMeshesAsMiscDirty;
  46857. /** @hidden */
  46858. _markAllSubMeshesAsMiscDirty(): void;
  46859. /**
  46860. * Instantiate a new istance of clear coat configuration.
  46861. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46862. */
  46863. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46864. /**
  46865. * Checks to see if a texture is used in the material.
  46866. * @param defines the list of "defines" to update.
  46867. */
  46868. prepareDefines(defines: IMaterialBRDFDefines): void;
  46869. /**
  46870. * Get the current class name of the texture useful for serialization or dynamic coding.
  46871. * @returns "PBRClearCoatConfiguration"
  46872. */
  46873. getClassName(): string;
  46874. /**
  46875. * Makes a duplicate of the current configuration into another one.
  46876. * @param brdfConfiguration define the config where to copy the info
  46877. */
  46878. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46879. /**
  46880. * Serializes this BRDF configuration.
  46881. * @returns - An object with the serialized config.
  46882. */
  46883. serialize(): any;
  46884. /**
  46885. * Parses a anisotropy Configuration from a serialized object.
  46886. * @param source - Serialized object.
  46887. * @param scene Defines the scene we are parsing for
  46888. * @param rootUrl Defines the rootUrl to load from
  46889. */
  46890. parse(source: any, scene: Scene, rootUrl: string): void;
  46891. }
  46892. }
  46893. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  46894. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46895. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46896. import { Color3 } from "babylonjs/Maths/math";
  46897. import { Scene } from "babylonjs/scene";
  46898. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46899. import { IAnimatable } from "babylonjs/Misc/tools";
  46900. import { Nullable } from "babylonjs/types";
  46901. /**
  46902. * @hidden
  46903. */
  46904. export interface IMaterialSheenDefines {
  46905. SHEEN: boolean;
  46906. SHEEN_TEXTURE: boolean;
  46907. SHEEN_TEXTUREDIRECTUV: number;
  46908. SHEEN_LINKWITHALBEDO: boolean;
  46909. /** @hidden */
  46910. _areTexturesDirty: boolean;
  46911. }
  46912. /**
  46913. * Define the code related to the Sheen parameters of the pbr material.
  46914. */
  46915. export class PBRSheenConfiguration {
  46916. private _isEnabled;
  46917. /**
  46918. * Defines if the material uses sheen.
  46919. */
  46920. isEnabled: boolean;
  46921. private _linkSheenWithAlbedo;
  46922. /**
  46923. * Defines if the sheen is linked to the sheen color.
  46924. */
  46925. linkSheenWithAlbedo: boolean;
  46926. /**
  46927. * Defines the sheen intensity.
  46928. */
  46929. intensity: number;
  46930. /**
  46931. * Defines the sheen color.
  46932. */
  46933. color: Color3;
  46934. private _texture;
  46935. /**
  46936. * Stores the sheen tint values in a texture.
  46937. * rgb is tint
  46938. * a is a intensity
  46939. */
  46940. texture: Nullable<BaseTexture>;
  46941. /** @hidden */
  46942. private _internalMarkAllSubMeshesAsTexturesDirty;
  46943. /** @hidden */
  46944. _markAllSubMeshesAsTexturesDirty(): void;
  46945. /**
  46946. * Instantiate a new istance of clear coat configuration.
  46947. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46948. */
  46949. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46950. /**
  46951. * Specifies that the submesh is ready to be used.
  46952. * @param defines the list of "defines" to update.
  46953. * @param scene defines the scene the material belongs to.
  46954. * @returns - boolean indicating that the submesh is ready or not.
  46955. */
  46956. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46957. /**
  46958. * Checks to see if a texture is used in the material.
  46959. * @param defines the list of "defines" to update.
  46960. * @param scene defines the scene the material belongs to.
  46961. */
  46962. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46963. /**
  46964. * Binds the material data.
  46965. * @param uniformBuffer defines the Uniform buffer to fill in.
  46966. * @param scene defines the scene the material belongs to.
  46967. * @param isFrozen defines wether the material is frozen or not.
  46968. */
  46969. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46970. /**
  46971. * Checks to see if a texture is used in the material.
  46972. * @param texture - Base texture to use.
  46973. * @returns - Boolean specifying if a texture is used in the material.
  46974. */
  46975. hasTexture(texture: BaseTexture): boolean;
  46976. /**
  46977. * Returns an array of the actively used textures.
  46978. * @param activeTextures Array of BaseTextures
  46979. */
  46980. getActiveTextures(activeTextures: BaseTexture[]): void;
  46981. /**
  46982. * Returns the animatable textures.
  46983. * @param animatables Array of animatable textures.
  46984. */
  46985. getAnimatables(animatables: IAnimatable[]): void;
  46986. /**
  46987. * Disposes the resources of the material.
  46988. * @param forceDisposeTextures - Forces the disposal of all textures.
  46989. */
  46990. dispose(forceDisposeTextures?: boolean): void;
  46991. /**
  46992. * Get the current class name of the texture useful for serialization or dynamic coding.
  46993. * @returns "PBRSheenConfiguration"
  46994. */
  46995. getClassName(): string;
  46996. /**
  46997. * Add fallbacks to the effect fallbacks list.
  46998. * @param defines defines the Base texture to use.
  46999. * @param fallbacks defines the current fallback list.
  47000. * @param currentRank defines the current fallback rank.
  47001. * @returns the new fallback rank.
  47002. */
  47003. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47004. /**
  47005. * Add the required uniforms to the current list.
  47006. * @param uniforms defines the current uniform list.
  47007. */
  47008. static AddUniforms(uniforms: string[]): void;
  47009. /**
  47010. * Add the required uniforms to the current buffer.
  47011. * @param uniformBuffer defines the current uniform buffer.
  47012. */
  47013. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47014. /**
  47015. * Add the required samplers to the current list.
  47016. * @param samplers defines the current sampler list.
  47017. */
  47018. static AddSamplers(samplers: string[]): void;
  47019. /**
  47020. * Makes a duplicate of the current configuration into another one.
  47021. * @param sheenConfiguration define the config where to copy the info
  47022. */
  47023. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  47024. /**
  47025. * Serializes this BRDF configuration.
  47026. * @returns - An object with the serialized config.
  47027. */
  47028. serialize(): any;
  47029. /**
  47030. * Parses a anisotropy Configuration from a serialized object.
  47031. * @param source - Serialized object.
  47032. * @param scene Defines the scene we are parsing for
  47033. * @param rootUrl Defines the rootUrl to load from
  47034. */
  47035. parse(source: any, scene: Scene, rootUrl: string): void;
  47036. }
  47037. }
  47038. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  47039. import { Nullable } from "babylonjs/types";
  47040. import { IAnimatable } from "babylonjs/Misc/tools";
  47041. import { Color3 } from "babylonjs/Maths/math";
  47042. import { SmartArray } from "babylonjs/Misc/smartArray";
  47043. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47044. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47045. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  47046. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  47047. import { Engine } from "babylonjs/Engines/engine";
  47048. import { Scene } from "babylonjs/scene";
  47049. /**
  47050. * @hidden
  47051. */
  47052. export interface IMaterialSubSurfaceDefines {
  47053. SUBSURFACE: boolean;
  47054. SS_REFRACTION: boolean;
  47055. SS_TRANSLUCENCY: boolean;
  47056. SS_SCATERRING: boolean;
  47057. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47058. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47059. SS_REFRACTIONMAP_3D: boolean;
  47060. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47061. SS_LODINREFRACTIONALPHA: boolean;
  47062. SS_GAMMAREFRACTION: boolean;
  47063. SS_RGBDREFRACTION: boolean;
  47064. SS_LINEARSPECULARREFRACTION: boolean;
  47065. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47066. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47067. /** @hidden */
  47068. _areTexturesDirty: boolean;
  47069. }
  47070. /**
  47071. * Define the code related to the sub surface parameters of the pbr material.
  47072. */
  47073. export class PBRSubSurfaceConfiguration {
  47074. private _isRefractionEnabled;
  47075. /**
  47076. * Defines if the refraction is enabled in the material.
  47077. */
  47078. isRefractionEnabled: boolean;
  47079. private _isTranslucencyEnabled;
  47080. /**
  47081. * Defines if the translucency is enabled in the material.
  47082. */
  47083. isTranslucencyEnabled: boolean;
  47084. private _isScatteringEnabled;
  47085. /**
  47086. * Defines the refraction intensity of the material.
  47087. * The refraction when enabled replaces the Diffuse part of the material.
  47088. * The intensity helps transitionning between diffuse and refraction.
  47089. */
  47090. refractionIntensity: number;
  47091. /**
  47092. * Defines the translucency intensity of the material.
  47093. * When translucency has been enabled, this defines how much of the "translucency"
  47094. * is addded to the diffuse part of the material.
  47095. */
  47096. translucencyIntensity: number;
  47097. /**
  47098. * Defines the scattering intensity of the material.
  47099. * When scattering has been enabled, this defines how much of the "scattered light"
  47100. * is addded to the diffuse part of the material.
  47101. */
  47102. scatteringIntensity: number;
  47103. private _thicknessTexture;
  47104. /**
  47105. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  47106. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  47107. * 0 would mean minimumThickness
  47108. * 1 would mean maximumThickness
  47109. * The other channels might be use as a mask to vary the different effects intensity.
  47110. */
  47111. thicknessTexture: Nullable<BaseTexture>;
  47112. private _refractionTexture;
  47113. /**
  47114. * Defines the texture to use for refraction.
  47115. */
  47116. refractionTexture: Nullable<BaseTexture>;
  47117. private _indexOfRefraction;
  47118. /**
  47119. * Defines the index of refraction used in the material.
  47120. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  47121. */
  47122. indexOfRefraction: number;
  47123. private _invertRefractionY;
  47124. /**
  47125. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47126. */
  47127. invertRefractionY: boolean;
  47128. private _linkRefractionWithTransparency;
  47129. /**
  47130. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47131. * Materials half opaque for instance using refraction could benefit from this control.
  47132. */
  47133. linkRefractionWithTransparency: boolean;
  47134. /**
  47135. * Defines the minimum thickness stored in the thickness map.
  47136. * If no thickness map is defined, this value will be used to simulate thickness.
  47137. */
  47138. minimumThickness: number;
  47139. /**
  47140. * Defines the maximum thickness stored in the thickness map.
  47141. */
  47142. maximumThickness: number;
  47143. /**
  47144. * Defines the volume tint of the material.
  47145. * This is used for both translucency and scattering.
  47146. */
  47147. tintColor: Color3;
  47148. /**
  47149. * Defines the distance at which the tint color should be found in the media.
  47150. * This is used for refraction only.
  47151. */
  47152. tintColorAtDistance: number;
  47153. /**
  47154. * Defines how far each channel transmit through the media.
  47155. * It is defined as a color to simplify it selection.
  47156. */
  47157. diffusionDistance: Color3;
  47158. private _useMaskFromThicknessTexture;
  47159. /**
  47160. * Stores the intensity of the different subsurface effects in the thickness texture.
  47161. * * the green channel is the translucency intensity.
  47162. * * the blue channel is the scattering intensity.
  47163. * * the alpha channel is the refraction intensity.
  47164. */
  47165. useMaskFromThicknessTexture: boolean;
  47166. /** @hidden */
  47167. private _internalMarkAllSubMeshesAsTexturesDirty;
  47168. /** @hidden */
  47169. _markAllSubMeshesAsTexturesDirty(): void;
  47170. /**
  47171. * Instantiate a new istance of sub surface configuration.
  47172. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  47173. */
  47174. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  47175. /**
  47176. * Gets wehter the submesh is ready to be used or not.
  47177. * @param defines the list of "defines" to update.
  47178. * @param scene defines the scene the material belongs to.
  47179. * @returns - boolean indicating that the submesh is ready or not.
  47180. */
  47181. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  47182. /**
  47183. * Checks to see if a texture is used in the material.
  47184. * @param defines the list of "defines" to update.
  47185. * @param scene defines the scene to the material belongs to.
  47186. */
  47187. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  47188. /**
  47189. * Binds the material data.
  47190. * @param uniformBuffer defines the Uniform buffer to fill in.
  47191. * @param scene defines the scene the material belongs to.
  47192. * @param engine defines the engine the material belongs to.
  47193. * @param isFrozen defines wether the material is frozen or not.
  47194. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  47195. */
  47196. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  47197. /**
  47198. * Unbinds the material from the mesh.
  47199. * @param activeEffect defines the effect that should be unbound from.
  47200. * @returns true if unbound, otherwise false
  47201. */
  47202. unbind(activeEffect: Effect): boolean;
  47203. /**
  47204. * Returns the texture used for refraction or null if none is used.
  47205. * @param scene defines the scene the material belongs to.
  47206. * @returns - Refraction texture if present. If no refraction texture and refraction
  47207. * is linked with transparency, returns environment texture. Otherwise, returns null.
  47208. */
  47209. private _getRefractionTexture;
  47210. /**
  47211. * Returns true if alpha blending should be disabled.
  47212. */
  47213. readonly disableAlphaBlending: boolean;
  47214. /**
  47215. * Fills the list of render target textures.
  47216. * @param renderTargets the list of render targets to update
  47217. */
  47218. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  47219. /**
  47220. * Checks to see if a texture is used in the material.
  47221. * @param texture - Base texture to use.
  47222. * @returns - Boolean specifying if a texture is used in the material.
  47223. */
  47224. hasTexture(texture: BaseTexture): boolean;
  47225. /**
  47226. * Gets a boolean indicating that current material needs to register RTT
  47227. * @returns true if this uses a render target otherwise false.
  47228. */
  47229. hasRenderTargetTextures(): boolean;
  47230. /**
  47231. * Returns an array of the actively used textures.
  47232. * @param activeTextures Array of BaseTextures
  47233. */
  47234. getActiveTextures(activeTextures: BaseTexture[]): void;
  47235. /**
  47236. * Returns the animatable textures.
  47237. * @param animatables Array of animatable textures.
  47238. */
  47239. getAnimatables(animatables: IAnimatable[]): void;
  47240. /**
  47241. * Disposes the resources of the material.
  47242. * @param forceDisposeTextures - Forces the disposal of all textures.
  47243. */
  47244. dispose(forceDisposeTextures?: boolean): void;
  47245. /**
  47246. * Get the current class name of the texture useful for serialization or dynamic coding.
  47247. * @returns "PBRSubSurfaceConfiguration"
  47248. */
  47249. getClassName(): string;
  47250. /**
  47251. * Add fallbacks to the effect fallbacks list.
  47252. * @param defines defines the Base texture to use.
  47253. * @param fallbacks defines the current fallback list.
  47254. * @param currentRank defines the current fallback rank.
  47255. * @returns the new fallback rank.
  47256. */
  47257. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  47258. /**
  47259. * Add the required uniforms to the current list.
  47260. * @param uniforms defines the current uniform list.
  47261. */
  47262. static AddUniforms(uniforms: string[]): void;
  47263. /**
  47264. * Add the required samplers to the current list.
  47265. * @param samplers defines the current sampler list.
  47266. */
  47267. static AddSamplers(samplers: string[]): void;
  47268. /**
  47269. * Add the required uniforms to the current buffer.
  47270. * @param uniformBuffer defines the current uniform buffer.
  47271. */
  47272. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  47273. /**
  47274. * Makes a duplicate of the current configuration into another one.
  47275. * @param configuration define the config where to copy the info
  47276. */
  47277. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  47278. /**
  47279. * Serializes this Sub Surface configuration.
  47280. * @returns - An object with the serialized config.
  47281. */
  47282. serialize(): any;
  47283. /**
  47284. * Parses a anisotropy Configuration from a serialized object.
  47285. * @param source - Serialized object.
  47286. * @param scene Defines the scene we are parsing for
  47287. * @param rootUrl Defines the rootUrl to load from
  47288. */
  47289. parse(source: any, scene: Scene, rootUrl: string): void;
  47290. }
  47291. }
  47292. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  47293. /** @hidden */
  47294. export var pbrFragmentDeclaration: {
  47295. name: string;
  47296. shader: string;
  47297. };
  47298. }
  47299. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  47300. /** @hidden */
  47301. export var pbrUboDeclaration: {
  47302. name: string;
  47303. shader: string;
  47304. };
  47305. }
  47306. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  47307. /** @hidden */
  47308. export var pbrFragmentExtraDeclaration: {
  47309. name: string;
  47310. shader: string;
  47311. };
  47312. }
  47313. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  47314. /** @hidden */
  47315. export var pbrFragmentSamplersDeclaration: {
  47316. name: string;
  47317. shader: string;
  47318. };
  47319. }
  47320. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  47321. /** @hidden */
  47322. export var pbrHelperFunctions: {
  47323. name: string;
  47324. shader: string;
  47325. };
  47326. }
  47327. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  47328. /** @hidden */
  47329. export var harmonicsFunctions: {
  47330. name: string;
  47331. shader: string;
  47332. };
  47333. }
  47334. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  47335. /** @hidden */
  47336. export var pbrDirectLightingSetupFunctions: {
  47337. name: string;
  47338. shader: string;
  47339. };
  47340. }
  47341. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  47342. /** @hidden */
  47343. export var pbrDirectLightingFalloffFunctions: {
  47344. name: string;
  47345. shader: string;
  47346. };
  47347. }
  47348. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  47349. /** @hidden */
  47350. export var pbrBRDFFunctions: {
  47351. name: string;
  47352. shader: string;
  47353. };
  47354. }
  47355. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  47356. /** @hidden */
  47357. export var pbrDirectLightingFunctions: {
  47358. name: string;
  47359. shader: string;
  47360. };
  47361. }
  47362. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  47363. /** @hidden */
  47364. export var pbrIBLFunctions: {
  47365. name: string;
  47366. shader: string;
  47367. };
  47368. }
  47369. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  47370. /** @hidden */
  47371. export var pbrDebug: {
  47372. name: string;
  47373. shader: string;
  47374. };
  47375. }
  47376. declare module "babylonjs/Shaders/pbr.fragment" {
  47377. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  47378. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47379. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  47380. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47381. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47382. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  47383. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47384. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47385. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47386. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47387. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47388. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  47389. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47390. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47391. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47392. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  47393. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  47394. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  47395. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  47396. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  47397. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  47398. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47399. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47400. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  47401. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  47402. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47403. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  47404. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47405. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  47406. /** @hidden */
  47407. export var pbrPixelShader: {
  47408. name: string;
  47409. shader: string;
  47410. };
  47411. }
  47412. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  47413. /** @hidden */
  47414. export var pbrVertexDeclaration: {
  47415. name: string;
  47416. shader: string;
  47417. };
  47418. }
  47419. declare module "babylonjs/Shaders/pbr.vertex" {
  47420. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  47421. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  47422. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47423. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47424. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47425. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  47426. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  47427. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47428. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47429. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47430. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47431. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  47432. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  47433. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  47434. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  47435. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47436. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47437. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  47438. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47439. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47440. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47441. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  47442. /** @hidden */
  47443. export var pbrVertexShader: {
  47444. name: string;
  47445. shader: string;
  47446. };
  47447. }
  47448. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  47449. import { IAnimatable } from "babylonjs/Misc/tools";
  47450. import { Nullable } from "babylonjs/types";
  47451. import { Scene } from "babylonjs/scene";
  47452. import { Matrix, Color3 } from "babylonjs/Maths/math";
  47453. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47454. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47455. import { Mesh } from "babylonjs/Meshes/mesh";
  47456. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  47457. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  47458. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  47459. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  47460. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  47461. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  47462. import { Material } from "babylonjs/Materials/material";
  47463. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  47464. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47465. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47466. import "babylonjs/Shaders/pbr.fragment";
  47467. import "babylonjs/Shaders/pbr.vertex";
  47468. /**
  47469. * Manages the defines for the PBR Material.
  47470. * @hidden
  47471. */
  47472. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  47473. PBR: boolean;
  47474. MAINUV1: boolean;
  47475. MAINUV2: boolean;
  47476. UV1: boolean;
  47477. UV2: boolean;
  47478. ALBEDO: boolean;
  47479. ALBEDODIRECTUV: number;
  47480. VERTEXCOLOR: boolean;
  47481. AMBIENT: boolean;
  47482. AMBIENTDIRECTUV: number;
  47483. AMBIENTINGRAYSCALE: boolean;
  47484. OPACITY: boolean;
  47485. VERTEXALPHA: boolean;
  47486. OPACITYDIRECTUV: number;
  47487. OPACITYRGB: boolean;
  47488. ALPHATEST: boolean;
  47489. DEPTHPREPASS: boolean;
  47490. ALPHABLEND: boolean;
  47491. ALPHAFROMALBEDO: boolean;
  47492. ALPHATESTVALUE: string;
  47493. SPECULAROVERALPHA: boolean;
  47494. RADIANCEOVERALPHA: boolean;
  47495. ALPHAFRESNEL: boolean;
  47496. LINEARALPHAFRESNEL: boolean;
  47497. PREMULTIPLYALPHA: boolean;
  47498. EMISSIVE: boolean;
  47499. EMISSIVEDIRECTUV: number;
  47500. REFLECTIVITY: boolean;
  47501. REFLECTIVITYDIRECTUV: number;
  47502. SPECULARTERM: boolean;
  47503. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47504. MICROSURFACEAUTOMATIC: boolean;
  47505. LODBASEDMICROSFURACE: boolean;
  47506. MICROSURFACEMAP: boolean;
  47507. MICROSURFACEMAPDIRECTUV: number;
  47508. METALLICWORKFLOW: boolean;
  47509. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  47510. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  47511. METALLNESSSTOREINMETALMAPBLUE: boolean;
  47512. AOSTOREINMETALMAPRED: boolean;
  47513. ENVIRONMENTBRDF: boolean;
  47514. ENVIRONMENTBRDF_RGBD: boolean;
  47515. NORMAL: boolean;
  47516. TANGENT: boolean;
  47517. BUMP: boolean;
  47518. BUMPDIRECTUV: number;
  47519. OBJECTSPACE_NORMALMAP: boolean;
  47520. PARALLAX: boolean;
  47521. PARALLAXOCCLUSION: boolean;
  47522. NORMALXYSCALE: boolean;
  47523. LIGHTMAP: boolean;
  47524. LIGHTMAPDIRECTUV: number;
  47525. USELIGHTMAPASSHADOWMAP: boolean;
  47526. GAMMALIGHTMAP: boolean;
  47527. REFLECTION: boolean;
  47528. REFLECTIONMAP_3D: boolean;
  47529. REFLECTIONMAP_SPHERICAL: boolean;
  47530. REFLECTIONMAP_PLANAR: boolean;
  47531. REFLECTIONMAP_CUBIC: boolean;
  47532. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  47533. REFLECTIONMAP_PROJECTION: boolean;
  47534. REFLECTIONMAP_SKYBOX: boolean;
  47535. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  47536. REFLECTIONMAP_EXPLICIT: boolean;
  47537. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  47538. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  47539. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  47540. INVERTCUBICMAP: boolean;
  47541. USESPHERICALFROMREFLECTIONMAP: boolean;
  47542. USEIRRADIANCEMAP: boolean;
  47543. SPHERICAL_HARMONICS: boolean;
  47544. USESPHERICALINVERTEX: boolean;
  47545. REFLECTIONMAP_OPPOSITEZ: boolean;
  47546. LODINREFLECTIONALPHA: boolean;
  47547. GAMMAREFLECTION: boolean;
  47548. RGBDREFLECTION: boolean;
  47549. LINEARSPECULARREFLECTION: boolean;
  47550. RADIANCEOCCLUSION: boolean;
  47551. HORIZONOCCLUSION: boolean;
  47552. INSTANCES: boolean;
  47553. NUM_BONE_INFLUENCERS: number;
  47554. BonesPerMesh: number;
  47555. BONETEXTURE: boolean;
  47556. NONUNIFORMSCALING: boolean;
  47557. MORPHTARGETS: boolean;
  47558. MORPHTARGETS_NORMAL: boolean;
  47559. MORPHTARGETS_TANGENT: boolean;
  47560. MORPHTARGETS_UV: boolean;
  47561. NUM_MORPH_INFLUENCERS: number;
  47562. IMAGEPROCESSING: boolean;
  47563. VIGNETTE: boolean;
  47564. VIGNETTEBLENDMODEMULTIPLY: boolean;
  47565. VIGNETTEBLENDMODEOPAQUE: boolean;
  47566. TONEMAPPING: boolean;
  47567. TONEMAPPING_ACES: boolean;
  47568. CONTRAST: boolean;
  47569. COLORCURVES: boolean;
  47570. COLORGRADING: boolean;
  47571. COLORGRADING3D: boolean;
  47572. SAMPLER3DGREENDEPTH: boolean;
  47573. SAMPLER3DBGRMAP: boolean;
  47574. IMAGEPROCESSINGPOSTPROCESS: boolean;
  47575. EXPOSURE: boolean;
  47576. MULTIVIEW: boolean;
  47577. USEPHYSICALLIGHTFALLOFF: boolean;
  47578. USEGLTFLIGHTFALLOFF: boolean;
  47579. TWOSIDEDLIGHTING: boolean;
  47580. SHADOWFLOAT: boolean;
  47581. CLIPPLANE: boolean;
  47582. CLIPPLANE2: boolean;
  47583. CLIPPLANE3: boolean;
  47584. CLIPPLANE4: boolean;
  47585. POINTSIZE: boolean;
  47586. FOG: boolean;
  47587. LOGARITHMICDEPTH: boolean;
  47588. FORCENORMALFORWARD: boolean;
  47589. SPECULARAA: boolean;
  47590. CLEARCOAT: boolean;
  47591. CLEARCOAT_DEFAULTIOR: boolean;
  47592. CLEARCOAT_TEXTURE: boolean;
  47593. CLEARCOAT_TEXTUREDIRECTUV: number;
  47594. CLEARCOAT_BUMP: boolean;
  47595. CLEARCOAT_BUMPDIRECTUV: number;
  47596. CLEARCOAT_TINT: boolean;
  47597. CLEARCOAT_TINT_TEXTURE: boolean;
  47598. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47599. ANISOTROPIC: boolean;
  47600. ANISOTROPIC_TEXTURE: boolean;
  47601. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47602. BRDF_V_HEIGHT_CORRELATED: boolean;
  47603. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47604. SHEEN: boolean;
  47605. SHEEN_TEXTURE: boolean;
  47606. SHEEN_TEXTUREDIRECTUV: number;
  47607. SHEEN_LINKWITHALBEDO: boolean;
  47608. SUBSURFACE: boolean;
  47609. SS_REFRACTION: boolean;
  47610. SS_TRANSLUCENCY: boolean;
  47611. SS_SCATERRING: boolean;
  47612. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47613. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47614. SS_REFRACTIONMAP_3D: boolean;
  47615. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47616. SS_LODINREFRACTIONALPHA: boolean;
  47617. SS_GAMMAREFRACTION: boolean;
  47618. SS_RGBDREFRACTION: boolean;
  47619. SS_LINEARSPECULARREFRACTION: boolean;
  47620. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47621. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47622. UNLIT: boolean;
  47623. DEBUGMODE: number;
  47624. /**
  47625. * Initializes the PBR Material defines.
  47626. */
  47627. constructor();
  47628. /**
  47629. * Resets the PBR Material defines.
  47630. */
  47631. reset(): void;
  47632. }
  47633. /**
  47634. * The Physically based material base class of BJS.
  47635. *
  47636. * This offers the main features of a standard PBR material.
  47637. * For more information, please refer to the documentation :
  47638. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47639. */
  47640. export abstract class PBRBaseMaterial extends PushMaterial {
  47641. /**
  47642. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47643. */
  47644. static readonly PBRMATERIAL_OPAQUE: number;
  47645. /**
  47646. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47647. */
  47648. static readonly PBRMATERIAL_ALPHATEST: number;
  47649. /**
  47650. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47651. */
  47652. static readonly PBRMATERIAL_ALPHABLEND: number;
  47653. /**
  47654. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47655. * They are also discarded below the alpha cutoff threshold to improve performances.
  47656. */
  47657. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47658. /**
  47659. * Defines the default value of how much AO map is occluding the analytical lights
  47660. * (point spot...).
  47661. */
  47662. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47663. /**
  47664. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47665. */
  47666. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47667. /**
  47668. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47669. * to enhance interoperability with other engines.
  47670. */
  47671. static readonly LIGHTFALLOFF_GLTF: number;
  47672. /**
  47673. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47674. * to enhance interoperability with other materials.
  47675. */
  47676. static readonly LIGHTFALLOFF_STANDARD: number;
  47677. /**
  47678. * Intensity of the direct lights e.g. the four lights available in your scene.
  47679. * This impacts both the direct diffuse and specular highlights.
  47680. */
  47681. protected _directIntensity: number;
  47682. /**
  47683. * Intensity of the emissive part of the material.
  47684. * This helps controlling the emissive effect without modifying the emissive color.
  47685. */
  47686. protected _emissiveIntensity: number;
  47687. /**
  47688. * Intensity of the environment e.g. how much the environment will light the object
  47689. * either through harmonics for rough material or through the refelction for shiny ones.
  47690. */
  47691. protected _environmentIntensity: number;
  47692. /**
  47693. * This is a special control allowing the reduction of the specular highlights coming from the
  47694. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47695. */
  47696. protected _specularIntensity: number;
  47697. /**
  47698. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47699. */
  47700. private _lightingInfos;
  47701. /**
  47702. * Debug Control allowing disabling the bump map on this material.
  47703. */
  47704. protected _disableBumpMap: boolean;
  47705. /**
  47706. * AKA Diffuse Texture in standard nomenclature.
  47707. */
  47708. protected _albedoTexture: Nullable<BaseTexture>;
  47709. /**
  47710. * AKA Occlusion Texture in other nomenclature.
  47711. */
  47712. protected _ambientTexture: Nullable<BaseTexture>;
  47713. /**
  47714. * AKA Occlusion Texture Intensity in other nomenclature.
  47715. */
  47716. protected _ambientTextureStrength: number;
  47717. /**
  47718. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47719. * 1 means it completely occludes it
  47720. * 0 mean it has no impact
  47721. */
  47722. protected _ambientTextureImpactOnAnalyticalLights: number;
  47723. /**
  47724. * Stores the alpha values in a texture.
  47725. */
  47726. protected _opacityTexture: Nullable<BaseTexture>;
  47727. /**
  47728. * Stores the reflection values in a texture.
  47729. */
  47730. protected _reflectionTexture: Nullable<BaseTexture>;
  47731. /**
  47732. * Stores the emissive values in a texture.
  47733. */
  47734. protected _emissiveTexture: Nullable<BaseTexture>;
  47735. /**
  47736. * AKA Specular texture in other nomenclature.
  47737. */
  47738. protected _reflectivityTexture: Nullable<BaseTexture>;
  47739. /**
  47740. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47741. */
  47742. protected _metallicTexture: Nullable<BaseTexture>;
  47743. /**
  47744. * Specifies the metallic scalar of the metallic/roughness workflow.
  47745. * Can also be used to scale the metalness values of the metallic texture.
  47746. */
  47747. protected _metallic: Nullable<number>;
  47748. /**
  47749. * Specifies the roughness scalar of the metallic/roughness workflow.
  47750. * Can also be used to scale the roughness values of the metallic texture.
  47751. */
  47752. protected _roughness: Nullable<number>;
  47753. /**
  47754. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47755. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47756. */
  47757. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47758. /**
  47759. * Stores surface normal data used to displace a mesh in a texture.
  47760. */
  47761. protected _bumpTexture: Nullable<BaseTexture>;
  47762. /**
  47763. * Stores the pre-calculated light information of a mesh in a texture.
  47764. */
  47765. protected _lightmapTexture: Nullable<BaseTexture>;
  47766. /**
  47767. * The color of a material in ambient lighting.
  47768. */
  47769. protected _ambientColor: Color3;
  47770. /**
  47771. * AKA Diffuse Color in other nomenclature.
  47772. */
  47773. protected _albedoColor: Color3;
  47774. /**
  47775. * AKA Specular Color in other nomenclature.
  47776. */
  47777. protected _reflectivityColor: Color3;
  47778. /**
  47779. * The color applied when light is reflected from a material.
  47780. */
  47781. protected _reflectionColor: Color3;
  47782. /**
  47783. * The color applied when light is emitted from a material.
  47784. */
  47785. protected _emissiveColor: Color3;
  47786. /**
  47787. * AKA Glossiness in other nomenclature.
  47788. */
  47789. protected _microSurface: number;
  47790. /**
  47791. * Specifies that the material will use the light map as a show map.
  47792. */
  47793. protected _useLightmapAsShadowmap: boolean;
  47794. /**
  47795. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47796. * makes the reflect vector face the model (under horizon).
  47797. */
  47798. protected _useHorizonOcclusion: boolean;
  47799. /**
  47800. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47801. * too much the area relying on ambient texture to define their ambient occlusion.
  47802. */
  47803. protected _useRadianceOcclusion: boolean;
  47804. /**
  47805. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47806. */
  47807. protected _useAlphaFromAlbedoTexture: boolean;
  47808. /**
  47809. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47810. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47811. */
  47812. protected _useSpecularOverAlpha: boolean;
  47813. /**
  47814. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47815. */
  47816. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47817. /**
  47818. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47819. */
  47820. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47821. /**
  47822. * Specifies if the metallic texture contains the roughness information in its green channel.
  47823. */
  47824. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47825. /**
  47826. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47827. */
  47828. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47829. /**
  47830. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47831. */
  47832. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47833. /**
  47834. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47835. */
  47836. protected _useAmbientInGrayScale: boolean;
  47837. /**
  47838. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47839. * The material will try to infer what glossiness each pixel should be.
  47840. */
  47841. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47842. /**
  47843. * Defines the falloff type used in this material.
  47844. * It by default is Physical.
  47845. */
  47846. protected _lightFalloff: number;
  47847. /**
  47848. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47849. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47850. */
  47851. protected _useRadianceOverAlpha: boolean;
  47852. /**
  47853. * Allows using an object space normal map (instead of tangent space).
  47854. */
  47855. protected _useObjectSpaceNormalMap: boolean;
  47856. /**
  47857. * Allows using the bump map in parallax mode.
  47858. */
  47859. protected _useParallax: boolean;
  47860. /**
  47861. * Allows using the bump map in parallax occlusion mode.
  47862. */
  47863. protected _useParallaxOcclusion: boolean;
  47864. /**
  47865. * Controls the scale bias of the parallax mode.
  47866. */
  47867. protected _parallaxScaleBias: number;
  47868. /**
  47869. * If sets to true, disables all the lights affecting the material.
  47870. */
  47871. protected _disableLighting: boolean;
  47872. /**
  47873. * Number of Simultaneous lights allowed on the material.
  47874. */
  47875. protected _maxSimultaneousLights: number;
  47876. /**
  47877. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47878. */
  47879. protected _invertNormalMapX: boolean;
  47880. /**
  47881. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47882. */
  47883. protected _invertNormalMapY: boolean;
  47884. /**
  47885. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47886. */
  47887. protected _twoSidedLighting: boolean;
  47888. /**
  47889. * Defines the alpha limits in alpha test mode.
  47890. */
  47891. protected _alphaCutOff: number;
  47892. /**
  47893. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47894. */
  47895. protected _forceAlphaTest: boolean;
  47896. /**
  47897. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47898. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47899. */
  47900. protected _useAlphaFresnel: boolean;
  47901. /**
  47902. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47903. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47904. */
  47905. protected _useLinearAlphaFresnel: boolean;
  47906. /**
  47907. * The transparency mode of the material.
  47908. */
  47909. protected _transparencyMode: Nullable<number>;
  47910. /**
  47911. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47912. * from cos thetav and roughness:
  47913. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47914. */
  47915. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47916. /**
  47917. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47918. */
  47919. protected _forceIrradianceInFragment: boolean;
  47920. /**
  47921. * Force normal to face away from face.
  47922. */
  47923. protected _forceNormalForward: boolean;
  47924. /**
  47925. * Enables specular anti aliasing in the PBR shader.
  47926. * It will both interacts on the Geometry for analytical and IBL lighting.
  47927. * It also prefilter the roughness map based on the bump values.
  47928. */
  47929. protected _enableSpecularAntiAliasing: boolean;
  47930. /**
  47931. * Default configuration related to image processing available in the PBR Material.
  47932. */
  47933. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47934. /**
  47935. * Keep track of the image processing observer to allow dispose and replace.
  47936. */
  47937. private _imageProcessingObserver;
  47938. /**
  47939. * Attaches a new image processing configuration to the PBR Material.
  47940. * @param configuration
  47941. */
  47942. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47943. /**
  47944. * Stores the available render targets.
  47945. */
  47946. private _renderTargets;
  47947. /**
  47948. * Sets the global ambient color for the material used in lighting calculations.
  47949. */
  47950. private _globalAmbientColor;
  47951. /**
  47952. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47953. */
  47954. private _useLogarithmicDepth;
  47955. /**
  47956. * If set to true, no lighting calculations will be applied.
  47957. */
  47958. private _unlit;
  47959. private _debugMode;
  47960. /**
  47961. * @hidden
  47962. * This is reserved for the inspector.
  47963. * Defines the material debug mode.
  47964. * It helps seeing only some components of the material while troubleshooting.
  47965. */
  47966. debugMode: number;
  47967. /**
  47968. * @hidden
  47969. * This is reserved for the inspector.
  47970. * Specify from where on screen the debug mode should start.
  47971. * The value goes from -1 (full screen) to 1 (not visible)
  47972. * It helps with side by side comparison against the final render
  47973. * This defaults to -1
  47974. */
  47975. private debugLimit;
  47976. /**
  47977. * @hidden
  47978. * This is reserved for the inspector.
  47979. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47980. * You can use the factor to better multiply the final value.
  47981. */
  47982. private debugFactor;
  47983. /**
  47984. * Defines the clear coat layer parameters for the material.
  47985. */
  47986. readonly clearCoat: PBRClearCoatConfiguration;
  47987. /**
  47988. * Defines the anisotropic parameters for the material.
  47989. */
  47990. readonly anisotropy: PBRAnisotropicConfiguration;
  47991. /**
  47992. * Defines the BRDF parameters for the material.
  47993. */
  47994. readonly brdf: PBRBRDFConfiguration;
  47995. /**
  47996. * Defines the Sheen parameters for the material.
  47997. */
  47998. readonly sheen: PBRSheenConfiguration;
  47999. /**
  48000. * Defines the SubSurface parameters for the material.
  48001. */
  48002. readonly subSurface: PBRSubSurfaceConfiguration;
  48003. /**
  48004. * Custom callback helping to override the default shader used in the material.
  48005. */
  48006. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  48007. /**
  48008. * Instantiates a new PBRMaterial instance.
  48009. *
  48010. * @param name The material name
  48011. * @param scene The scene the material will be use in.
  48012. */
  48013. constructor(name: string, scene: Scene);
  48014. /**
  48015. * Gets a boolean indicating that current material needs to register RTT
  48016. */
  48017. readonly hasRenderTargetTextures: boolean;
  48018. /**
  48019. * Gets the name of the material class.
  48020. */
  48021. getClassName(): string;
  48022. /**
  48023. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48024. */
  48025. /**
  48026. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  48027. */
  48028. useLogarithmicDepth: boolean;
  48029. /**
  48030. * Gets the current transparency mode.
  48031. */
  48032. /**
  48033. * Sets the transparency mode of the material.
  48034. *
  48035. * | Value | Type | Description |
  48036. * | ----- | ----------------------------------- | ----------- |
  48037. * | 0 | OPAQUE | |
  48038. * | 1 | ALPHATEST | |
  48039. * | 2 | ALPHABLEND | |
  48040. * | 3 | ALPHATESTANDBLEND | |
  48041. *
  48042. */
  48043. transparencyMode: Nullable<number>;
  48044. /**
  48045. * Returns true if alpha blending should be disabled.
  48046. */
  48047. private readonly _disableAlphaBlending;
  48048. /**
  48049. * Specifies whether or not this material should be rendered in alpha blend mode.
  48050. */
  48051. needAlphaBlending(): boolean;
  48052. /**
  48053. * Specifies if the mesh will require alpha blending.
  48054. * @param mesh - BJS mesh.
  48055. */
  48056. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  48057. /**
  48058. * Specifies whether or not this material should be rendered in alpha test mode.
  48059. */
  48060. needAlphaTesting(): boolean;
  48061. /**
  48062. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  48063. */
  48064. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  48065. /**
  48066. * Gets the texture used for the alpha test.
  48067. */
  48068. getAlphaTestTexture(): Nullable<BaseTexture>;
  48069. /**
  48070. * Specifies that the submesh is ready to be used.
  48071. * @param mesh - BJS mesh.
  48072. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  48073. * @param useInstances - Specifies that instances should be used.
  48074. * @returns - boolean indicating that the submesh is ready or not.
  48075. */
  48076. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  48077. /**
  48078. * Specifies if the material uses metallic roughness workflow.
  48079. * @returns boolean specifiying if the material uses metallic roughness workflow.
  48080. */
  48081. isMetallicWorkflow(): boolean;
  48082. private _prepareEffect;
  48083. private _prepareDefines;
  48084. /**
  48085. * Force shader compilation
  48086. */
  48087. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  48088. clipPlane: boolean;
  48089. }>): void;
  48090. /**
  48091. * Initializes the uniform buffer layout for the shader.
  48092. */
  48093. buildUniformLayout(): void;
  48094. /**
  48095. * Unbinds the material from the mesh
  48096. */
  48097. unbind(): void;
  48098. /**
  48099. * Binds the submesh data.
  48100. * @param world - The world matrix.
  48101. * @param mesh - The BJS mesh.
  48102. * @param subMesh - A submesh of the BJS mesh.
  48103. */
  48104. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48105. /**
  48106. * Returns the animatable textures.
  48107. * @returns - Array of animatable textures.
  48108. */
  48109. getAnimatables(): IAnimatable[];
  48110. /**
  48111. * Returns the texture used for reflections.
  48112. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  48113. */
  48114. private _getReflectionTexture;
  48115. /**
  48116. * Returns an array of the actively used textures.
  48117. * @returns - Array of BaseTextures
  48118. */
  48119. getActiveTextures(): BaseTexture[];
  48120. /**
  48121. * Checks to see if a texture is used in the material.
  48122. * @param texture - Base texture to use.
  48123. * @returns - Boolean specifying if a texture is used in the material.
  48124. */
  48125. hasTexture(texture: BaseTexture): boolean;
  48126. /**
  48127. * Disposes the resources of the material.
  48128. * @param forceDisposeEffect - Forces the disposal of effects.
  48129. * @param forceDisposeTextures - Forces the disposal of all textures.
  48130. */
  48131. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48132. }
  48133. }
  48134. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  48135. import { Nullable } from "babylonjs/types";
  48136. import { Scene } from "babylonjs/scene";
  48137. import { Color3 } from "babylonjs/Maths/math";
  48138. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  48139. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  48140. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48141. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  48142. /**
  48143. * The Physically based material of BJS.
  48144. *
  48145. * This offers the main features of a standard PBR material.
  48146. * For more information, please refer to the documentation :
  48147. * https://doc.babylonjs.com/how_to/physically_based_rendering
  48148. */
  48149. export class PBRMaterial extends PBRBaseMaterial {
  48150. /**
  48151. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  48152. */
  48153. static readonly PBRMATERIAL_OPAQUE: number;
  48154. /**
  48155. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  48156. */
  48157. static readonly PBRMATERIAL_ALPHATEST: number;
  48158. /**
  48159. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48160. */
  48161. static readonly PBRMATERIAL_ALPHABLEND: number;
  48162. /**
  48163. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  48164. * They are also discarded below the alpha cutoff threshold to improve performances.
  48165. */
  48166. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  48167. /**
  48168. * Defines the default value of how much AO map is occluding the analytical lights
  48169. * (point spot...).
  48170. */
  48171. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  48172. /**
  48173. * Intensity of the direct lights e.g. the four lights available in your scene.
  48174. * This impacts both the direct diffuse and specular highlights.
  48175. */
  48176. directIntensity: number;
  48177. /**
  48178. * Intensity of the emissive part of the material.
  48179. * This helps controlling the emissive effect without modifying the emissive color.
  48180. */
  48181. emissiveIntensity: number;
  48182. /**
  48183. * Intensity of the environment e.g. how much the environment will light the object
  48184. * either through harmonics for rough material or through the refelction for shiny ones.
  48185. */
  48186. environmentIntensity: number;
  48187. /**
  48188. * This is a special control allowing the reduction of the specular highlights coming from the
  48189. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  48190. */
  48191. specularIntensity: number;
  48192. /**
  48193. * Debug Control allowing disabling the bump map on this material.
  48194. */
  48195. disableBumpMap: boolean;
  48196. /**
  48197. * AKA Diffuse Texture in standard nomenclature.
  48198. */
  48199. albedoTexture: BaseTexture;
  48200. /**
  48201. * AKA Occlusion Texture in other nomenclature.
  48202. */
  48203. ambientTexture: BaseTexture;
  48204. /**
  48205. * AKA Occlusion Texture Intensity in other nomenclature.
  48206. */
  48207. ambientTextureStrength: number;
  48208. /**
  48209. * Defines how much the AO map is occluding the analytical lights (point spot...).
  48210. * 1 means it completely occludes it
  48211. * 0 mean it has no impact
  48212. */
  48213. ambientTextureImpactOnAnalyticalLights: number;
  48214. /**
  48215. * Stores the alpha values in a texture.
  48216. */
  48217. opacityTexture: BaseTexture;
  48218. /**
  48219. * Stores the reflection values in a texture.
  48220. */
  48221. reflectionTexture: Nullable<BaseTexture>;
  48222. /**
  48223. * Stores the emissive values in a texture.
  48224. */
  48225. emissiveTexture: BaseTexture;
  48226. /**
  48227. * AKA Specular texture in other nomenclature.
  48228. */
  48229. reflectivityTexture: BaseTexture;
  48230. /**
  48231. * Used to switch from specular/glossiness to metallic/roughness workflow.
  48232. */
  48233. metallicTexture: BaseTexture;
  48234. /**
  48235. * Specifies the metallic scalar of the metallic/roughness workflow.
  48236. * Can also be used to scale the metalness values of the metallic texture.
  48237. */
  48238. metallic: Nullable<number>;
  48239. /**
  48240. * Specifies the roughness scalar of the metallic/roughness workflow.
  48241. * Can also be used to scale the roughness values of the metallic texture.
  48242. */
  48243. roughness: Nullable<number>;
  48244. /**
  48245. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  48246. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  48247. */
  48248. microSurfaceTexture: BaseTexture;
  48249. /**
  48250. * Stores surface normal data used to displace a mesh in a texture.
  48251. */
  48252. bumpTexture: BaseTexture;
  48253. /**
  48254. * Stores the pre-calculated light information of a mesh in a texture.
  48255. */
  48256. lightmapTexture: BaseTexture;
  48257. /**
  48258. * Stores the refracted light information in a texture.
  48259. */
  48260. refractionTexture: Nullable<BaseTexture>;
  48261. /**
  48262. * The color of a material in ambient lighting.
  48263. */
  48264. ambientColor: Color3;
  48265. /**
  48266. * AKA Diffuse Color in other nomenclature.
  48267. */
  48268. albedoColor: Color3;
  48269. /**
  48270. * AKA Specular Color in other nomenclature.
  48271. */
  48272. reflectivityColor: Color3;
  48273. /**
  48274. * The color reflected from the material.
  48275. */
  48276. reflectionColor: Color3;
  48277. /**
  48278. * The color emitted from the material.
  48279. */
  48280. emissiveColor: Color3;
  48281. /**
  48282. * AKA Glossiness in other nomenclature.
  48283. */
  48284. microSurface: number;
  48285. /**
  48286. * source material index of refraction (IOR)' / 'destination material IOR.
  48287. */
  48288. indexOfRefraction: number;
  48289. /**
  48290. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  48291. */
  48292. invertRefractionY: boolean;
  48293. /**
  48294. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  48295. * Materials half opaque for instance using refraction could benefit from this control.
  48296. */
  48297. linkRefractionWithTransparency: boolean;
  48298. /**
  48299. * If true, the light map contains occlusion information instead of lighting info.
  48300. */
  48301. useLightmapAsShadowmap: boolean;
  48302. /**
  48303. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  48304. */
  48305. useAlphaFromAlbedoTexture: boolean;
  48306. /**
  48307. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  48308. */
  48309. forceAlphaTest: boolean;
  48310. /**
  48311. * Defines the alpha limits in alpha test mode.
  48312. */
  48313. alphaCutOff: number;
  48314. /**
  48315. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  48316. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  48317. */
  48318. useSpecularOverAlpha: boolean;
  48319. /**
  48320. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  48321. */
  48322. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  48323. /**
  48324. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  48325. */
  48326. useRoughnessFromMetallicTextureAlpha: boolean;
  48327. /**
  48328. * Specifies if the metallic texture contains the roughness information in its green channel.
  48329. */
  48330. useRoughnessFromMetallicTextureGreen: boolean;
  48331. /**
  48332. * Specifies if the metallic texture contains the metallness information in its blue channel.
  48333. */
  48334. useMetallnessFromMetallicTextureBlue: boolean;
  48335. /**
  48336. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  48337. */
  48338. useAmbientOcclusionFromMetallicTextureRed: boolean;
  48339. /**
  48340. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  48341. */
  48342. useAmbientInGrayScale: boolean;
  48343. /**
  48344. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  48345. * The material will try to infer what glossiness each pixel should be.
  48346. */
  48347. useAutoMicroSurfaceFromReflectivityMap: boolean;
  48348. /**
  48349. * BJS is using an harcoded light falloff based on a manually sets up range.
  48350. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48351. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48352. */
  48353. /**
  48354. * BJS is using an harcoded light falloff based on a manually sets up range.
  48355. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  48356. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  48357. */
  48358. usePhysicalLightFalloff: boolean;
  48359. /**
  48360. * In order to support the falloff compatibility with gltf, a special mode has been added
  48361. * to reproduce the gltf light falloff.
  48362. */
  48363. /**
  48364. * In order to support the falloff compatibility with gltf, a special mode has been added
  48365. * to reproduce the gltf light falloff.
  48366. */
  48367. useGLTFLightFalloff: boolean;
  48368. /**
  48369. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  48370. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  48371. */
  48372. useRadianceOverAlpha: boolean;
  48373. /**
  48374. * Allows using an object space normal map (instead of tangent space).
  48375. */
  48376. useObjectSpaceNormalMap: boolean;
  48377. /**
  48378. * Allows using the bump map in parallax mode.
  48379. */
  48380. useParallax: boolean;
  48381. /**
  48382. * Allows using the bump map in parallax occlusion mode.
  48383. */
  48384. useParallaxOcclusion: boolean;
  48385. /**
  48386. * Controls the scale bias of the parallax mode.
  48387. */
  48388. parallaxScaleBias: number;
  48389. /**
  48390. * If sets to true, disables all the lights affecting the material.
  48391. */
  48392. disableLighting: boolean;
  48393. /**
  48394. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  48395. */
  48396. forceIrradianceInFragment: boolean;
  48397. /**
  48398. * Number of Simultaneous lights allowed on the material.
  48399. */
  48400. maxSimultaneousLights: number;
  48401. /**
  48402. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48403. */
  48404. invertNormalMapX: boolean;
  48405. /**
  48406. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48407. */
  48408. invertNormalMapY: boolean;
  48409. /**
  48410. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48411. */
  48412. twoSidedLighting: boolean;
  48413. /**
  48414. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48415. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  48416. */
  48417. useAlphaFresnel: boolean;
  48418. /**
  48419. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  48420. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  48421. */
  48422. useLinearAlphaFresnel: boolean;
  48423. /**
  48424. * Let user defines the brdf lookup texture used for IBL.
  48425. * A default 8bit version is embedded but you could point at :
  48426. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  48427. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  48428. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  48429. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  48430. */
  48431. environmentBRDFTexture: Nullable<BaseTexture>;
  48432. /**
  48433. * Force normal to face away from face.
  48434. */
  48435. forceNormalForward: boolean;
  48436. /**
  48437. * Enables specular anti aliasing in the PBR shader.
  48438. * It will both interacts on the Geometry for analytical and IBL lighting.
  48439. * It also prefilter the roughness map based on the bump values.
  48440. */
  48441. enableSpecularAntiAliasing: boolean;
  48442. /**
  48443. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  48444. * makes the reflect vector face the model (under horizon).
  48445. */
  48446. useHorizonOcclusion: boolean;
  48447. /**
  48448. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  48449. * too much the area relying on ambient texture to define their ambient occlusion.
  48450. */
  48451. useRadianceOcclusion: boolean;
  48452. /**
  48453. * If set to true, no lighting calculations will be applied.
  48454. */
  48455. unlit: boolean;
  48456. /**
  48457. * Gets the image processing configuration used either in this material.
  48458. */
  48459. /**
  48460. * Sets the Default image processing configuration used either in the this material.
  48461. *
  48462. * If sets to null, the scene one is in use.
  48463. */
  48464. imageProcessingConfiguration: ImageProcessingConfiguration;
  48465. /**
  48466. * Gets wether the color curves effect is enabled.
  48467. */
  48468. /**
  48469. * Sets wether the color curves effect is enabled.
  48470. */
  48471. cameraColorCurvesEnabled: boolean;
  48472. /**
  48473. * Gets wether the color grading effect is enabled.
  48474. */
  48475. /**
  48476. * Gets wether the color grading effect is enabled.
  48477. */
  48478. cameraColorGradingEnabled: boolean;
  48479. /**
  48480. * Gets wether tonemapping is enabled or not.
  48481. */
  48482. /**
  48483. * Sets wether tonemapping is enabled or not
  48484. */
  48485. cameraToneMappingEnabled: boolean;
  48486. /**
  48487. * The camera exposure used on this material.
  48488. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48489. * This corresponds to a photographic exposure.
  48490. */
  48491. /**
  48492. * The camera exposure used on this material.
  48493. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48494. * This corresponds to a photographic exposure.
  48495. */
  48496. cameraExposure: number;
  48497. /**
  48498. * Gets The camera contrast used on this material.
  48499. */
  48500. /**
  48501. * Sets The camera contrast used on this material.
  48502. */
  48503. cameraContrast: number;
  48504. /**
  48505. * Gets the Color Grading 2D Lookup Texture.
  48506. */
  48507. /**
  48508. * Sets the Color Grading 2D Lookup Texture.
  48509. */
  48510. cameraColorGradingTexture: Nullable<BaseTexture>;
  48511. /**
  48512. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48513. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48514. * 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;
  48515. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48516. */
  48517. /**
  48518. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48519. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48520. * 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;
  48521. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48522. */
  48523. cameraColorCurves: Nullable<ColorCurves>;
  48524. /**
  48525. * Instantiates a new PBRMaterial instance.
  48526. *
  48527. * @param name The material name
  48528. * @param scene The scene the material will be use in.
  48529. */
  48530. constructor(name: string, scene: Scene);
  48531. /**
  48532. * Returns the name of this material class.
  48533. */
  48534. getClassName(): string;
  48535. /**
  48536. * Makes a duplicate of the current material.
  48537. * @param name - name to use for the new material.
  48538. */
  48539. clone(name: string): PBRMaterial;
  48540. /**
  48541. * Serializes this PBR Material.
  48542. * @returns - An object with the serialized material.
  48543. */
  48544. serialize(): any;
  48545. /**
  48546. * Parses a PBR Material from a serialized object.
  48547. * @param source - Serialized object.
  48548. * @param scene - BJS scene instance.
  48549. * @param rootUrl - url for the scene object
  48550. * @returns - PBRMaterial
  48551. */
  48552. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  48553. }
  48554. }
  48555. declare module "babylonjs/Misc/dds" {
  48556. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48557. import { Engine } from "babylonjs/Engines/engine";
  48558. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48559. import { Nullable } from "babylonjs/types";
  48560. import { Scene } from "babylonjs/scene";
  48561. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  48562. /**
  48563. * Direct draw surface info
  48564. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48565. */
  48566. export interface DDSInfo {
  48567. /**
  48568. * Width of the texture
  48569. */
  48570. width: number;
  48571. /**
  48572. * Width of the texture
  48573. */
  48574. height: number;
  48575. /**
  48576. * Number of Mipmaps for the texture
  48577. * @see https://en.wikipedia.org/wiki/Mipmap
  48578. */
  48579. mipmapCount: number;
  48580. /**
  48581. * If the textures format is a known fourCC format
  48582. * @see https://www.fourcc.org/
  48583. */
  48584. isFourCC: boolean;
  48585. /**
  48586. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48587. */
  48588. isRGB: boolean;
  48589. /**
  48590. * If the texture is a lumincance format
  48591. */
  48592. isLuminance: boolean;
  48593. /**
  48594. * If this is a cube texture
  48595. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48596. */
  48597. isCube: boolean;
  48598. /**
  48599. * If the texture is a compressed format eg. FOURCC_DXT1
  48600. */
  48601. isCompressed: boolean;
  48602. /**
  48603. * The dxgiFormat of the texture
  48604. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48605. */
  48606. dxgiFormat: number;
  48607. /**
  48608. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48609. */
  48610. textureType: number;
  48611. /**
  48612. * Sphericle polynomial created for the dds texture
  48613. */
  48614. sphericalPolynomial?: SphericalPolynomial;
  48615. }
  48616. /**
  48617. * Class used to provide DDS decompression tools
  48618. */
  48619. export class DDSTools {
  48620. /**
  48621. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48622. */
  48623. static StoreLODInAlphaChannel: boolean;
  48624. /**
  48625. * Gets DDS information from an array buffer
  48626. * @param arrayBuffer defines the array buffer to read data from
  48627. * @returns the DDS information
  48628. */
  48629. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48630. private static _FloatView;
  48631. private static _Int32View;
  48632. private static _ToHalfFloat;
  48633. private static _FromHalfFloat;
  48634. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48635. private static _GetHalfFloatRGBAArrayBuffer;
  48636. private static _GetFloatRGBAArrayBuffer;
  48637. private static _GetFloatAsUIntRGBAArrayBuffer;
  48638. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48639. private static _GetRGBAArrayBuffer;
  48640. private static _ExtractLongWordOrder;
  48641. private static _GetRGBArrayBuffer;
  48642. private static _GetLuminanceArrayBuffer;
  48643. /**
  48644. * Uploads DDS Levels to a Babylon Texture
  48645. * @hidden
  48646. */
  48647. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48648. }
  48649. module "babylonjs/Engines/engine" {
  48650. interface Engine {
  48651. /**
  48652. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48653. * @param rootUrl defines the url where the file to load is located
  48654. * @param scene defines the current scene
  48655. * @param lodScale defines scale to apply to the mip map selection
  48656. * @param lodOffset defines offset to apply to the mip map selection
  48657. * @param onLoad defines an optional callback raised when the texture is loaded
  48658. * @param onError defines an optional callback raised if there is an issue to load the texture
  48659. * @param format defines the format of the data
  48660. * @param forcedExtension defines the extension to use to pick the right loader
  48661. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48662. * @returns the cube texture as an InternalTexture
  48663. */
  48664. 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;
  48665. }
  48666. }
  48667. }
  48668. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  48669. import { Nullable } from "babylonjs/types";
  48670. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48671. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48672. /**
  48673. * Implementation of the DDS Texture Loader.
  48674. * @hidden
  48675. */
  48676. export class _DDSTextureLoader implements IInternalTextureLoader {
  48677. /**
  48678. * Defines wether the loader supports cascade loading the different faces.
  48679. */
  48680. readonly supportCascades: boolean;
  48681. /**
  48682. * This returns if the loader support the current file information.
  48683. * @param extension defines the file extension of the file being loaded
  48684. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48685. * @param fallback defines the fallback internal texture if any
  48686. * @param isBase64 defines whether the texture is encoded as a base64
  48687. * @param isBuffer defines whether the texture data are stored as a buffer
  48688. * @returns true if the loader can load the specified file
  48689. */
  48690. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48691. /**
  48692. * Transform the url before loading if required.
  48693. * @param rootUrl the url of the texture
  48694. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48695. * @returns the transformed texture
  48696. */
  48697. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48698. /**
  48699. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48700. * @param rootUrl the url of the texture
  48701. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48702. * @returns the fallback texture
  48703. */
  48704. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48705. /**
  48706. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48707. * @param data contains the texture data
  48708. * @param texture defines the BabylonJS internal texture
  48709. * @param createPolynomials will be true if polynomials have been requested
  48710. * @param onLoad defines the callback to trigger once the texture is ready
  48711. * @param onError defines the callback to trigger in case of error
  48712. */
  48713. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48714. /**
  48715. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48716. * @param data contains the texture data
  48717. * @param texture defines the BabylonJS internal texture
  48718. * @param callback defines the method to call once ready to upload
  48719. */
  48720. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48721. }
  48722. }
  48723. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48724. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48725. /** @hidden */
  48726. export var rgbdEncodePixelShader: {
  48727. name: string;
  48728. shader: string;
  48729. };
  48730. }
  48731. declare module "babylonjs/Misc/environmentTextureTools" {
  48732. import { Nullable } from "babylonjs/types";
  48733. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48734. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48735. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48736. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48737. import "babylonjs/Shaders/rgbdEncode.fragment";
  48738. import "babylonjs/Shaders/rgbdDecode.fragment";
  48739. /**
  48740. * Raw texture data and descriptor sufficient for WebGL texture upload
  48741. */
  48742. export interface EnvironmentTextureInfo {
  48743. /**
  48744. * Version of the environment map
  48745. */
  48746. version: number;
  48747. /**
  48748. * Width of image
  48749. */
  48750. width: number;
  48751. /**
  48752. * Irradiance information stored in the file.
  48753. */
  48754. irradiance: any;
  48755. /**
  48756. * Specular information stored in the file.
  48757. */
  48758. specular: any;
  48759. }
  48760. /**
  48761. * Sets of helpers addressing the serialization and deserialization of environment texture
  48762. * stored in a BabylonJS env file.
  48763. * Those files are usually stored as .env files.
  48764. */
  48765. export class EnvironmentTextureTools {
  48766. /**
  48767. * Magic number identifying the env file.
  48768. */
  48769. private static _MagicBytes;
  48770. /**
  48771. * Gets the environment info from an env file.
  48772. * @param data The array buffer containing the .env bytes.
  48773. * @returns the environment file info (the json header) if successfully parsed.
  48774. */
  48775. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48776. /**
  48777. * Creates an environment texture from a loaded cube texture.
  48778. * @param texture defines the cube texture to convert in env file
  48779. * @return a promise containing the environment data if succesfull.
  48780. */
  48781. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48782. /**
  48783. * Creates a JSON representation of the spherical data.
  48784. * @param texture defines the texture containing the polynomials
  48785. * @return the JSON representation of the spherical info
  48786. */
  48787. private static _CreateEnvTextureIrradiance;
  48788. /**
  48789. * Uploads the texture info contained in the env file to the GPU.
  48790. * @param texture defines the internal texture to upload to
  48791. * @param arrayBuffer defines the buffer cotaining the data to load
  48792. * @param info defines the texture info retrieved through the GetEnvInfo method
  48793. * @returns a promise
  48794. */
  48795. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48796. /**
  48797. * Uploads the levels of image data to the GPU.
  48798. * @param texture defines the internal texture to upload to
  48799. * @param imageData defines the array buffer views of image data [mipmap][face]
  48800. * @returns a promise
  48801. */
  48802. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48803. /**
  48804. * Uploads spherical polynomials information to the texture.
  48805. * @param texture defines the texture we are trying to upload the information to
  48806. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48807. */
  48808. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48809. /** @hidden */
  48810. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48811. }
  48812. }
  48813. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48814. import { Nullable } from "babylonjs/types";
  48815. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48816. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48817. /**
  48818. * Implementation of the ENV Texture Loader.
  48819. * @hidden
  48820. */
  48821. export class _ENVTextureLoader implements IInternalTextureLoader {
  48822. /**
  48823. * Defines wether the loader supports cascade loading the different faces.
  48824. */
  48825. readonly supportCascades: boolean;
  48826. /**
  48827. * This returns if the loader support the current file information.
  48828. * @param extension defines the file extension of the file being loaded
  48829. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48830. * @param fallback defines the fallback internal texture if any
  48831. * @param isBase64 defines whether the texture is encoded as a base64
  48832. * @param isBuffer defines whether the texture data are stored as a buffer
  48833. * @returns true if the loader can load the specified file
  48834. */
  48835. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48836. /**
  48837. * Transform the url before loading if required.
  48838. * @param rootUrl the url of the texture
  48839. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48840. * @returns the transformed texture
  48841. */
  48842. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48843. /**
  48844. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48845. * @param rootUrl the url of the texture
  48846. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48847. * @returns the fallback texture
  48848. */
  48849. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48850. /**
  48851. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48852. * @param data contains the texture data
  48853. * @param texture defines the BabylonJS internal texture
  48854. * @param createPolynomials will be true if polynomials have been requested
  48855. * @param onLoad defines the callback to trigger once the texture is ready
  48856. * @param onError defines the callback to trigger in case of error
  48857. */
  48858. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48859. /**
  48860. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48861. * @param data contains the texture data
  48862. * @param texture defines the BabylonJS internal texture
  48863. * @param callback defines the method to call once ready to upload
  48864. */
  48865. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48866. }
  48867. }
  48868. declare module "babylonjs/Misc/khronosTextureContainer" {
  48869. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48870. /**
  48871. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48872. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48873. */
  48874. export class KhronosTextureContainer {
  48875. /** contents of the KTX container file */
  48876. arrayBuffer: any;
  48877. private static HEADER_LEN;
  48878. private static COMPRESSED_2D;
  48879. private static COMPRESSED_3D;
  48880. private static TEX_2D;
  48881. private static TEX_3D;
  48882. /**
  48883. * Gets the openGL type
  48884. */
  48885. glType: number;
  48886. /**
  48887. * Gets the openGL type size
  48888. */
  48889. glTypeSize: number;
  48890. /**
  48891. * Gets the openGL format
  48892. */
  48893. glFormat: number;
  48894. /**
  48895. * Gets the openGL internal format
  48896. */
  48897. glInternalFormat: number;
  48898. /**
  48899. * Gets the base internal format
  48900. */
  48901. glBaseInternalFormat: number;
  48902. /**
  48903. * Gets image width in pixel
  48904. */
  48905. pixelWidth: number;
  48906. /**
  48907. * Gets image height in pixel
  48908. */
  48909. pixelHeight: number;
  48910. /**
  48911. * Gets image depth in pixels
  48912. */
  48913. pixelDepth: number;
  48914. /**
  48915. * Gets the number of array elements
  48916. */
  48917. numberOfArrayElements: number;
  48918. /**
  48919. * Gets the number of faces
  48920. */
  48921. numberOfFaces: number;
  48922. /**
  48923. * Gets the number of mipmap levels
  48924. */
  48925. numberOfMipmapLevels: number;
  48926. /**
  48927. * Gets the bytes of key value data
  48928. */
  48929. bytesOfKeyValueData: number;
  48930. /**
  48931. * Gets the load type
  48932. */
  48933. loadType: number;
  48934. /**
  48935. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48936. */
  48937. isInvalid: boolean;
  48938. /**
  48939. * Creates a new KhronosTextureContainer
  48940. * @param arrayBuffer contents of the KTX container file
  48941. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48942. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48943. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48944. */
  48945. constructor(
  48946. /** contents of the KTX container file */
  48947. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48948. /**
  48949. * Uploads KTX content to a Babylon Texture.
  48950. * It is assumed that the texture has already been created & is currently bound
  48951. * @hidden
  48952. */
  48953. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48954. private _upload2DCompressedLevels;
  48955. }
  48956. }
  48957. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48958. import { Nullable } from "babylonjs/types";
  48959. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48960. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48961. /**
  48962. * Implementation of the KTX Texture Loader.
  48963. * @hidden
  48964. */
  48965. export class _KTXTextureLoader implements IInternalTextureLoader {
  48966. /**
  48967. * Defines wether the loader supports cascade loading the different faces.
  48968. */
  48969. readonly supportCascades: boolean;
  48970. /**
  48971. * This returns if the loader support the current file information.
  48972. * @param extension defines the file extension of the file being loaded
  48973. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48974. * @param fallback defines the fallback internal texture if any
  48975. * @param isBase64 defines whether the texture is encoded as a base64
  48976. * @param isBuffer defines whether the texture data are stored as a buffer
  48977. * @returns true if the loader can load the specified file
  48978. */
  48979. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48980. /**
  48981. * Transform the url before loading if required.
  48982. * @param rootUrl the url of the texture
  48983. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48984. * @returns the transformed texture
  48985. */
  48986. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48987. /**
  48988. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48989. * @param rootUrl the url of the texture
  48990. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48991. * @returns the fallback texture
  48992. */
  48993. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48994. /**
  48995. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48996. * @param data contains the texture data
  48997. * @param texture defines the BabylonJS internal texture
  48998. * @param createPolynomials will be true if polynomials have been requested
  48999. * @param onLoad defines the callback to trigger once the texture is ready
  49000. * @param onError defines the callback to trigger in case of error
  49001. */
  49002. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  49003. /**
  49004. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  49005. * @param data contains the texture data
  49006. * @param texture defines the BabylonJS internal texture
  49007. * @param callback defines the method to call once ready to upload
  49008. */
  49009. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  49010. }
  49011. }
  49012. declare module "babylonjs/Helpers/sceneHelpers" {
  49013. import { Nullable } from "babylonjs/types";
  49014. import { Mesh } from "babylonjs/Meshes/mesh";
  49015. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49016. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  49017. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  49018. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  49019. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  49020. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  49021. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  49022. import "babylonjs/Meshes/Builders/boxBuilder";
  49023. /** @hidden */
  49024. export var _forceSceneHelpersToBundle: boolean;
  49025. module "babylonjs/scene" {
  49026. interface Scene {
  49027. /**
  49028. * Creates a default light for the scene.
  49029. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  49030. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  49031. */
  49032. createDefaultLight(replace?: boolean): void;
  49033. /**
  49034. * Creates a default camera for the scene.
  49035. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  49036. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49037. * @param replace has default false, when true replaces the active camera in the scene
  49038. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  49039. */
  49040. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49041. /**
  49042. * Creates a default camera and a default light.
  49043. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  49044. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  49045. * @param replace has the default false, when true replaces the active camera/light in the scene
  49046. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  49047. */
  49048. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  49049. /**
  49050. * Creates a new sky box
  49051. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  49052. * @param environmentTexture defines the texture to use as environment texture
  49053. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  49054. * @param scale defines the overall scale of the skybox
  49055. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  49056. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  49057. * @returns a new mesh holding the sky box
  49058. */
  49059. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  49060. /**
  49061. * Creates a new environment
  49062. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  49063. * @param options defines the options you can use to configure the environment
  49064. * @returns the new EnvironmentHelper
  49065. */
  49066. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  49067. /**
  49068. * Creates a new VREXperienceHelper
  49069. * @see http://doc.babylonjs.com/how_to/webvr_helper
  49070. * @param webVROptions defines the options used to create the new VREXperienceHelper
  49071. * @returns a new VREXperienceHelper
  49072. */
  49073. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  49074. /**
  49075. * Creates a new XREXperienceHelper
  49076. * @see http://doc.babylonjs.com/how_to/webxr
  49077. * @returns a promise for a new XREXperienceHelper
  49078. */
  49079. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  49080. }
  49081. }
  49082. }
  49083. declare module "babylonjs/Helpers/videoDome" {
  49084. import { Scene } from "babylonjs/scene";
  49085. import { TransformNode } from "babylonjs/Meshes/transformNode";
  49086. import { Mesh } from "babylonjs/Meshes/mesh";
  49087. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  49088. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  49089. import "babylonjs/Meshes/Builders/sphereBuilder";
  49090. /**
  49091. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  49092. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  49093. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  49094. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49095. */
  49096. export class VideoDome extends TransformNode {
  49097. /**
  49098. * Define the video source as a Monoscopic panoramic 360 video.
  49099. */
  49100. static readonly MODE_MONOSCOPIC: number;
  49101. /**
  49102. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49103. */
  49104. static readonly MODE_TOPBOTTOM: number;
  49105. /**
  49106. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49107. */
  49108. static readonly MODE_SIDEBYSIDE: number;
  49109. private _useDirectMapping;
  49110. /**
  49111. * The video texture being displayed on the sphere
  49112. */
  49113. protected _videoTexture: VideoTexture;
  49114. /**
  49115. * Gets the video texture being displayed on the sphere
  49116. */
  49117. readonly videoTexture: VideoTexture;
  49118. /**
  49119. * The skybox material
  49120. */
  49121. protected _material: BackgroundMaterial;
  49122. /**
  49123. * The surface used for the skybox
  49124. */
  49125. protected _mesh: Mesh;
  49126. /**
  49127. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49128. * Also see the options.resolution property.
  49129. */
  49130. fovMultiplier: number;
  49131. private _videoMode;
  49132. /**
  49133. * Gets or set the current video mode for the video. It can be:
  49134. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  49135. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  49136. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  49137. */
  49138. videoMode: number;
  49139. /**
  49140. * Oberserver used in Stereoscopic VR Mode.
  49141. */
  49142. private _onBeforeCameraRenderObserver;
  49143. /**
  49144. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  49145. * @param name Element's name, child elements will append suffixes for their own names.
  49146. * @param urlsOrVideo defines the url(s) or the video element to use
  49147. * @param options An object containing optional or exposed sub element properties
  49148. */
  49149. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  49150. resolution?: number;
  49151. clickToPlay?: boolean;
  49152. autoPlay?: boolean;
  49153. loop?: boolean;
  49154. size?: number;
  49155. poster?: string;
  49156. faceForward?: boolean;
  49157. useDirectMapping?: boolean;
  49158. }, scene: Scene);
  49159. private _changeVideoMode;
  49160. /**
  49161. * Releases resources associated with this node.
  49162. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49163. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49164. */
  49165. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49166. }
  49167. }
  49168. declare module "babylonjs/Helpers/index" {
  49169. export * from "babylonjs/Helpers/environmentHelper";
  49170. export * from "babylonjs/Helpers/photoDome";
  49171. export * from "babylonjs/Helpers/sceneHelpers";
  49172. export * from "babylonjs/Helpers/videoDome";
  49173. }
  49174. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  49175. import { PerfCounter } from "babylonjs/Misc/tools";
  49176. import { IDisposable } from "babylonjs/scene";
  49177. import { Engine } from "babylonjs/Engines/engine";
  49178. /**
  49179. * This class can be used to get instrumentation data from a Babylon engine
  49180. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49181. */
  49182. export class EngineInstrumentation implements IDisposable {
  49183. /**
  49184. * Define the instrumented engine.
  49185. */
  49186. engine: Engine;
  49187. private _captureGPUFrameTime;
  49188. private _gpuFrameTimeToken;
  49189. private _gpuFrameTime;
  49190. private _captureShaderCompilationTime;
  49191. private _shaderCompilationTime;
  49192. private _onBeginFrameObserver;
  49193. private _onEndFrameObserver;
  49194. private _onBeforeShaderCompilationObserver;
  49195. private _onAfterShaderCompilationObserver;
  49196. /**
  49197. * Gets the perf counter used for GPU frame time
  49198. */
  49199. readonly gpuFrameTimeCounter: PerfCounter;
  49200. /**
  49201. * Gets the GPU frame time capture status
  49202. */
  49203. /**
  49204. * Enable or disable the GPU frame time capture
  49205. */
  49206. captureGPUFrameTime: boolean;
  49207. /**
  49208. * Gets the perf counter used for shader compilation time
  49209. */
  49210. readonly shaderCompilationTimeCounter: PerfCounter;
  49211. /**
  49212. * Gets the shader compilation time capture status
  49213. */
  49214. /**
  49215. * Enable or disable the shader compilation time capture
  49216. */
  49217. captureShaderCompilationTime: boolean;
  49218. /**
  49219. * Instantiates a new engine instrumentation.
  49220. * This class can be used to get instrumentation data from a Babylon engine
  49221. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  49222. * @param engine Defines the engine to instrument
  49223. */
  49224. constructor(
  49225. /**
  49226. * Define the instrumented engine.
  49227. */
  49228. engine: Engine);
  49229. /**
  49230. * Dispose and release associated resources.
  49231. */
  49232. dispose(): void;
  49233. }
  49234. }
  49235. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  49236. import { PerfCounter } from "babylonjs/Misc/tools";
  49237. import { Scene, IDisposable } from "babylonjs/scene";
  49238. /**
  49239. * This class can be used to get instrumentation data from a Babylon engine
  49240. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49241. */
  49242. export class SceneInstrumentation implements IDisposable {
  49243. /**
  49244. * Defines the scene to instrument
  49245. */
  49246. scene: Scene;
  49247. private _captureActiveMeshesEvaluationTime;
  49248. private _activeMeshesEvaluationTime;
  49249. private _captureRenderTargetsRenderTime;
  49250. private _renderTargetsRenderTime;
  49251. private _captureFrameTime;
  49252. private _frameTime;
  49253. private _captureRenderTime;
  49254. private _renderTime;
  49255. private _captureInterFrameTime;
  49256. private _interFrameTime;
  49257. private _captureParticlesRenderTime;
  49258. private _particlesRenderTime;
  49259. private _captureSpritesRenderTime;
  49260. private _spritesRenderTime;
  49261. private _capturePhysicsTime;
  49262. private _physicsTime;
  49263. private _captureAnimationsTime;
  49264. private _animationsTime;
  49265. private _captureCameraRenderTime;
  49266. private _cameraRenderTime;
  49267. private _onBeforeActiveMeshesEvaluationObserver;
  49268. private _onAfterActiveMeshesEvaluationObserver;
  49269. private _onBeforeRenderTargetsRenderObserver;
  49270. private _onAfterRenderTargetsRenderObserver;
  49271. private _onAfterRenderObserver;
  49272. private _onBeforeDrawPhaseObserver;
  49273. private _onAfterDrawPhaseObserver;
  49274. private _onBeforeAnimationsObserver;
  49275. private _onBeforeParticlesRenderingObserver;
  49276. private _onAfterParticlesRenderingObserver;
  49277. private _onBeforeSpritesRenderingObserver;
  49278. private _onAfterSpritesRenderingObserver;
  49279. private _onBeforePhysicsObserver;
  49280. private _onAfterPhysicsObserver;
  49281. private _onAfterAnimationsObserver;
  49282. private _onBeforeCameraRenderObserver;
  49283. private _onAfterCameraRenderObserver;
  49284. /**
  49285. * Gets the perf counter used for active meshes evaluation time
  49286. */
  49287. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  49288. /**
  49289. * Gets the active meshes evaluation time capture status
  49290. */
  49291. /**
  49292. * Enable or disable the active meshes evaluation time capture
  49293. */
  49294. captureActiveMeshesEvaluationTime: boolean;
  49295. /**
  49296. * Gets the perf counter used for render targets render time
  49297. */
  49298. readonly renderTargetsRenderTimeCounter: PerfCounter;
  49299. /**
  49300. * Gets the render targets render time capture status
  49301. */
  49302. /**
  49303. * Enable or disable the render targets render time capture
  49304. */
  49305. captureRenderTargetsRenderTime: boolean;
  49306. /**
  49307. * Gets the perf counter used for particles render time
  49308. */
  49309. readonly particlesRenderTimeCounter: PerfCounter;
  49310. /**
  49311. * Gets the particles render time capture status
  49312. */
  49313. /**
  49314. * Enable or disable the particles render time capture
  49315. */
  49316. captureParticlesRenderTime: boolean;
  49317. /**
  49318. * Gets the perf counter used for sprites render time
  49319. */
  49320. readonly spritesRenderTimeCounter: PerfCounter;
  49321. /**
  49322. * Gets the sprites render time capture status
  49323. */
  49324. /**
  49325. * Enable or disable the sprites render time capture
  49326. */
  49327. captureSpritesRenderTime: boolean;
  49328. /**
  49329. * Gets the perf counter used for physics time
  49330. */
  49331. readonly physicsTimeCounter: PerfCounter;
  49332. /**
  49333. * Gets the physics time capture status
  49334. */
  49335. /**
  49336. * Enable or disable the physics time capture
  49337. */
  49338. capturePhysicsTime: boolean;
  49339. /**
  49340. * Gets the perf counter used for animations time
  49341. */
  49342. readonly animationsTimeCounter: PerfCounter;
  49343. /**
  49344. * Gets the animations time capture status
  49345. */
  49346. /**
  49347. * Enable or disable the animations time capture
  49348. */
  49349. captureAnimationsTime: boolean;
  49350. /**
  49351. * Gets the perf counter used for frame time capture
  49352. */
  49353. readonly frameTimeCounter: PerfCounter;
  49354. /**
  49355. * Gets the frame time capture status
  49356. */
  49357. /**
  49358. * Enable or disable the frame time capture
  49359. */
  49360. captureFrameTime: boolean;
  49361. /**
  49362. * Gets the perf counter used for inter-frames time capture
  49363. */
  49364. readonly interFrameTimeCounter: PerfCounter;
  49365. /**
  49366. * Gets the inter-frames time capture status
  49367. */
  49368. /**
  49369. * Enable or disable the inter-frames time capture
  49370. */
  49371. captureInterFrameTime: boolean;
  49372. /**
  49373. * Gets the perf counter used for render time capture
  49374. */
  49375. readonly renderTimeCounter: PerfCounter;
  49376. /**
  49377. * Gets the render time capture status
  49378. */
  49379. /**
  49380. * Enable or disable the render time capture
  49381. */
  49382. captureRenderTime: boolean;
  49383. /**
  49384. * Gets the perf counter used for camera render time capture
  49385. */
  49386. readonly cameraRenderTimeCounter: PerfCounter;
  49387. /**
  49388. * Gets the camera render time capture status
  49389. */
  49390. /**
  49391. * Enable or disable the camera render time capture
  49392. */
  49393. captureCameraRenderTime: boolean;
  49394. /**
  49395. * Gets the perf counter used for draw calls
  49396. */
  49397. readonly drawCallsCounter: PerfCounter;
  49398. /**
  49399. * Instantiates a new scene instrumentation.
  49400. * This class can be used to get instrumentation data from a Babylon engine
  49401. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  49402. * @param scene Defines the scene to instrument
  49403. */
  49404. constructor(
  49405. /**
  49406. * Defines the scene to instrument
  49407. */
  49408. scene: Scene);
  49409. /**
  49410. * Dispose and release associated resources.
  49411. */
  49412. dispose(): void;
  49413. }
  49414. }
  49415. declare module "babylonjs/Instrumentation/index" {
  49416. export * from "babylonjs/Instrumentation/engineInstrumentation";
  49417. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  49418. export * from "babylonjs/Instrumentation/timeToken";
  49419. }
  49420. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  49421. /** @hidden */
  49422. export var glowMapGenerationPixelShader: {
  49423. name: string;
  49424. shader: string;
  49425. };
  49426. }
  49427. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  49428. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49429. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49430. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49431. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49432. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49433. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49434. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49435. /** @hidden */
  49436. export var glowMapGenerationVertexShader: {
  49437. name: string;
  49438. shader: string;
  49439. };
  49440. }
  49441. declare module "babylonjs/Layers/effectLayer" {
  49442. import { Observable } from "babylonjs/Misc/observable";
  49443. import { Nullable } from "babylonjs/types";
  49444. import { Camera } from "babylonjs/Cameras/camera";
  49445. import { Scene } from "babylonjs/scene";
  49446. import { Color4, ISize } from "babylonjs/Maths/math";
  49447. import { Engine } from "babylonjs/Engines/engine";
  49448. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49449. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49450. import { Mesh } from "babylonjs/Meshes/mesh";
  49451. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  49452. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49453. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49454. import { Effect } from "babylonjs/Materials/effect";
  49455. import { Material } from "babylonjs/Materials/material";
  49456. import "babylonjs/Shaders/glowMapGeneration.fragment";
  49457. import "babylonjs/Shaders/glowMapGeneration.vertex";
  49458. /**
  49459. * Effect layer options. This helps customizing the behaviour
  49460. * of the effect layer.
  49461. */
  49462. export interface IEffectLayerOptions {
  49463. /**
  49464. * Multiplication factor apply to the canvas size to compute the render target size
  49465. * used to generated the objects (the smaller the faster).
  49466. */
  49467. mainTextureRatio: number;
  49468. /**
  49469. * Enforces a fixed size texture to ensure effect stability across devices.
  49470. */
  49471. mainTextureFixedSize?: number;
  49472. /**
  49473. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  49474. */
  49475. alphaBlendingMode: number;
  49476. /**
  49477. * The camera attached to the layer.
  49478. */
  49479. camera: Nullable<Camera>;
  49480. /**
  49481. * The rendering group to draw the layer in.
  49482. */
  49483. renderingGroupId: number;
  49484. }
  49485. /**
  49486. * The effect layer Helps adding post process effect blended with the main pass.
  49487. *
  49488. * This can be for instance use to generate glow or higlight effects on the scene.
  49489. *
  49490. * The effect layer class can not be used directly and is intented to inherited from to be
  49491. * customized per effects.
  49492. */
  49493. export abstract class EffectLayer {
  49494. private _vertexBuffers;
  49495. private _indexBuffer;
  49496. private _cachedDefines;
  49497. private _effectLayerMapGenerationEffect;
  49498. private _effectLayerOptions;
  49499. private _mergeEffect;
  49500. protected _scene: Scene;
  49501. protected _engine: Engine;
  49502. protected _maxSize: number;
  49503. protected _mainTextureDesiredSize: ISize;
  49504. protected _mainTexture: RenderTargetTexture;
  49505. protected _shouldRender: boolean;
  49506. protected _postProcesses: PostProcess[];
  49507. protected _textures: BaseTexture[];
  49508. protected _emissiveTextureAndColor: {
  49509. texture: Nullable<BaseTexture>;
  49510. color: Color4;
  49511. };
  49512. /**
  49513. * The name of the layer
  49514. */
  49515. name: string;
  49516. /**
  49517. * The clear color of the texture used to generate the glow map.
  49518. */
  49519. neutralColor: Color4;
  49520. /**
  49521. * Specifies wether the highlight layer is enabled or not.
  49522. */
  49523. isEnabled: boolean;
  49524. /**
  49525. * Gets the camera attached to the layer.
  49526. */
  49527. readonly camera: Nullable<Camera>;
  49528. /**
  49529. * Gets the rendering group id the layer should render in.
  49530. */
  49531. renderingGroupId: number;
  49532. /**
  49533. * An event triggered when the effect layer has been disposed.
  49534. */
  49535. onDisposeObservable: Observable<EffectLayer>;
  49536. /**
  49537. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  49538. */
  49539. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  49540. /**
  49541. * An event triggered when the generated texture is being merged in the scene.
  49542. */
  49543. onBeforeComposeObservable: Observable<EffectLayer>;
  49544. /**
  49545. * An event triggered when the generated texture has been merged in the scene.
  49546. */
  49547. onAfterComposeObservable: Observable<EffectLayer>;
  49548. /**
  49549. * An event triggered when the efffect layer changes its size.
  49550. */
  49551. onSizeChangedObservable: Observable<EffectLayer>;
  49552. /** @hidden */
  49553. static _SceneComponentInitialization: (scene: Scene) => void;
  49554. /**
  49555. * Instantiates a new effect Layer and references it in the scene.
  49556. * @param name The name of the layer
  49557. * @param scene The scene to use the layer in
  49558. */
  49559. constructor(
  49560. /** The Friendly of the effect in the scene */
  49561. name: string, scene: Scene);
  49562. /**
  49563. * Get the effect name of the layer.
  49564. * @return The effect name
  49565. */
  49566. abstract getEffectName(): string;
  49567. /**
  49568. * Checks for the readiness of the element composing the layer.
  49569. * @param subMesh the mesh to check for
  49570. * @param useInstances specify wether or not to use instances to render the mesh
  49571. * @return true if ready otherwise, false
  49572. */
  49573. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49574. /**
  49575. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49576. * @returns true if the effect requires stencil during the main canvas render pass.
  49577. */
  49578. abstract needStencil(): boolean;
  49579. /**
  49580. * Create the merge effect. This is the shader use to blit the information back
  49581. * to the main canvas at the end of the scene rendering.
  49582. * @returns The effect containing the shader used to merge the effect on the main canvas
  49583. */
  49584. protected abstract _createMergeEffect(): Effect;
  49585. /**
  49586. * Creates the render target textures and post processes used in the effect layer.
  49587. */
  49588. protected abstract _createTextureAndPostProcesses(): void;
  49589. /**
  49590. * Implementation specific of rendering the generating effect on the main canvas.
  49591. * @param effect The effect used to render through
  49592. */
  49593. protected abstract _internalRender(effect: Effect): void;
  49594. /**
  49595. * Sets the required values for both the emissive texture and and the main color.
  49596. */
  49597. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49598. /**
  49599. * Free any resources and references associated to a mesh.
  49600. * Internal use
  49601. * @param mesh The mesh to free.
  49602. */
  49603. abstract _disposeMesh(mesh: Mesh): void;
  49604. /**
  49605. * Serializes this layer (Glow or Highlight for example)
  49606. * @returns a serialized layer object
  49607. */
  49608. abstract serialize?(): any;
  49609. /**
  49610. * Initializes the effect layer with the required options.
  49611. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  49612. */
  49613. protected _init(options: Partial<IEffectLayerOptions>): void;
  49614. /**
  49615. * Generates the index buffer of the full screen quad blending to the main canvas.
  49616. */
  49617. private _generateIndexBuffer;
  49618. /**
  49619. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  49620. */
  49621. private _generateVertexBuffer;
  49622. /**
  49623. * Sets the main texture desired size which is the closest power of two
  49624. * of the engine canvas size.
  49625. */
  49626. private _setMainTextureSize;
  49627. /**
  49628. * Creates the main texture for the effect layer.
  49629. */
  49630. protected _createMainTexture(): void;
  49631. /**
  49632. * Adds specific effects defines.
  49633. * @param defines The defines to add specifics to.
  49634. */
  49635. protected _addCustomEffectDefines(defines: string[]): void;
  49636. /**
  49637. * Checks for the readiness of the element composing the layer.
  49638. * @param subMesh the mesh to check for
  49639. * @param useInstances specify wether or not to use instances to render the mesh
  49640. * @param emissiveTexture the associated emissive texture used to generate the glow
  49641. * @return true if ready otherwise, false
  49642. */
  49643. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  49644. /**
  49645. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  49646. */
  49647. render(): void;
  49648. /**
  49649. * Determine if a given mesh will be used in the current effect.
  49650. * @param mesh mesh to test
  49651. * @returns true if the mesh will be used
  49652. */
  49653. hasMesh(mesh: AbstractMesh): boolean;
  49654. /**
  49655. * Returns true if the layer contains information to display, otherwise false.
  49656. * @returns true if the glow layer should be rendered
  49657. */
  49658. shouldRender(): boolean;
  49659. /**
  49660. * Returns true if the mesh should render, otherwise false.
  49661. * @param mesh The mesh to render
  49662. * @returns true if it should render otherwise false
  49663. */
  49664. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  49665. /**
  49666. * Returns true if the mesh can be rendered, otherwise false.
  49667. * @param mesh The mesh to render
  49668. * @param material The material used on the mesh
  49669. * @returns true if it can be rendered otherwise false
  49670. */
  49671. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49672. /**
  49673. * Returns true if the mesh should render, otherwise false.
  49674. * @param mesh The mesh to render
  49675. * @returns true if it should render otherwise false
  49676. */
  49677. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  49678. /**
  49679. * Renders the submesh passed in parameter to the generation map.
  49680. */
  49681. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  49682. /**
  49683. * Rebuild the required buffers.
  49684. * @hidden Internal use only.
  49685. */
  49686. _rebuild(): void;
  49687. /**
  49688. * Dispose only the render target textures and post process.
  49689. */
  49690. private _disposeTextureAndPostProcesses;
  49691. /**
  49692. * Dispose the highlight layer and free resources.
  49693. */
  49694. dispose(): void;
  49695. /**
  49696. * Gets the class name of the effect layer
  49697. * @returns the string with the class name of the effect layer
  49698. */
  49699. getClassName(): string;
  49700. /**
  49701. * Creates an effect layer from parsed effect layer data
  49702. * @param parsedEffectLayer defines effect layer data
  49703. * @param scene defines the current scene
  49704. * @param rootUrl defines the root URL containing the effect layer information
  49705. * @returns a parsed effect Layer
  49706. */
  49707. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49708. }
  49709. }
  49710. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  49711. import { Scene } from "babylonjs/scene";
  49712. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49713. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49714. import { AbstractScene } from "babylonjs/abstractScene";
  49715. module "babylonjs/abstractScene" {
  49716. interface AbstractScene {
  49717. /**
  49718. * The list of effect layers (highlights/glow) added to the scene
  49719. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49720. * @see http://doc.babylonjs.com/how_to/glow_layer
  49721. */
  49722. effectLayers: Array<EffectLayer>;
  49723. /**
  49724. * Removes the given effect layer from this scene.
  49725. * @param toRemove defines the effect layer to remove
  49726. * @returns the index of the removed effect layer
  49727. */
  49728. removeEffectLayer(toRemove: EffectLayer): number;
  49729. /**
  49730. * Adds the given effect layer to this scene
  49731. * @param newEffectLayer defines the effect layer to add
  49732. */
  49733. addEffectLayer(newEffectLayer: EffectLayer): void;
  49734. }
  49735. }
  49736. /**
  49737. * Defines the layer scene component responsible to manage any effect layers
  49738. * in a given scene.
  49739. */
  49740. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49741. /**
  49742. * The component name helpfull to identify the component in the list of scene components.
  49743. */
  49744. readonly name: string;
  49745. /**
  49746. * The scene the component belongs to.
  49747. */
  49748. scene: Scene;
  49749. private _engine;
  49750. private _renderEffects;
  49751. private _needStencil;
  49752. private _previousStencilState;
  49753. /**
  49754. * Creates a new instance of the component for the given scene
  49755. * @param scene Defines the scene to register the component in
  49756. */
  49757. constructor(scene: Scene);
  49758. /**
  49759. * Registers the component in a given scene
  49760. */
  49761. register(): void;
  49762. /**
  49763. * Rebuilds the elements related to this component in case of
  49764. * context lost for instance.
  49765. */
  49766. rebuild(): void;
  49767. /**
  49768. * Serializes the component data to the specified json object
  49769. * @param serializationObject The object to serialize to
  49770. */
  49771. serialize(serializationObject: any): void;
  49772. /**
  49773. * Adds all the elements from the container to the scene
  49774. * @param container the container holding the elements
  49775. */
  49776. addFromContainer(container: AbstractScene): void;
  49777. /**
  49778. * Removes all the elements in the container from the scene
  49779. * @param container contains the elements to remove
  49780. * @param dispose if the removed element should be disposed (default: false)
  49781. */
  49782. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49783. /**
  49784. * Disposes the component and the associated ressources.
  49785. */
  49786. dispose(): void;
  49787. private _isReadyForMesh;
  49788. private _renderMainTexture;
  49789. private _setStencil;
  49790. private _setStencilBack;
  49791. private _draw;
  49792. private _drawCamera;
  49793. private _drawRenderingGroup;
  49794. }
  49795. }
  49796. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  49797. /** @hidden */
  49798. export var glowMapMergePixelShader: {
  49799. name: string;
  49800. shader: string;
  49801. };
  49802. }
  49803. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  49804. /** @hidden */
  49805. export var glowMapMergeVertexShader: {
  49806. name: string;
  49807. shader: string;
  49808. };
  49809. }
  49810. declare module "babylonjs/Layers/glowLayer" {
  49811. import { Nullable } from "babylonjs/types";
  49812. import { Camera } from "babylonjs/Cameras/camera";
  49813. import { Scene } from "babylonjs/scene";
  49814. import { Color4 } from "babylonjs/Maths/math";
  49815. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49816. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49817. import { Mesh } from "babylonjs/Meshes/mesh";
  49818. import { Texture } from "babylonjs/Materials/Textures/texture";
  49819. import { Effect } from "babylonjs/Materials/effect";
  49820. import { Material } from "babylonjs/Materials/material";
  49821. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49822. import "babylonjs/Shaders/glowMapMerge.fragment";
  49823. import "babylonjs/Shaders/glowMapMerge.vertex";
  49824. import "babylonjs/Layers/effectLayerSceneComponent";
  49825. module "babylonjs/abstractScene" {
  49826. interface AbstractScene {
  49827. /**
  49828. * Return a the first highlight layer of the scene with a given name.
  49829. * @param name The name of the highlight layer to look for.
  49830. * @return The highlight layer if found otherwise null.
  49831. */
  49832. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49833. }
  49834. }
  49835. /**
  49836. * Glow layer options. This helps customizing the behaviour
  49837. * of the glow layer.
  49838. */
  49839. export interface IGlowLayerOptions {
  49840. /**
  49841. * Multiplication factor apply to the canvas size to compute the render target size
  49842. * used to generated the glowing objects (the smaller the faster).
  49843. */
  49844. mainTextureRatio: number;
  49845. /**
  49846. * Enforces a fixed size texture to ensure resize independant blur.
  49847. */
  49848. mainTextureFixedSize?: number;
  49849. /**
  49850. * How big is the kernel of the blur texture.
  49851. */
  49852. blurKernelSize: number;
  49853. /**
  49854. * The camera attached to the layer.
  49855. */
  49856. camera: Nullable<Camera>;
  49857. /**
  49858. * Enable MSAA by chosing the number of samples.
  49859. */
  49860. mainTextureSamples?: number;
  49861. /**
  49862. * The rendering group to draw the layer in.
  49863. */
  49864. renderingGroupId: number;
  49865. }
  49866. /**
  49867. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49868. *
  49869. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49870. * glowy meshes to your scene.
  49871. *
  49872. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49873. */
  49874. export class GlowLayer extends EffectLayer {
  49875. /**
  49876. * Effect Name of the layer.
  49877. */
  49878. static readonly EffectName: string;
  49879. /**
  49880. * The default blur kernel size used for the glow.
  49881. */
  49882. static DefaultBlurKernelSize: number;
  49883. /**
  49884. * The default texture size ratio used for the glow.
  49885. */
  49886. static DefaultTextureRatio: number;
  49887. /**
  49888. * Sets the kernel size of the blur.
  49889. */
  49890. /**
  49891. * Gets the kernel size of the blur.
  49892. */
  49893. blurKernelSize: number;
  49894. /**
  49895. * Sets the glow intensity.
  49896. */
  49897. /**
  49898. * Gets the glow intensity.
  49899. */
  49900. intensity: number;
  49901. private _options;
  49902. private _intensity;
  49903. private _horizontalBlurPostprocess1;
  49904. private _verticalBlurPostprocess1;
  49905. private _horizontalBlurPostprocess2;
  49906. private _verticalBlurPostprocess2;
  49907. private _blurTexture1;
  49908. private _blurTexture2;
  49909. private _postProcesses1;
  49910. private _postProcesses2;
  49911. private _includedOnlyMeshes;
  49912. private _excludedMeshes;
  49913. /**
  49914. * Callback used to let the user override the color selection on a per mesh basis
  49915. */
  49916. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49917. /**
  49918. * Callback used to let the user override the texture selection on a per mesh basis
  49919. */
  49920. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49921. /**
  49922. * Instantiates a new glow Layer and references it to the scene.
  49923. * @param name The name of the layer
  49924. * @param scene The scene to use the layer in
  49925. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49926. */
  49927. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49928. /**
  49929. * Get the effect name of the layer.
  49930. * @return The effect name
  49931. */
  49932. getEffectName(): string;
  49933. /**
  49934. * Create the merge effect. This is the shader use to blit the information back
  49935. * to the main canvas at the end of the scene rendering.
  49936. */
  49937. protected _createMergeEffect(): Effect;
  49938. /**
  49939. * Creates the render target textures and post processes used in the glow layer.
  49940. */
  49941. protected _createTextureAndPostProcesses(): void;
  49942. /**
  49943. * Checks for the readiness of the element composing the layer.
  49944. * @param subMesh the mesh to check for
  49945. * @param useInstances specify wether or not to use instances to render the mesh
  49946. * @param emissiveTexture the associated emissive texture used to generate the glow
  49947. * @return true if ready otherwise, false
  49948. */
  49949. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49950. /**
  49951. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49952. */
  49953. needStencil(): boolean;
  49954. /**
  49955. * Returns true if the mesh can be rendered, otherwise false.
  49956. * @param mesh The mesh to render
  49957. * @param material The material used on the mesh
  49958. * @returns true if it can be rendered otherwise false
  49959. */
  49960. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49961. /**
  49962. * Implementation specific of rendering the generating effect on the main canvas.
  49963. * @param effect The effect used to render through
  49964. */
  49965. protected _internalRender(effect: Effect): void;
  49966. /**
  49967. * Sets the required values for both the emissive texture and and the main color.
  49968. */
  49969. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49970. /**
  49971. * Returns true if the mesh should render, otherwise false.
  49972. * @param mesh The mesh to render
  49973. * @returns true if it should render otherwise false
  49974. */
  49975. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49976. /**
  49977. * Adds specific effects defines.
  49978. * @param defines The defines to add specifics to.
  49979. */
  49980. protected _addCustomEffectDefines(defines: string[]): void;
  49981. /**
  49982. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49983. * @param mesh The mesh to exclude from the glow layer
  49984. */
  49985. addExcludedMesh(mesh: Mesh): void;
  49986. /**
  49987. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49988. * @param mesh The mesh to remove
  49989. */
  49990. removeExcludedMesh(mesh: Mesh): void;
  49991. /**
  49992. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49993. * @param mesh The mesh to include in the glow layer
  49994. */
  49995. addIncludedOnlyMesh(mesh: Mesh): void;
  49996. /**
  49997. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49998. * @param mesh The mesh to remove
  49999. */
  50000. removeIncludedOnlyMesh(mesh: Mesh): void;
  50001. /**
  50002. * Determine if a given mesh will be used in the glow layer
  50003. * @param mesh The mesh to test
  50004. * @returns true if the mesh will be highlighted by the current glow layer
  50005. */
  50006. hasMesh(mesh: AbstractMesh): boolean;
  50007. /**
  50008. * Free any resources and references associated to a mesh.
  50009. * Internal use
  50010. * @param mesh The mesh to free.
  50011. * @hidden
  50012. */
  50013. _disposeMesh(mesh: Mesh): void;
  50014. /**
  50015. * Gets the class name of the effect layer
  50016. * @returns the string with the class name of the effect layer
  50017. */
  50018. getClassName(): string;
  50019. /**
  50020. * Serializes this glow layer
  50021. * @returns a serialized glow layer object
  50022. */
  50023. serialize(): any;
  50024. /**
  50025. * Creates a Glow Layer from parsed glow layer data
  50026. * @param parsedGlowLayer defines glow layer data
  50027. * @param scene defines the current scene
  50028. * @param rootUrl defines the root URL containing the glow layer information
  50029. * @returns a parsed Glow Layer
  50030. */
  50031. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  50032. }
  50033. }
  50034. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  50035. /** @hidden */
  50036. export var glowBlurPostProcessPixelShader: {
  50037. name: string;
  50038. shader: string;
  50039. };
  50040. }
  50041. declare module "babylonjs/Layers/highlightLayer" {
  50042. import { Observable } from "babylonjs/Misc/observable";
  50043. import { Nullable } from "babylonjs/types";
  50044. import { Camera } from "babylonjs/Cameras/camera";
  50045. import { Scene } from "babylonjs/scene";
  50046. import { Color3, Color4 } from "babylonjs/Maths/math";
  50047. import { SubMesh } from "babylonjs/Meshes/subMesh";
  50048. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50049. import { Mesh } from "babylonjs/Meshes/mesh";
  50050. import { Effect } from "babylonjs/Materials/effect";
  50051. import { Material } from "babylonjs/Materials/material";
  50052. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  50053. import "babylonjs/Shaders/glowMapMerge.fragment";
  50054. import "babylonjs/Shaders/glowMapMerge.vertex";
  50055. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  50056. module "babylonjs/abstractScene" {
  50057. interface AbstractScene {
  50058. /**
  50059. * Return a the first highlight layer of the scene with a given name.
  50060. * @param name The name of the highlight layer to look for.
  50061. * @return The highlight layer if found otherwise null.
  50062. */
  50063. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  50064. }
  50065. }
  50066. /**
  50067. * Highlight layer options. This helps customizing the behaviour
  50068. * of the highlight layer.
  50069. */
  50070. export interface IHighlightLayerOptions {
  50071. /**
  50072. * Multiplication factor apply to the canvas size to compute the render target size
  50073. * used to generated the glowing objects (the smaller the faster).
  50074. */
  50075. mainTextureRatio: number;
  50076. /**
  50077. * Enforces a fixed size texture to ensure resize independant blur.
  50078. */
  50079. mainTextureFixedSize?: number;
  50080. /**
  50081. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  50082. * of the picture to blur (the smaller the faster).
  50083. */
  50084. blurTextureSizeRatio: number;
  50085. /**
  50086. * How big in texel of the blur texture is the vertical blur.
  50087. */
  50088. blurVerticalSize: number;
  50089. /**
  50090. * How big in texel of the blur texture is the horizontal blur.
  50091. */
  50092. blurHorizontalSize: number;
  50093. /**
  50094. * Alpha blending mode used to apply the blur. Default is combine.
  50095. */
  50096. alphaBlendingMode: number;
  50097. /**
  50098. * The camera attached to the layer.
  50099. */
  50100. camera: Nullable<Camera>;
  50101. /**
  50102. * Should we display highlight as a solid stroke?
  50103. */
  50104. isStroke?: boolean;
  50105. /**
  50106. * The rendering group to draw the layer in.
  50107. */
  50108. renderingGroupId: number;
  50109. }
  50110. /**
  50111. * The highlight layer Helps adding a glow effect around a mesh.
  50112. *
  50113. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  50114. * glowy meshes to your scene.
  50115. *
  50116. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  50117. */
  50118. export class HighlightLayer extends EffectLayer {
  50119. name: string;
  50120. /**
  50121. * Effect Name of the highlight layer.
  50122. */
  50123. static readonly EffectName: string;
  50124. /**
  50125. * The neutral color used during the preparation of the glow effect.
  50126. * This is black by default as the blend operation is a blend operation.
  50127. */
  50128. static NeutralColor: Color4;
  50129. /**
  50130. * Stencil value used for glowing meshes.
  50131. */
  50132. static GlowingMeshStencilReference: number;
  50133. /**
  50134. * Stencil value used for the other meshes in the scene.
  50135. */
  50136. static NormalMeshStencilReference: number;
  50137. /**
  50138. * Specifies whether or not the inner glow is ACTIVE in the layer.
  50139. */
  50140. innerGlow: boolean;
  50141. /**
  50142. * Specifies whether or not the outer glow is ACTIVE in the layer.
  50143. */
  50144. outerGlow: boolean;
  50145. /**
  50146. * Specifies the horizontal size of the blur.
  50147. */
  50148. /**
  50149. * Gets the horizontal size of the blur.
  50150. */
  50151. blurHorizontalSize: number;
  50152. /**
  50153. * Specifies the vertical size of the blur.
  50154. */
  50155. /**
  50156. * Gets the vertical size of the blur.
  50157. */
  50158. blurVerticalSize: number;
  50159. /**
  50160. * An event triggered when the highlight layer is being blurred.
  50161. */
  50162. onBeforeBlurObservable: Observable<HighlightLayer>;
  50163. /**
  50164. * An event triggered when the highlight layer has been blurred.
  50165. */
  50166. onAfterBlurObservable: Observable<HighlightLayer>;
  50167. private _instanceGlowingMeshStencilReference;
  50168. private _options;
  50169. private _downSamplePostprocess;
  50170. private _horizontalBlurPostprocess;
  50171. private _verticalBlurPostprocess;
  50172. private _blurTexture;
  50173. private _meshes;
  50174. private _excludedMeshes;
  50175. /**
  50176. * Instantiates a new highlight Layer and references it to the scene..
  50177. * @param name The name of the layer
  50178. * @param scene The scene to use the layer in
  50179. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  50180. */
  50181. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  50182. /**
  50183. * Get the effect name of the layer.
  50184. * @return The effect name
  50185. */
  50186. getEffectName(): string;
  50187. /**
  50188. * Create the merge effect. This is the shader use to blit the information back
  50189. * to the main canvas at the end of the scene rendering.
  50190. */
  50191. protected _createMergeEffect(): Effect;
  50192. /**
  50193. * Creates the render target textures and post processes used in the highlight layer.
  50194. */
  50195. protected _createTextureAndPostProcesses(): void;
  50196. /**
  50197. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  50198. */
  50199. needStencil(): boolean;
  50200. /**
  50201. * Checks for the readiness of the element composing the layer.
  50202. * @param subMesh the mesh to check for
  50203. * @param useInstances specify wether or not to use instances to render the mesh
  50204. * @param emissiveTexture the associated emissive texture used to generate the glow
  50205. * @return true if ready otherwise, false
  50206. */
  50207. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  50208. /**
  50209. * Implementation specific of rendering the generating effect on the main canvas.
  50210. * @param effect The effect used to render through
  50211. */
  50212. protected _internalRender(effect: Effect): void;
  50213. /**
  50214. * Returns true if the layer contains information to display, otherwise false.
  50215. */
  50216. shouldRender(): boolean;
  50217. /**
  50218. * Returns true if the mesh should render, otherwise false.
  50219. * @param mesh The mesh to render
  50220. * @returns true if it should render otherwise false
  50221. */
  50222. protected _shouldRenderMesh(mesh: Mesh): boolean;
  50223. /**
  50224. * Sets the required values for both the emissive texture and and the main color.
  50225. */
  50226. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  50227. /**
  50228. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  50229. * @param mesh The mesh to exclude from the highlight layer
  50230. */
  50231. addExcludedMesh(mesh: Mesh): void;
  50232. /**
  50233. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  50234. * @param mesh The mesh to highlight
  50235. */
  50236. removeExcludedMesh(mesh: Mesh): void;
  50237. /**
  50238. * Determine if a given mesh will be highlighted by the current HighlightLayer
  50239. * @param mesh mesh to test
  50240. * @returns true if the mesh will be highlighted by the current HighlightLayer
  50241. */
  50242. hasMesh(mesh: AbstractMesh): boolean;
  50243. /**
  50244. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  50245. * @param mesh The mesh to highlight
  50246. * @param color The color of the highlight
  50247. * @param glowEmissiveOnly Extract the glow from the emissive texture
  50248. */
  50249. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  50250. /**
  50251. * Remove a mesh from the highlight layer in order to make it stop glowing.
  50252. * @param mesh The mesh to highlight
  50253. */
  50254. removeMesh(mesh: Mesh): void;
  50255. /**
  50256. * Force the stencil to the normal expected value for none glowing parts
  50257. */
  50258. private _defaultStencilReference;
  50259. /**
  50260. * Free any resources and references associated to a mesh.
  50261. * Internal use
  50262. * @param mesh The mesh to free.
  50263. * @hidden
  50264. */
  50265. _disposeMesh(mesh: Mesh): void;
  50266. /**
  50267. * Dispose the highlight layer and free resources.
  50268. */
  50269. dispose(): void;
  50270. /**
  50271. * Gets the class name of the effect layer
  50272. * @returns the string with the class name of the effect layer
  50273. */
  50274. getClassName(): string;
  50275. /**
  50276. * Serializes this Highlight layer
  50277. * @returns a serialized Highlight layer object
  50278. */
  50279. serialize(): any;
  50280. /**
  50281. * Creates a Highlight layer from parsed Highlight layer data
  50282. * @param parsedHightlightLayer defines the Highlight layer data
  50283. * @param scene defines the current scene
  50284. * @param rootUrl defines the root URL containing the Highlight layer information
  50285. * @returns a parsed Highlight layer
  50286. */
  50287. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  50288. }
  50289. }
  50290. declare module "babylonjs/Layers/layerSceneComponent" {
  50291. import { Scene } from "babylonjs/scene";
  50292. import { ISceneComponent } from "babylonjs/sceneComponent";
  50293. import { Layer } from "babylonjs/Layers/layer";
  50294. import { AbstractScene } from "babylonjs/abstractScene";
  50295. module "babylonjs/abstractScene" {
  50296. interface AbstractScene {
  50297. /**
  50298. * The list of layers (background and foreground) of the scene
  50299. */
  50300. layers: Array<Layer>;
  50301. }
  50302. }
  50303. /**
  50304. * Defines the layer scene component responsible to manage any layers
  50305. * in a given scene.
  50306. */
  50307. export class LayerSceneComponent implements ISceneComponent {
  50308. /**
  50309. * The component name helpfull to identify the component in the list of scene components.
  50310. */
  50311. readonly name: string;
  50312. /**
  50313. * The scene the component belongs to.
  50314. */
  50315. scene: Scene;
  50316. private _engine;
  50317. /**
  50318. * Creates a new instance of the component for the given scene
  50319. * @param scene Defines the scene to register the component in
  50320. */
  50321. constructor(scene: Scene);
  50322. /**
  50323. * Registers the component in a given scene
  50324. */
  50325. register(): void;
  50326. /**
  50327. * Rebuilds the elements related to this component in case of
  50328. * context lost for instance.
  50329. */
  50330. rebuild(): void;
  50331. /**
  50332. * Disposes the component and the associated ressources.
  50333. */
  50334. dispose(): void;
  50335. private _draw;
  50336. private _drawCameraPredicate;
  50337. private _drawCameraBackground;
  50338. private _drawCameraForeground;
  50339. private _drawRenderTargetPredicate;
  50340. private _drawRenderTargetBackground;
  50341. private _drawRenderTargetForeground;
  50342. /**
  50343. * Adds all the elements from the container to the scene
  50344. * @param container the container holding the elements
  50345. */
  50346. addFromContainer(container: AbstractScene): void;
  50347. /**
  50348. * Removes all the elements in the container from the scene
  50349. * @param container contains the elements to remove
  50350. * @param dispose if the removed element should be disposed (default: false)
  50351. */
  50352. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50353. }
  50354. }
  50355. declare module "babylonjs/Shaders/layer.fragment" {
  50356. /** @hidden */
  50357. export var layerPixelShader: {
  50358. name: string;
  50359. shader: string;
  50360. };
  50361. }
  50362. declare module "babylonjs/Shaders/layer.vertex" {
  50363. /** @hidden */
  50364. export var layerVertexShader: {
  50365. name: string;
  50366. shader: string;
  50367. };
  50368. }
  50369. declare module "babylonjs/Layers/layer" {
  50370. import { Observable } from "babylonjs/Misc/observable";
  50371. import { Nullable } from "babylonjs/types";
  50372. import { Scene } from "babylonjs/scene";
  50373. import { Vector2, Color4 } from "babylonjs/Maths/math";
  50374. import { Texture } from "babylonjs/Materials/Textures/texture";
  50375. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50376. import "babylonjs/Shaders/layer.fragment";
  50377. import "babylonjs/Shaders/layer.vertex";
  50378. /**
  50379. * This represents a full screen 2d layer.
  50380. * This can be useful to display a picture in the background of your scene for instance.
  50381. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50382. */
  50383. export class Layer {
  50384. /**
  50385. * Define the name of the layer.
  50386. */
  50387. name: string;
  50388. /**
  50389. * Define the texture the layer should display.
  50390. */
  50391. texture: Nullable<Texture>;
  50392. /**
  50393. * Is the layer in background or foreground.
  50394. */
  50395. isBackground: boolean;
  50396. /**
  50397. * Define the color of the layer (instead of texture).
  50398. */
  50399. color: Color4;
  50400. /**
  50401. * Define the scale of the layer in order to zoom in out of the texture.
  50402. */
  50403. scale: Vector2;
  50404. /**
  50405. * Define an offset for the layer in order to shift the texture.
  50406. */
  50407. offset: Vector2;
  50408. /**
  50409. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  50410. */
  50411. alphaBlendingMode: number;
  50412. /**
  50413. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  50414. * Alpha test will not mix with the background color in case of transparency.
  50415. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  50416. */
  50417. alphaTest: boolean;
  50418. /**
  50419. * Define a mask to restrict the layer to only some of the scene cameras.
  50420. */
  50421. layerMask: number;
  50422. /**
  50423. * Define the list of render target the layer is visible into.
  50424. */
  50425. renderTargetTextures: RenderTargetTexture[];
  50426. /**
  50427. * Define if the layer is only used in renderTarget or if it also
  50428. * renders in the main frame buffer of the canvas.
  50429. */
  50430. renderOnlyInRenderTargetTextures: boolean;
  50431. private _scene;
  50432. private _vertexBuffers;
  50433. private _indexBuffer;
  50434. private _effect;
  50435. private _alphaTestEffect;
  50436. /**
  50437. * An event triggered when the layer is disposed.
  50438. */
  50439. onDisposeObservable: Observable<Layer>;
  50440. private _onDisposeObserver;
  50441. /**
  50442. * Back compatibility with callback before the onDisposeObservable existed.
  50443. * The set callback will be triggered when the layer has been disposed.
  50444. */
  50445. onDispose: () => void;
  50446. /**
  50447. * An event triggered before rendering the scene
  50448. */
  50449. onBeforeRenderObservable: Observable<Layer>;
  50450. private _onBeforeRenderObserver;
  50451. /**
  50452. * Back compatibility with callback before the onBeforeRenderObservable existed.
  50453. * The set callback will be triggered just before rendering the layer.
  50454. */
  50455. onBeforeRender: () => void;
  50456. /**
  50457. * An event triggered after rendering the scene
  50458. */
  50459. onAfterRenderObservable: Observable<Layer>;
  50460. private _onAfterRenderObserver;
  50461. /**
  50462. * Back compatibility with callback before the onAfterRenderObservable existed.
  50463. * The set callback will be triggered just after rendering the layer.
  50464. */
  50465. onAfterRender: () => void;
  50466. /**
  50467. * Instantiates a new layer.
  50468. * This represents a full screen 2d layer.
  50469. * This can be useful to display a picture in the background of your scene for instance.
  50470. * @see https://www.babylonjs-playground.com/#08A2BS#1
  50471. * @param name Define the name of the layer in the scene
  50472. * @param imgUrl Define the url of the texture to display in the layer
  50473. * @param scene Define the scene the layer belongs to
  50474. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  50475. * @param color Defines a color for the layer
  50476. */
  50477. constructor(
  50478. /**
  50479. * Define the name of the layer.
  50480. */
  50481. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  50482. private _createIndexBuffer;
  50483. /** @hidden */
  50484. _rebuild(): void;
  50485. /**
  50486. * Renders the layer in the scene.
  50487. */
  50488. render(): void;
  50489. /**
  50490. * Disposes and releases the associated ressources.
  50491. */
  50492. dispose(): void;
  50493. }
  50494. }
  50495. declare module "babylonjs/Layers/index" {
  50496. export * from "babylonjs/Layers/effectLayer";
  50497. export * from "babylonjs/Layers/effectLayerSceneComponent";
  50498. export * from "babylonjs/Layers/glowLayer";
  50499. export * from "babylonjs/Layers/highlightLayer";
  50500. export * from "babylonjs/Layers/layer";
  50501. export * from "babylonjs/Layers/layerSceneComponent";
  50502. }
  50503. declare module "babylonjs/Shaders/lensFlare.fragment" {
  50504. /** @hidden */
  50505. export var lensFlarePixelShader: {
  50506. name: string;
  50507. shader: string;
  50508. };
  50509. }
  50510. declare module "babylonjs/Shaders/lensFlare.vertex" {
  50511. /** @hidden */
  50512. export var lensFlareVertexShader: {
  50513. name: string;
  50514. shader: string;
  50515. };
  50516. }
  50517. declare module "babylonjs/LensFlares/lensFlareSystem" {
  50518. import { Scene } from "babylonjs/scene";
  50519. import { Vector3, Viewport } from "babylonjs/Maths/math";
  50520. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50521. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  50522. import "babylonjs/Shaders/lensFlare.fragment";
  50523. import "babylonjs/Shaders/lensFlare.vertex";
  50524. /**
  50525. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50526. * It is usually composed of several `lensFlare`.
  50527. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50528. */
  50529. export class LensFlareSystem {
  50530. /**
  50531. * Define the name of the lens flare system
  50532. */
  50533. name: string;
  50534. /**
  50535. * List of lens flares used in this system.
  50536. */
  50537. lensFlares: LensFlare[];
  50538. /**
  50539. * Define a limit from the border the lens flare can be visible.
  50540. */
  50541. borderLimit: number;
  50542. /**
  50543. * Define a viewport border we do not want to see the lens flare in.
  50544. */
  50545. viewportBorder: number;
  50546. /**
  50547. * Define a predicate which could limit the list of meshes able to occlude the effect.
  50548. */
  50549. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50550. /**
  50551. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  50552. */
  50553. layerMask: number;
  50554. /**
  50555. * Define the id of the lens flare system in the scene.
  50556. * (equal to name by default)
  50557. */
  50558. id: string;
  50559. private _scene;
  50560. private _emitter;
  50561. private _vertexBuffers;
  50562. private _indexBuffer;
  50563. private _effect;
  50564. private _positionX;
  50565. private _positionY;
  50566. private _isEnabled;
  50567. /** @hidden */
  50568. static _SceneComponentInitialization: (scene: Scene) => void;
  50569. /**
  50570. * Instantiates a lens flare system.
  50571. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50572. * It is usually composed of several `lensFlare`.
  50573. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50574. * @param name Define the name of the lens flare system in the scene
  50575. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  50576. * @param scene Define the scene the lens flare system belongs to
  50577. */
  50578. constructor(
  50579. /**
  50580. * Define the name of the lens flare system
  50581. */
  50582. name: string, emitter: any, scene: Scene);
  50583. /**
  50584. * Define if the lens flare system is enabled.
  50585. */
  50586. isEnabled: boolean;
  50587. /**
  50588. * Get the scene the effects belongs to.
  50589. * @returns the scene holding the lens flare system
  50590. */
  50591. getScene(): Scene;
  50592. /**
  50593. * Get the emitter of the lens flare system.
  50594. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50595. * @returns the emitter of the lens flare system
  50596. */
  50597. getEmitter(): any;
  50598. /**
  50599. * Set the emitter of the lens flare system.
  50600. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50601. * @param newEmitter Define the new emitter of the system
  50602. */
  50603. setEmitter(newEmitter: any): void;
  50604. /**
  50605. * Get the lens flare system emitter position.
  50606. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  50607. * @returns the position
  50608. */
  50609. getEmitterPosition(): Vector3;
  50610. /**
  50611. * @hidden
  50612. */
  50613. computeEffectivePosition(globalViewport: Viewport): boolean;
  50614. /** @hidden */
  50615. _isVisible(): boolean;
  50616. /**
  50617. * @hidden
  50618. */
  50619. render(): boolean;
  50620. /**
  50621. * Dispose and release the lens flare with its associated resources.
  50622. */
  50623. dispose(): void;
  50624. /**
  50625. * Parse a lens flare system from a JSON repressentation
  50626. * @param parsedLensFlareSystem Define the JSON to parse
  50627. * @param scene Define the scene the parsed system should be instantiated in
  50628. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  50629. * @returns the parsed system
  50630. */
  50631. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  50632. /**
  50633. * Serialize the current Lens Flare System into a JSON representation.
  50634. * @returns the serialized JSON
  50635. */
  50636. serialize(): any;
  50637. }
  50638. }
  50639. declare module "babylonjs/LensFlares/lensFlare" {
  50640. import { Nullable } from "babylonjs/types";
  50641. import { Color3 } from "babylonjs/Maths/math";
  50642. import { Texture } from "babylonjs/Materials/Textures/texture";
  50643. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  50644. /**
  50645. * This represents one of the lens effect in a `lensFlareSystem`.
  50646. * It controls one of the indiviual texture used in the effect.
  50647. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50648. */
  50649. export class LensFlare {
  50650. /**
  50651. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50652. */
  50653. size: number;
  50654. /**
  50655. * 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.
  50656. */
  50657. position: number;
  50658. /**
  50659. * Define the lens color.
  50660. */
  50661. color: Color3;
  50662. /**
  50663. * Define the lens texture.
  50664. */
  50665. texture: Nullable<Texture>;
  50666. /**
  50667. * Define the alpha mode to render this particular lens.
  50668. */
  50669. alphaMode: number;
  50670. private _system;
  50671. /**
  50672. * Creates a new Lens Flare.
  50673. * This represents one of the lens effect in a `lensFlareSystem`.
  50674. * It controls one of the indiviual texture used in the effect.
  50675. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50676. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  50677. * @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.
  50678. * @param color Define the lens color
  50679. * @param imgUrl Define the lens texture url
  50680. * @param system Define the `lensFlareSystem` this flare is part of
  50681. * @returns The newly created Lens Flare
  50682. */
  50683. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  50684. /**
  50685. * Instantiates a new Lens Flare.
  50686. * This represents one of the lens effect in a `lensFlareSystem`.
  50687. * It controls one of the indiviual texture used in the effect.
  50688. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50689. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  50690. * @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.
  50691. * @param color Define the lens color
  50692. * @param imgUrl Define the lens texture url
  50693. * @param system Define the `lensFlareSystem` this flare is part of
  50694. */
  50695. constructor(
  50696. /**
  50697. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50698. */
  50699. size: number,
  50700. /**
  50701. * 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.
  50702. */
  50703. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  50704. /**
  50705. * Dispose and release the lens flare with its associated resources.
  50706. */
  50707. dispose(): void;
  50708. }
  50709. }
  50710. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  50711. import { Nullable } from "babylonjs/types";
  50712. import { Scene } from "babylonjs/scene";
  50713. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50714. import { AbstractScene } from "babylonjs/abstractScene";
  50715. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  50716. module "babylonjs/abstractScene" {
  50717. interface AbstractScene {
  50718. /**
  50719. * The list of lens flare system added to the scene
  50720. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50721. */
  50722. lensFlareSystems: Array<LensFlareSystem>;
  50723. /**
  50724. * Removes the given lens flare system from this scene.
  50725. * @param toRemove The lens flare system to remove
  50726. * @returns The index of the removed lens flare system
  50727. */
  50728. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  50729. /**
  50730. * Adds the given lens flare system to this scene
  50731. * @param newLensFlareSystem The lens flare system to add
  50732. */
  50733. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  50734. /**
  50735. * Gets a lens flare system using its name
  50736. * @param name defines the name to look for
  50737. * @returns the lens flare system or null if not found
  50738. */
  50739. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  50740. /**
  50741. * Gets a lens flare system using its id
  50742. * @param id defines the id to look for
  50743. * @returns the lens flare system or null if not found
  50744. */
  50745. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  50746. }
  50747. }
  50748. /**
  50749. * Defines the lens flare scene component responsible to manage any lens flares
  50750. * in a given scene.
  50751. */
  50752. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  50753. /**
  50754. * The component name helpfull to identify the component in the list of scene components.
  50755. */
  50756. readonly name: string;
  50757. /**
  50758. * The scene the component belongs to.
  50759. */
  50760. scene: Scene;
  50761. /**
  50762. * Creates a new instance of the component for the given scene
  50763. * @param scene Defines the scene to register the component in
  50764. */
  50765. constructor(scene: Scene);
  50766. /**
  50767. * Registers the component in a given scene
  50768. */
  50769. register(): void;
  50770. /**
  50771. * Rebuilds the elements related to this component in case of
  50772. * context lost for instance.
  50773. */
  50774. rebuild(): void;
  50775. /**
  50776. * Adds all the elements from the container to the scene
  50777. * @param container the container holding the elements
  50778. */
  50779. addFromContainer(container: AbstractScene): void;
  50780. /**
  50781. * Removes all the elements in the container from the scene
  50782. * @param container contains the elements to remove
  50783. * @param dispose if the removed element should be disposed (default: false)
  50784. */
  50785. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50786. /**
  50787. * Serializes the component data to the specified json object
  50788. * @param serializationObject The object to serialize to
  50789. */
  50790. serialize(serializationObject: any): void;
  50791. /**
  50792. * Disposes the component and the associated ressources.
  50793. */
  50794. dispose(): void;
  50795. private _draw;
  50796. }
  50797. }
  50798. declare module "babylonjs/LensFlares/index" {
  50799. export * from "babylonjs/LensFlares/lensFlare";
  50800. export * from "babylonjs/LensFlares/lensFlareSystem";
  50801. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  50802. }
  50803. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  50804. import { Scene } from "babylonjs/scene";
  50805. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50806. import { AbstractScene } from "babylonjs/abstractScene";
  50807. /**
  50808. * Defines the shadow generator component responsible to manage any shadow generators
  50809. * in a given scene.
  50810. */
  50811. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  50812. /**
  50813. * The component name helpfull to identify the component in the list of scene components.
  50814. */
  50815. readonly name: string;
  50816. /**
  50817. * The scene the component belongs to.
  50818. */
  50819. scene: Scene;
  50820. /**
  50821. * Creates a new instance of the component for the given scene
  50822. * @param scene Defines the scene to register the component in
  50823. */
  50824. constructor(scene: Scene);
  50825. /**
  50826. * Registers the component in a given scene
  50827. */
  50828. register(): void;
  50829. /**
  50830. * Rebuilds the elements related to this component in case of
  50831. * context lost for instance.
  50832. */
  50833. rebuild(): void;
  50834. /**
  50835. * Serializes the component data to the specified json object
  50836. * @param serializationObject The object to serialize to
  50837. */
  50838. serialize(serializationObject: any): void;
  50839. /**
  50840. * Adds all the elements from the container to the scene
  50841. * @param container the container holding the elements
  50842. */
  50843. addFromContainer(container: AbstractScene): void;
  50844. /**
  50845. * Removes all the elements in the container from the scene
  50846. * @param container contains the elements to remove
  50847. * @param dispose if the removed element should be disposed (default: false)
  50848. */
  50849. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50850. /**
  50851. * Rebuilds the elements related to this component in case of
  50852. * context lost for instance.
  50853. */
  50854. dispose(): void;
  50855. private _gatherRenderTargets;
  50856. }
  50857. }
  50858. declare module "babylonjs/Lights/Shadows/index" {
  50859. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  50860. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  50861. }
  50862. declare module "babylonjs/Lights/pointLight" {
  50863. import { Scene } from "babylonjs/scene";
  50864. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50865. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50866. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50867. import { Effect } from "babylonjs/Materials/effect";
  50868. /**
  50869. * A point light is a light defined by an unique point in world space.
  50870. * The light is emitted in every direction from this point.
  50871. * A good example of a point light is a standard light bulb.
  50872. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50873. */
  50874. export class PointLight extends ShadowLight {
  50875. private _shadowAngle;
  50876. /**
  50877. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50878. * This specifies what angle the shadow will use to be created.
  50879. *
  50880. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50881. */
  50882. /**
  50883. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50884. * This specifies what angle the shadow will use to be created.
  50885. *
  50886. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50887. */
  50888. shadowAngle: number;
  50889. /**
  50890. * Gets the direction if it has been set.
  50891. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50892. */
  50893. /**
  50894. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50895. */
  50896. direction: Vector3;
  50897. /**
  50898. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50899. * A PointLight emits the light in every direction.
  50900. * It can cast shadows.
  50901. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50902. * ```javascript
  50903. * var pointLight = new PointLight("pl", camera.position, scene);
  50904. * ```
  50905. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50906. * @param name The light friendly name
  50907. * @param position The position of the point light in the scene
  50908. * @param scene The scene the lights belongs to
  50909. */
  50910. constructor(name: string, position: Vector3, scene: Scene);
  50911. /**
  50912. * Returns the string "PointLight"
  50913. * @returns the class name
  50914. */
  50915. getClassName(): string;
  50916. /**
  50917. * Returns the integer 0.
  50918. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50919. */
  50920. getTypeID(): number;
  50921. /**
  50922. * Specifies wether or not the shadowmap should be a cube texture.
  50923. * @returns true if the shadowmap needs to be a cube texture.
  50924. */
  50925. needCube(): boolean;
  50926. /**
  50927. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50928. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50929. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50930. */
  50931. getShadowDirection(faceIndex?: number): Vector3;
  50932. /**
  50933. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50934. * - fov = PI / 2
  50935. * - aspect ratio : 1.0
  50936. * - z-near and far equal to the active camera minZ and maxZ.
  50937. * Returns the PointLight.
  50938. */
  50939. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50940. protected _buildUniformLayout(): void;
  50941. /**
  50942. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50943. * @param effect The effect to update
  50944. * @param lightIndex The index of the light in the effect to update
  50945. * @returns The point light
  50946. */
  50947. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50948. /**
  50949. * Prepares the list of defines specific to the light type.
  50950. * @param defines the list of defines
  50951. * @param lightIndex defines the index of the light for the effect
  50952. */
  50953. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50954. }
  50955. }
  50956. declare module "babylonjs/Lights/index" {
  50957. export * from "babylonjs/Lights/light";
  50958. export * from "babylonjs/Lights/shadowLight";
  50959. export * from "babylonjs/Lights/Shadows/index";
  50960. export * from "babylonjs/Lights/directionalLight";
  50961. export * from "babylonjs/Lights/hemisphericLight";
  50962. export * from "babylonjs/Lights/pointLight";
  50963. export * from "babylonjs/Lights/spotLight";
  50964. }
  50965. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  50966. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  50967. /**
  50968. * Header information of HDR texture files.
  50969. */
  50970. export interface HDRInfo {
  50971. /**
  50972. * The height of the texture in pixels.
  50973. */
  50974. height: number;
  50975. /**
  50976. * The width of the texture in pixels.
  50977. */
  50978. width: number;
  50979. /**
  50980. * The index of the beginning of the data in the binary file.
  50981. */
  50982. dataPosition: number;
  50983. }
  50984. /**
  50985. * This groups tools to convert HDR texture to native colors array.
  50986. */
  50987. export class HDRTools {
  50988. private static Ldexp;
  50989. private static Rgbe2float;
  50990. private static readStringLine;
  50991. /**
  50992. * Reads header information from an RGBE texture stored in a native array.
  50993. * More information on this format are available here:
  50994. * https://en.wikipedia.org/wiki/RGBE_image_format
  50995. *
  50996. * @param uint8array The binary file stored in native array.
  50997. * @return The header information.
  50998. */
  50999. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  51000. /**
  51001. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  51002. * This RGBE texture needs to store the information as a panorama.
  51003. *
  51004. * More information on this format are available here:
  51005. * https://en.wikipedia.org/wiki/RGBE_image_format
  51006. *
  51007. * @param buffer The binary file stored in an array buffer.
  51008. * @param size The expected size of the extracted cubemap.
  51009. * @return The Cube Map information.
  51010. */
  51011. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  51012. /**
  51013. * Returns the pixels data extracted from an RGBE texture.
  51014. * This pixels will be stored left to right up to down in the R G B order in one array.
  51015. *
  51016. * More information on this format are available here:
  51017. * https://en.wikipedia.org/wiki/RGBE_image_format
  51018. *
  51019. * @param uint8array The binary file stored in an array buffer.
  51020. * @param hdrInfo The header information of the file.
  51021. * @return The pixels data in RGB right to left up to down order.
  51022. */
  51023. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  51024. private static RGBE_ReadPixels_RLE;
  51025. }
  51026. }
  51027. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  51028. import { Nullable } from "babylonjs/types";
  51029. import { Scene } from "babylonjs/scene";
  51030. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  51031. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51032. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51033. /**
  51034. * This represents a texture coming from an HDR input.
  51035. *
  51036. * The only supported format is currently panorama picture stored in RGBE format.
  51037. * Example of such files can be found on HDRLib: http://hdrlib.com/
  51038. */
  51039. export class HDRCubeTexture extends BaseTexture {
  51040. private static _facesMapping;
  51041. private _generateHarmonics;
  51042. private _noMipmap;
  51043. private _textureMatrix;
  51044. private _size;
  51045. private _onLoad;
  51046. private _onError;
  51047. /**
  51048. * The texture URL.
  51049. */
  51050. url: string;
  51051. /**
  51052. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  51053. */
  51054. coordinatesMode: number;
  51055. protected _isBlocking: boolean;
  51056. /**
  51057. * Sets wether or not the texture is blocking during loading.
  51058. */
  51059. /**
  51060. * Gets wether or not the texture is blocking during loading.
  51061. */
  51062. isBlocking: boolean;
  51063. protected _rotationY: number;
  51064. /**
  51065. * Sets texture matrix rotation angle around Y axis in radians.
  51066. */
  51067. /**
  51068. * Gets texture matrix rotation angle around Y axis radians.
  51069. */
  51070. rotationY: number;
  51071. /**
  51072. * Gets or sets the center of the bounding box associated with the cube texture
  51073. * It must define where the camera used to render the texture was set
  51074. */
  51075. boundingBoxPosition: Vector3;
  51076. private _boundingBoxSize;
  51077. /**
  51078. * Gets or sets the size of the bounding box associated with the cube texture
  51079. * When defined, the cubemap will switch to local mode
  51080. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  51081. * @example https://www.babylonjs-playground.com/#RNASML
  51082. */
  51083. boundingBoxSize: Vector3;
  51084. /**
  51085. * Instantiates an HDRTexture from the following parameters.
  51086. *
  51087. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  51088. * @param scene The scene the texture will be used in
  51089. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51090. * @param noMipmap Forces to not generate the mipmap if true
  51091. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  51092. * @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)
  51093. * @param reserved Reserved flag for internal use.
  51094. */
  51095. 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>);
  51096. /**
  51097. * Get the current class name of the texture useful for serialization or dynamic coding.
  51098. * @returns "HDRCubeTexture"
  51099. */
  51100. getClassName(): string;
  51101. /**
  51102. * Occurs when the file is raw .hdr file.
  51103. */
  51104. private loadTexture;
  51105. clone(): HDRCubeTexture;
  51106. delayLoad(): void;
  51107. /**
  51108. * Get the texture reflection matrix used to rotate/transform the reflection.
  51109. * @returns the reflection matrix
  51110. */
  51111. getReflectionTextureMatrix(): Matrix;
  51112. /**
  51113. * Set the texture reflection matrix used to rotate/transform the reflection.
  51114. * @param value Define the reflection matrix to set
  51115. */
  51116. setReflectionTextureMatrix(value: Matrix): void;
  51117. /**
  51118. * Parses a JSON representation of an HDR Texture in order to create the texture
  51119. * @param parsedTexture Define the JSON representation
  51120. * @param scene Define the scene the texture should be created in
  51121. * @param rootUrl Define the root url in case we need to load relative dependencies
  51122. * @returns the newly created texture after parsing
  51123. */
  51124. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  51125. serialize(): any;
  51126. }
  51127. }
  51128. declare module "babylonjs/Physics/physicsEngine" {
  51129. import { Nullable } from "babylonjs/types";
  51130. import { Vector3 } from "babylonjs/Maths/math";
  51131. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  51132. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  51133. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  51134. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51135. /**
  51136. * Class used to control physics engine
  51137. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51138. */
  51139. export class PhysicsEngine implements IPhysicsEngine {
  51140. private _physicsPlugin;
  51141. /**
  51142. * Global value used to control the smallest number supported by the simulation
  51143. */
  51144. static Epsilon: number;
  51145. private _impostors;
  51146. private _joints;
  51147. /**
  51148. * Gets the gravity vector used by the simulation
  51149. */
  51150. gravity: Vector3;
  51151. /**
  51152. * Factory used to create the default physics plugin.
  51153. * @returns The default physics plugin
  51154. */
  51155. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  51156. /**
  51157. * Creates a new Physics Engine
  51158. * @param gravity defines the gravity vector used by the simulation
  51159. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  51160. */
  51161. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  51162. /**
  51163. * Sets the gravity vector used by the simulation
  51164. * @param gravity defines the gravity vector to use
  51165. */
  51166. setGravity(gravity: Vector3): void;
  51167. /**
  51168. * Set the time step of the physics engine.
  51169. * Default is 1/60.
  51170. * To slow it down, enter 1/600 for example.
  51171. * To speed it up, 1/30
  51172. * @param newTimeStep defines the new timestep to apply to this world.
  51173. */
  51174. setTimeStep(newTimeStep?: number): void;
  51175. /**
  51176. * Get the time step of the physics engine.
  51177. * @returns the current time step
  51178. */
  51179. getTimeStep(): number;
  51180. /**
  51181. * Release all resources
  51182. */
  51183. dispose(): void;
  51184. /**
  51185. * Gets the name of the current physics plugin
  51186. * @returns the name of the plugin
  51187. */
  51188. getPhysicsPluginName(): string;
  51189. /**
  51190. * Adding a new impostor for the impostor tracking.
  51191. * This will be done by the impostor itself.
  51192. * @param impostor the impostor to add
  51193. */
  51194. addImpostor(impostor: PhysicsImpostor): void;
  51195. /**
  51196. * Remove an impostor from the engine.
  51197. * This impostor and its mesh will not longer be updated by the physics engine.
  51198. * @param impostor the impostor to remove
  51199. */
  51200. removeImpostor(impostor: PhysicsImpostor): void;
  51201. /**
  51202. * Add a joint to the physics engine
  51203. * @param mainImpostor defines the main impostor to which the joint is added.
  51204. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  51205. * @param joint defines the joint that will connect both impostors.
  51206. */
  51207. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51208. /**
  51209. * Removes a joint from the simulation
  51210. * @param mainImpostor defines the impostor used with the joint
  51211. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  51212. * @param joint defines the joint to remove
  51213. */
  51214. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  51215. /**
  51216. * Called by the scene. No need to call it.
  51217. * @param delta defines the timespam between frames
  51218. */
  51219. _step(delta: number): void;
  51220. /**
  51221. * Gets the current plugin used to run the simulation
  51222. * @returns current plugin
  51223. */
  51224. getPhysicsPlugin(): IPhysicsEnginePlugin;
  51225. /**
  51226. * Gets the list of physic impostors
  51227. * @returns an array of PhysicsImpostor
  51228. */
  51229. getImpostors(): Array<PhysicsImpostor>;
  51230. /**
  51231. * Gets the impostor for a physics enabled object
  51232. * @param object defines the object impersonated by the impostor
  51233. * @returns the PhysicsImpostor or null if not found
  51234. */
  51235. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  51236. /**
  51237. * Gets the impostor for a physics body object
  51238. * @param body defines physics body used by the impostor
  51239. * @returns the PhysicsImpostor or null if not found
  51240. */
  51241. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  51242. /**
  51243. * Does a raycast in the physics world
  51244. * @param from when should the ray start?
  51245. * @param to when should the ray end?
  51246. * @returns PhysicsRaycastResult
  51247. */
  51248. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51249. }
  51250. }
  51251. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  51252. import { Nullable } from "babylonjs/types";
  51253. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  51254. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51255. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51256. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51257. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51258. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51259. /** @hidden */
  51260. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  51261. private _useDeltaForWorldStep;
  51262. world: any;
  51263. name: string;
  51264. private _physicsMaterials;
  51265. private _fixedTimeStep;
  51266. private _cannonRaycastResult;
  51267. private _raycastResult;
  51268. private _physicsBodysToRemoveAfterStep;
  51269. BJSCANNON: any;
  51270. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  51271. setGravity(gravity: Vector3): void;
  51272. setTimeStep(timeStep: number): void;
  51273. getTimeStep(): number;
  51274. executeStep(delta: number): void;
  51275. private _removeMarkedPhysicsBodiesFromWorld;
  51276. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51277. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51278. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51279. private _processChildMeshes;
  51280. removePhysicsBody(impostor: PhysicsImpostor): void;
  51281. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51282. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51283. private _addMaterial;
  51284. private _checkWithEpsilon;
  51285. private _createShape;
  51286. private _createHeightmap;
  51287. private _minus90X;
  51288. private _plus90X;
  51289. private _tmpPosition;
  51290. private _tmpDeltaPosition;
  51291. private _tmpUnityRotation;
  51292. private _updatePhysicsBodyTransformation;
  51293. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51294. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51295. isSupported(): boolean;
  51296. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51297. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51298. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51299. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51300. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51301. getBodyMass(impostor: PhysicsImpostor): number;
  51302. getBodyFriction(impostor: PhysicsImpostor): number;
  51303. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51304. getBodyRestitution(impostor: PhysicsImpostor): number;
  51305. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51306. sleepBody(impostor: PhysicsImpostor): void;
  51307. wakeUpBody(impostor: PhysicsImpostor): void;
  51308. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  51309. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51310. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51311. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51312. getRadius(impostor: PhysicsImpostor): number;
  51313. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51314. dispose(): void;
  51315. private _extendNamespace;
  51316. /**
  51317. * Does a raycast in the physics world
  51318. * @param from when should the ray start?
  51319. * @param to when should the ray end?
  51320. * @returns PhysicsRaycastResult
  51321. */
  51322. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51323. }
  51324. }
  51325. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  51326. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51327. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51328. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51330. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  51331. import { Nullable } from "babylonjs/types";
  51332. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51333. /** @hidden */
  51334. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  51335. world: any;
  51336. name: string;
  51337. BJSOIMO: any;
  51338. private _raycastResult;
  51339. constructor(iterations?: number, oimoInjection?: any);
  51340. setGravity(gravity: Vector3): void;
  51341. setTimeStep(timeStep: number): void;
  51342. getTimeStep(): number;
  51343. private _tmpImpostorsArray;
  51344. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51345. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51346. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51347. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51348. private _tmpPositionVector;
  51349. removePhysicsBody(impostor: PhysicsImpostor): void;
  51350. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51351. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51352. isSupported(): boolean;
  51353. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51354. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51355. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51356. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51357. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51358. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51359. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51360. getBodyMass(impostor: PhysicsImpostor): number;
  51361. getBodyFriction(impostor: PhysicsImpostor): number;
  51362. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51363. getBodyRestitution(impostor: PhysicsImpostor): number;
  51364. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51365. sleepBody(impostor: PhysicsImpostor): void;
  51366. wakeUpBody(impostor: PhysicsImpostor): void;
  51367. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51368. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  51369. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  51370. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51371. getRadius(impostor: PhysicsImpostor): number;
  51372. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51373. dispose(): void;
  51374. /**
  51375. * Does a raycast in the physics world
  51376. * @param from when should the ray start?
  51377. * @param to when should the ray end?
  51378. * @returns PhysicsRaycastResult
  51379. */
  51380. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51381. }
  51382. }
  51383. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  51384. import { Nullable } from "babylonjs/types";
  51385. import { Scene } from "babylonjs/scene";
  51386. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  51387. import { Mesh } from "babylonjs/Meshes/mesh";
  51388. /**
  51389. * Class containing static functions to help procedurally build meshes
  51390. */
  51391. export class RibbonBuilder {
  51392. /**
  51393. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51394. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51395. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51396. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51397. * * 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
  51398. * * 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
  51399. * * 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
  51400. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51401. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51402. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51403. * * 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
  51404. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51405. * * 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
  51406. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51408. * @param name defines the name of the mesh
  51409. * @param options defines the options used to create the mesh
  51410. * @param scene defines the hosting scene
  51411. * @returns the ribbon mesh
  51412. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51413. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51414. */
  51415. static CreateRibbon(name: string, options: {
  51416. pathArray: Vector3[][];
  51417. closeArray?: boolean;
  51418. closePath?: boolean;
  51419. offset?: number;
  51420. updatable?: boolean;
  51421. sideOrientation?: number;
  51422. frontUVs?: Vector4;
  51423. backUVs?: Vector4;
  51424. instance?: Mesh;
  51425. invertUV?: boolean;
  51426. uvs?: Vector2[];
  51427. colors?: Color4[];
  51428. }, scene?: Nullable<Scene>): Mesh;
  51429. }
  51430. }
  51431. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  51432. import { Nullable } from "babylonjs/types";
  51433. import { Scene } from "babylonjs/scene";
  51434. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  51435. import { Mesh } from "babylonjs/Meshes/mesh";
  51436. /**
  51437. * Class containing static functions to help procedurally build meshes
  51438. */
  51439. export class ShapeBuilder {
  51440. /**
  51441. * 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.
  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 `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.
  51445. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51446. * * 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
  51447. * * 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
  51448. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51449. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51450. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51451. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51453. * @param name defines the name of the mesh
  51454. * @param options defines the options used to create the mesh
  51455. * @param scene defines the hosting scene
  51456. * @returns the extruded shape mesh
  51457. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51458. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51459. */
  51460. static ExtrudeShape(name: string, options: {
  51461. shape: Vector3[];
  51462. path: Vector3[];
  51463. scale?: number;
  51464. rotation?: number;
  51465. cap?: number;
  51466. updatable?: boolean;
  51467. sideOrientation?: number;
  51468. frontUVs?: Vector4;
  51469. backUVs?: Vector4;
  51470. instance?: Mesh;
  51471. invertUV?: boolean;
  51472. }, scene?: Nullable<Scene>): Mesh;
  51473. /**
  51474. * Creates an custom extruded shape mesh.
  51475. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51476. * * 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.
  51477. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51478. * * 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
  51479. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51480. * * 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
  51481. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51482. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51483. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51484. * * 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
  51485. * * 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
  51486. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51487. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51488. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51489. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51491. * @param name defines the name of the mesh
  51492. * @param options defines the options used to create the mesh
  51493. * @param scene defines the hosting scene
  51494. * @returns the custom extruded shape mesh
  51495. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51496. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51497. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51498. */
  51499. static ExtrudeShapeCustom(name: string, options: {
  51500. shape: Vector3[];
  51501. path: Vector3[];
  51502. scaleFunction?: any;
  51503. rotationFunction?: any;
  51504. ribbonCloseArray?: boolean;
  51505. ribbonClosePath?: boolean;
  51506. cap?: number;
  51507. updatable?: boolean;
  51508. sideOrientation?: number;
  51509. frontUVs?: Vector4;
  51510. backUVs?: Vector4;
  51511. instance?: Mesh;
  51512. invertUV?: boolean;
  51513. }, scene?: Nullable<Scene>): Mesh;
  51514. private static _ExtrudeShapeGeneric;
  51515. }
  51516. }
  51517. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  51518. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  51519. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51520. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51521. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51522. import { Nullable } from "babylonjs/types";
  51523. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51524. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51525. /**
  51526. * AmmoJS Physics plugin
  51527. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51528. * @see https://github.com/kripken/ammo.js/
  51529. */
  51530. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51531. private _useDeltaForWorldStep;
  51532. /**
  51533. * Reference to the Ammo library
  51534. */
  51535. bjsAMMO: any;
  51536. /**
  51537. * Created ammoJS world which physics bodies are added to
  51538. */
  51539. world: any;
  51540. /**
  51541. * Name of the plugin
  51542. */
  51543. name: string;
  51544. private _timeStep;
  51545. private _fixedTimeStep;
  51546. private _maxSteps;
  51547. private _tmpQuaternion;
  51548. private _tmpAmmoTransform;
  51549. private _tmpAmmoQuaternion;
  51550. private _tmpAmmoConcreteContactResultCallback;
  51551. private _collisionConfiguration;
  51552. private _dispatcher;
  51553. private _overlappingPairCache;
  51554. private _solver;
  51555. private _softBodySolver;
  51556. private _tmpAmmoVectorA;
  51557. private _tmpAmmoVectorB;
  51558. private _tmpAmmoVectorC;
  51559. private _tmpAmmoVectorD;
  51560. private _tmpContactCallbackResult;
  51561. private _tmpAmmoVectorRCA;
  51562. private _tmpAmmoVectorRCB;
  51563. private _raycastResult;
  51564. private static readonly DISABLE_COLLISION_FLAG;
  51565. private static readonly KINEMATIC_FLAG;
  51566. private static readonly DISABLE_DEACTIVATION_FLAG;
  51567. /**
  51568. * Initializes the ammoJS plugin
  51569. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51570. * @param ammoInjection can be used to inject your own ammo reference
  51571. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  51572. */
  51573. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  51574. /**
  51575. * Sets the gravity of the physics world (m/(s^2))
  51576. * @param gravity Gravity to set
  51577. */
  51578. setGravity(gravity: Vector3): void;
  51579. /**
  51580. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51581. * @param timeStep timestep to use in seconds
  51582. */
  51583. setTimeStep(timeStep: number): void;
  51584. /**
  51585. * 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)
  51586. * @param fixedTimeStep fixedTimeStep to use in seconds
  51587. */
  51588. setFixedTimeStep(fixedTimeStep: number): void;
  51589. /**
  51590. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51591. * @param maxSteps the maximum number of steps by the physics engine per frame
  51592. */
  51593. setMaxSteps(maxSteps: number): void;
  51594. /**
  51595. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51596. * @returns the current timestep in seconds
  51597. */
  51598. getTimeStep(): number;
  51599. private _isImpostorInContact;
  51600. private _isImpostorPairInContact;
  51601. private _stepSimulation;
  51602. /**
  51603. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51604. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51605. * After the step the babylon meshes are set to the position of the physics imposters
  51606. * @param delta amount of time to step forward
  51607. * @param impostors array of imposters to update before/after the step
  51608. */
  51609. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51610. /**
  51611. * Update babylon mesh to match physics world object
  51612. * @param impostor imposter to match
  51613. */
  51614. private _afterSoftStep;
  51615. /**
  51616. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51617. * @param impostor imposter to match
  51618. */
  51619. private _ropeStep;
  51620. /**
  51621. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51622. * @param impostor imposter to match
  51623. */
  51624. private _softbodyOrClothStep;
  51625. private _tmpVector;
  51626. private _tmpMatrix;
  51627. /**
  51628. * Applies an impulse on the imposter
  51629. * @param impostor imposter to apply impulse to
  51630. * @param force amount of force to be applied to the imposter
  51631. * @param contactPoint the location to apply the impulse on the imposter
  51632. */
  51633. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51634. /**
  51635. * Applies a force on the imposter
  51636. * @param impostor imposter to apply force
  51637. * @param force amount of force to be applied to the imposter
  51638. * @param contactPoint the location to apply the force on the imposter
  51639. */
  51640. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51641. /**
  51642. * Creates a physics body using the plugin
  51643. * @param impostor the imposter to create the physics body on
  51644. */
  51645. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51646. /**
  51647. * Removes the physics body from the imposter and disposes of the body's memory
  51648. * @param impostor imposter to remove the physics body from
  51649. */
  51650. removePhysicsBody(impostor: PhysicsImpostor): void;
  51651. /**
  51652. * Generates a joint
  51653. * @param impostorJoint the imposter joint to create the joint with
  51654. */
  51655. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51656. /**
  51657. * Removes a joint
  51658. * @param impostorJoint the imposter joint to remove the joint from
  51659. */
  51660. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51661. private _addMeshVerts;
  51662. /**
  51663. * Initialise the soft body vertices to match its object's (mesh) vertices
  51664. * Softbody vertices (nodes) are in world space and to match this
  51665. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  51666. * @param impostor to create the softbody for
  51667. */
  51668. private _softVertexData;
  51669. /**
  51670. * Create an impostor's soft body
  51671. * @param impostor to create the softbody for
  51672. */
  51673. private _createSoftbody;
  51674. /**
  51675. * Create cloth for an impostor
  51676. * @param impostor to create the softbody for
  51677. */
  51678. private _createCloth;
  51679. /**
  51680. * Create rope for an impostor
  51681. * @param impostor to create the softbody for
  51682. */
  51683. private _createRope;
  51684. private _addHullVerts;
  51685. private _createShape;
  51686. /**
  51687. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51688. * @param impostor imposter containing the physics body and babylon object
  51689. */
  51690. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51691. /**
  51692. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51693. * @param impostor imposter containing the physics body and babylon object
  51694. * @param newPosition new position
  51695. * @param newRotation new rotation
  51696. */
  51697. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51698. /**
  51699. * If this plugin is supported
  51700. * @returns true if its supported
  51701. */
  51702. isSupported(): boolean;
  51703. /**
  51704. * Sets the linear velocity of the physics body
  51705. * @param impostor imposter to set the velocity on
  51706. * @param velocity velocity to set
  51707. */
  51708. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51709. /**
  51710. * Sets the angular velocity of the physics body
  51711. * @param impostor imposter to set the velocity on
  51712. * @param velocity velocity to set
  51713. */
  51714. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51715. /**
  51716. * gets the linear velocity
  51717. * @param impostor imposter to get linear velocity from
  51718. * @returns linear velocity
  51719. */
  51720. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51721. /**
  51722. * gets the angular velocity
  51723. * @param impostor imposter to get angular velocity from
  51724. * @returns angular velocity
  51725. */
  51726. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51727. /**
  51728. * Sets the mass of physics body
  51729. * @param impostor imposter to set the mass on
  51730. * @param mass mass to set
  51731. */
  51732. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51733. /**
  51734. * Gets the mass of the physics body
  51735. * @param impostor imposter to get the mass from
  51736. * @returns mass
  51737. */
  51738. getBodyMass(impostor: PhysicsImpostor): number;
  51739. /**
  51740. * Gets friction of the impostor
  51741. * @param impostor impostor to get friction from
  51742. * @returns friction value
  51743. */
  51744. getBodyFriction(impostor: PhysicsImpostor): number;
  51745. /**
  51746. * Sets friction of the impostor
  51747. * @param impostor impostor to set friction on
  51748. * @param friction friction value
  51749. */
  51750. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51751. /**
  51752. * Gets restitution of the impostor
  51753. * @param impostor impostor to get restitution from
  51754. * @returns restitution value
  51755. */
  51756. getBodyRestitution(impostor: PhysicsImpostor): number;
  51757. /**
  51758. * Sets resitution of the impostor
  51759. * @param impostor impostor to set resitution on
  51760. * @param restitution resitution value
  51761. */
  51762. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51763. /**
  51764. * Gets pressure inside the impostor
  51765. * @param impostor impostor to get pressure from
  51766. * @returns pressure value
  51767. */
  51768. getBodyPressure(impostor: PhysicsImpostor): number;
  51769. /**
  51770. * Sets pressure inside a soft body impostor
  51771. * Cloth and rope must remain 0 pressure
  51772. * @param impostor impostor to set pressure on
  51773. * @param pressure pressure value
  51774. */
  51775. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  51776. /**
  51777. * Gets stiffness of the impostor
  51778. * @param impostor impostor to get stiffness from
  51779. * @returns pressure value
  51780. */
  51781. getBodyStiffness(impostor: PhysicsImpostor): number;
  51782. /**
  51783. * Sets stiffness of the impostor
  51784. * @param impostor impostor to set stiffness on
  51785. * @param stiffness stiffness value from 0 to 1
  51786. */
  51787. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  51788. /**
  51789. * Gets velocityIterations of the impostor
  51790. * @param impostor impostor to get velocity iterations from
  51791. * @returns velocityIterations value
  51792. */
  51793. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  51794. /**
  51795. * Sets velocityIterations of the impostor
  51796. * @param impostor impostor to set velocity iterations on
  51797. * @param velocityIterations velocityIterations value
  51798. */
  51799. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  51800. /**
  51801. * Gets positionIterations of the impostor
  51802. * @param impostor impostor to get position iterations from
  51803. * @returns positionIterations value
  51804. */
  51805. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  51806. /**
  51807. * Sets positionIterations of the impostor
  51808. * @param impostor impostor to set position on
  51809. * @param positionIterations positionIterations value
  51810. */
  51811. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  51812. /**
  51813. * Append an anchor to a cloth object
  51814. * @param impostor is the cloth impostor to add anchor to
  51815. * @param otherImpostor is the rigid impostor to anchor to
  51816. * @param width ratio across width from 0 to 1
  51817. * @param height ratio up height from 0 to 1
  51818. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  51819. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51820. */
  51821. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51822. /**
  51823. * Append an hook to a rope object
  51824. * @param impostor is the rope impostor to add hook to
  51825. * @param otherImpostor is the rigid impostor to hook to
  51826. * @param length ratio along the rope from 0 to 1
  51827. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  51828. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51829. */
  51830. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51831. /**
  51832. * Sleeps the physics body and stops it from being active
  51833. * @param impostor impostor to sleep
  51834. */
  51835. sleepBody(impostor: PhysicsImpostor): void;
  51836. /**
  51837. * Activates the physics body
  51838. * @param impostor impostor to activate
  51839. */
  51840. wakeUpBody(impostor: PhysicsImpostor): void;
  51841. /**
  51842. * Updates the distance parameters of the joint
  51843. * @param joint joint to update
  51844. * @param maxDistance maximum distance of the joint
  51845. * @param minDistance minimum distance of the joint
  51846. */
  51847. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51848. /**
  51849. * Sets a motor on the joint
  51850. * @param joint joint to set motor on
  51851. * @param speed speed of the motor
  51852. * @param maxForce maximum force of the motor
  51853. * @param motorIndex index of the motor
  51854. */
  51855. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51856. /**
  51857. * Sets the motors limit
  51858. * @param joint joint to set limit on
  51859. * @param upperLimit upper limit
  51860. * @param lowerLimit lower limit
  51861. */
  51862. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51863. /**
  51864. * Syncs the position and rotation of a mesh with the impostor
  51865. * @param mesh mesh to sync
  51866. * @param impostor impostor to update the mesh with
  51867. */
  51868. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51869. /**
  51870. * Gets the radius of the impostor
  51871. * @param impostor impostor to get radius from
  51872. * @returns the radius
  51873. */
  51874. getRadius(impostor: PhysicsImpostor): number;
  51875. /**
  51876. * Gets the box size of the impostor
  51877. * @param impostor impostor to get box size from
  51878. * @param result the resulting box size
  51879. */
  51880. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51881. /**
  51882. * Disposes of the impostor
  51883. */
  51884. dispose(): void;
  51885. /**
  51886. * Does a raycast in the physics world
  51887. * @param from when should the ray start?
  51888. * @param to when should the ray end?
  51889. * @returns PhysicsRaycastResult
  51890. */
  51891. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51892. }
  51893. }
  51894. declare module "babylonjs/Probes/reflectionProbe" {
  51895. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51896. import { Vector3 } from "babylonjs/Maths/math";
  51897. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51898. import { Nullable } from "babylonjs/types";
  51899. import { Scene } from "babylonjs/scene";
  51900. module "babylonjs/abstractScene" {
  51901. interface AbstractScene {
  51902. /**
  51903. * The list of reflection probes added to the scene
  51904. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51905. */
  51906. reflectionProbes: Array<ReflectionProbe>;
  51907. /**
  51908. * Removes the given reflection probe from this scene.
  51909. * @param toRemove The reflection probe to remove
  51910. * @returns The index of the removed reflection probe
  51911. */
  51912. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51913. /**
  51914. * Adds the given reflection probe to this scene.
  51915. * @param newReflectionProbe The reflection probe to add
  51916. */
  51917. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51918. }
  51919. }
  51920. /**
  51921. * Class used to generate realtime reflection / refraction cube textures
  51922. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51923. */
  51924. export class ReflectionProbe {
  51925. /** defines the name of the probe */
  51926. name: string;
  51927. private _scene;
  51928. private _renderTargetTexture;
  51929. private _projectionMatrix;
  51930. private _viewMatrix;
  51931. private _target;
  51932. private _add;
  51933. private _attachedMesh;
  51934. private _invertYAxis;
  51935. /** Gets or sets probe position (center of the cube map) */
  51936. position: Vector3;
  51937. /**
  51938. * Creates a new reflection probe
  51939. * @param name defines the name of the probe
  51940. * @param size defines the texture resolution (for each face)
  51941. * @param scene defines the hosting scene
  51942. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51943. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51944. */
  51945. constructor(
  51946. /** defines the name of the probe */
  51947. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51948. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51949. samples: number;
  51950. /** Gets or sets the refresh rate to use (on every frame by default) */
  51951. refreshRate: number;
  51952. /**
  51953. * Gets the hosting scene
  51954. * @returns a Scene
  51955. */
  51956. getScene(): Scene;
  51957. /** Gets the internal CubeTexture used to render to */
  51958. readonly cubeTexture: RenderTargetTexture;
  51959. /** Gets the list of meshes to render */
  51960. readonly renderList: Nullable<AbstractMesh[]>;
  51961. /**
  51962. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51963. * @param mesh defines the mesh to attach to
  51964. */
  51965. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51966. /**
  51967. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51968. * @param renderingGroupId The rendering group id corresponding to its index
  51969. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51970. */
  51971. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51972. /**
  51973. * Clean all associated resources
  51974. */
  51975. dispose(): void;
  51976. /**
  51977. * Converts the reflection probe information to a readable string for debug purpose.
  51978. * @param fullDetails Supports for multiple levels of logging within scene loading
  51979. * @returns the human readable reflection probe info
  51980. */
  51981. toString(fullDetails?: boolean): string;
  51982. /**
  51983. * Get the class name of the relfection probe.
  51984. * @returns "ReflectionProbe"
  51985. */
  51986. getClassName(): string;
  51987. /**
  51988. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51989. * @returns The JSON representation of the texture
  51990. */
  51991. serialize(): any;
  51992. /**
  51993. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51994. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51995. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51996. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51997. * @returns The parsed reflection probe if successful
  51998. */
  51999. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  52000. }
  52001. }
  52002. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  52003. /** @hidden */
  52004. export var _BabylonLoaderRegistered: boolean;
  52005. }
  52006. declare module "babylonjs/Loading/Plugins/index" {
  52007. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  52008. }
  52009. declare module "babylonjs/Loading/index" {
  52010. export * from "babylonjs/Loading/loadingScreen";
  52011. export * from "babylonjs/Loading/Plugins/index";
  52012. export * from "babylonjs/Loading/sceneLoader";
  52013. export * from "babylonjs/Loading/sceneLoaderFlags";
  52014. }
  52015. declare module "babylonjs/Materials/Background/index" {
  52016. export * from "babylonjs/Materials/Background/backgroundMaterial";
  52017. }
  52018. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  52019. import { Scene } from "babylonjs/scene";
  52020. import { Color3 } from "babylonjs/Maths/math";
  52021. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52022. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52023. /**
  52024. * The Physically based simple base material of BJS.
  52025. *
  52026. * This enables better naming and convention enforcements on top of the pbrMaterial.
  52027. * It is used as the base class for both the specGloss and metalRough conventions.
  52028. */
  52029. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  52030. /**
  52031. * Number of Simultaneous lights allowed on the material.
  52032. */
  52033. maxSimultaneousLights: number;
  52034. /**
  52035. * If sets to true, disables all the lights affecting the material.
  52036. */
  52037. disableLighting: boolean;
  52038. /**
  52039. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  52040. */
  52041. environmentTexture: BaseTexture;
  52042. /**
  52043. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52044. */
  52045. invertNormalMapX: boolean;
  52046. /**
  52047. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52048. */
  52049. invertNormalMapY: boolean;
  52050. /**
  52051. * Normal map used in the model.
  52052. */
  52053. normalTexture: BaseTexture;
  52054. /**
  52055. * Emissivie color used to self-illuminate the model.
  52056. */
  52057. emissiveColor: Color3;
  52058. /**
  52059. * Emissivie texture used to self-illuminate the model.
  52060. */
  52061. emissiveTexture: BaseTexture;
  52062. /**
  52063. * Occlusion Channel Strenght.
  52064. */
  52065. occlusionStrength: number;
  52066. /**
  52067. * Occlusion Texture of the material (adding extra occlusion effects).
  52068. */
  52069. occlusionTexture: BaseTexture;
  52070. /**
  52071. * Defines the alpha limits in alpha test mode.
  52072. */
  52073. alphaCutOff: number;
  52074. /**
  52075. * Gets the current double sided mode.
  52076. */
  52077. /**
  52078. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52079. */
  52080. doubleSided: boolean;
  52081. /**
  52082. * Stores the pre-calculated light information of a mesh in a texture.
  52083. */
  52084. lightmapTexture: BaseTexture;
  52085. /**
  52086. * If true, the light map contains occlusion information instead of lighting info.
  52087. */
  52088. useLightmapAsShadowmap: boolean;
  52089. /**
  52090. * Instantiates a new PBRMaterial instance.
  52091. *
  52092. * @param name The material name
  52093. * @param scene The scene the material will be use in.
  52094. */
  52095. constructor(name: string, scene: Scene);
  52096. getClassName(): string;
  52097. }
  52098. }
  52099. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  52100. import { Scene } from "babylonjs/scene";
  52101. import { Color3 } from "babylonjs/Maths/math";
  52102. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52103. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52104. /**
  52105. * The PBR material of BJS following the metal roughness convention.
  52106. *
  52107. * This fits to the PBR convention in the GLTF definition:
  52108. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  52109. */
  52110. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  52111. /**
  52112. * The base color has two different interpretations depending on the value of metalness.
  52113. * When the material is a metal, the base color is the specific measured reflectance value
  52114. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  52115. * of the material.
  52116. */
  52117. baseColor: Color3;
  52118. /**
  52119. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  52120. * well as opacity information in the alpha channel.
  52121. */
  52122. baseTexture: BaseTexture;
  52123. /**
  52124. * Specifies the metallic scalar value of the material.
  52125. * Can also be used to scale the metalness values of the metallic texture.
  52126. */
  52127. metallic: number;
  52128. /**
  52129. * Specifies the roughness scalar value of the material.
  52130. * Can also be used to scale the roughness values of the metallic texture.
  52131. */
  52132. roughness: number;
  52133. /**
  52134. * Texture containing both the metallic value in the B channel and the
  52135. * roughness value in the G channel to keep better precision.
  52136. */
  52137. metallicRoughnessTexture: BaseTexture;
  52138. /**
  52139. * Instantiates a new PBRMetalRoughnessMaterial instance.
  52140. *
  52141. * @param name The material name
  52142. * @param scene The scene the material will be use in.
  52143. */
  52144. constructor(name: string, scene: Scene);
  52145. /**
  52146. * Return the currrent class name of the material.
  52147. */
  52148. getClassName(): string;
  52149. /**
  52150. * Makes a duplicate of the current material.
  52151. * @param name - name to use for the new material.
  52152. */
  52153. clone(name: string): PBRMetallicRoughnessMaterial;
  52154. /**
  52155. * Serialize the material to a parsable JSON object.
  52156. */
  52157. serialize(): any;
  52158. /**
  52159. * Parses a JSON object correponding to the serialize function.
  52160. */
  52161. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  52162. }
  52163. }
  52164. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  52165. import { Scene } from "babylonjs/scene";
  52166. import { Color3 } from "babylonjs/Maths/math";
  52167. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52168. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52169. /**
  52170. * The PBR material of BJS following the specular glossiness convention.
  52171. *
  52172. * This fits to the PBR convention in the GLTF definition:
  52173. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  52174. */
  52175. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  52176. /**
  52177. * Specifies the diffuse color of the material.
  52178. */
  52179. diffuseColor: Color3;
  52180. /**
  52181. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  52182. * channel.
  52183. */
  52184. diffuseTexture: BaseTexture;
  52185. /**
  52186. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  52187. */
  52188. specularColor: Color3;
  52189. /**
  52190. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  52191. */
  52192. glossiness: number;
  52193. /**
  52194. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  52195. */
  52196. specularGlossinessTexture: BaseTexture;
  52197. /**
  52198. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  52199. *
  52200. * @param name The material name
  52201. * @param scene The scene the material will be use in.
  52202. */
  52203. constructor(name: string, scene: Scene);
  52204. /**
  52205. * Return the currrent class name of the material.
  52206. */
  52207. getClassName(): string;
  52208. /**
  52209. * Makes a duplicate of the current material.
  52210. * @param name - name to use for the new material.
  52211. */
  52212. clone(name: string): PBRSpecularGlossinessMaterial;
  52213. /**
  52214. * Serialize the material to a parsable JSON object.
  52215. */
  52216. serialize(): any;
  52217. /**
  52218. * Parses a JSON object correponding to the serialize function.
  52219. */
  52220. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  52221. }
  52222. }
  52223. declare module "babylonjs/Materials/PBR/index" {
  52224. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  52225. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  52226. export * from "babylonjs/Materials/PBR/pbrMaterial";
  52227. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  52228. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  52229. }
  52230. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  52231. import { Nullable } from "babylonjs/types";
  52232. import { Scene } from "babylonjs/scene";
  52233. import { Matrix } from "babylonjs/Maths/math";
  52234. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52235. /**
  52236. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  52237. * It can help converting any input color in a desired output one. This can then be used to create effects
  52238. * from sepia, black and white to sixties or futuristic rendering...
  52239. *
  52240. * The only supported format is currently 3dl.
  52241. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  52242. */
  52243. export class ColorGradingTexture extends BaseTexture {
  52244. /**
  52245. * The current texture matrix. (will always be identity in color grading texture)
  52246. */
  52247. private _textureMatrix;
  52248. /**
  52249. * The texture URL.
  52250. */
  52251. url: string;
  52252. /**
  52253. * Empty line regex stored for GC.
  52254. */
  52255. private static _noneEmptyLineRegex;
  52256. private _engine;
  52257. /**
  52258. * Instantiates a ColorGradingTexture from the following parameters.
  52259. *
  52260. * @param url The location of the color gradind data (currently only supporting 3dl)
  52261. * @param scene The scene the texture will be used in
  52262. */
  52263. constructor(url: string, scene: Scene);
  52264. /**
  52265. * Returns the texture matrix used in most of the material.
  52266. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  52267. */
  52268. getTextureMatrix(): Matrix;
  52269. /**
  52270. * Occurs when the file being loaded is a .3dl LUT file.
  52271. */
  52272. private load3dlTexture;
  52273. /**
  52274. * Starts the loading process of the texture.
  52275. */
  52276. private loadTexture;
  52277. /**
  52278. * Clones the color gradind texture.
  52279. */
  52280. clone(): ColorGradingTexture;
  52281. /**
  52282. * Called during delayed load for textures.
  52283. */
  52284. delayLoad(): void;
  52285. /**
  52286. * Parses a color grading texture serialized by Babylon.
  52287. * @param parsedTexture The texture information being parsedTexture
  52288. * @param scene The scene to load the texture in
  52289. * @param rootUrl The root url of the data assets to load
  52290. * @return A color gradind texture
  52291. */
  52292. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  52293. /**
  52294. * Serializes the LUT texture to json format.
  52295. */
  52296. serialize(): any;
  52297. }
  52298. }
  52299. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  52300. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52301. import { Scene } from "babylonjs/scene";
  52302. import { Nullable } from "babylonjs/types";
  52303. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52304. /**
  52305. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  52306. */
  52307. export class EquiRectangularCubeTexture extends BaseTexture {
  52308. /** The six faces of the cube. */
  52309. private static _FacesMapping;
  52310. private _noMipmap;
  52311. private _onLoad;
  52312. private _onError;
  52313. /** The size of the cubemap. */
  52314. private _size;
  52315. /** The buffer of the image. */
  52316. private _buffer;
  52317. /** The width of the input image. */
  52318. private _width;
  52319. /** The height of the input image. */
  52320. private _height;
  52321. /** The URL to the image. */
  52322. url: string;
  52323. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  52324. coordinatesMode: number;
  52325. /**
  52326. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  52327. * @param url The location of the image
  52328. * @param scene The scene the texture will be used in
  52329. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  52330. * @param noMipmap Forces to not generate the mipmap if true
  52331. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  52332. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  52333. * @param onLoad — defines a callback called when texture is loaded
  52334. * @param onError — defines a callback called if there is an error
  52335. */
  52336. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  52337. /**
  52338. * Load the image data, by putting the image on a canvas and extracting its buffer.
  52339. */
  52340. private loadImage;
  52341. /**
  52342. * Convert the image buffer into a cubemap and create a CubeTexture.
  52343. */
  52344. private loadTexture;
  52345. /**
  52346. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  52347. * @param buffer The ArrayBuffer that should be converted.
  52348. * @returns The buffer as Float32Array.
  52349. */
  52350. private getFloat32ArrayFromArrayBuffer;
  52351. /**
  52352. * Get the current class name of the texture useful for serialization or dynamic coding.
  52353. * @returns "EquiRectangularCubeTexture"
  52354. */
  52355. getClassName(): string;
  52356. /**
  52357. * Create a clone of the current EquiRectangularCubeTexture and return it.
  52358. * @returns A clone of the current EquiRectangularCubeTexture.
  52359. */
  52360. clone(): EquiRectangularCubeTexture;
  52361. }
  52362. }
  52363. declare module "babylonjs/Misc/tga" {
  52364. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52365. /**
  52366. * Based on jsTGALoader - Javascript loader for TGA file
  52367. * By Vincent Thibault
  52368. * @see http://blog.robrowser.com/javascript-tga-loader.html
  52369. */
  52370. export class TGATools {
  52371. private static _TYPE_INDEXED;
  52372. private static _TYPE_RGB;
  52373. private static _TYPE_GREY;
  52374. private static _TYPE_RLE_INDEXED;
  52375. private static _TYPE_RLE_RGB;
  52376. private static _TYPE_RLE_GREY;
  52377. private static _ORIGIN_MASK;
  52378. private static _ORIGIN_SHIFT;
  52379. private static _ORIGIN_BL;
  52380. private static _ORIGIN_BR;
  52381. private static _ORIGIN_UL;
  52382. private static _ORIGIN_UR;
  52383. /**
  52384. * Gets the header of a TGA file
  52385. * @param data defines the TGA data
  52386. * @returns the header
  52387. */
  52388. static GetTGAHeader(data: Uint8Array): any;
  52389. /**
  52390. * Uploads TGA content to a Babylon Texture
  52391. * @hidden
  52392. */
  52393. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  52394. /** @hidden */
  52395. 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;
  52396. /** @hidden */
  52397. 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;
  52398. /** @hidden */
  52399. 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;
  52400. /** @hidden */
  52401. 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;
  52402. /** @hidden */
  52403. 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;
  52404. /** @hidden */
  52405. 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;
  52406. }
  52407. }
  52408. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  52409. import { Nullable } from "babylonjs/types";
  52410. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52411. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52412. /**
  52413. * Implementation of the TGA Texture Loader.
  52414. * @hidden
  52415. */
  52416. export class _TGATextureLoader implements IInternalTextureLoader {
  52417. /**
  52418. * Defines wether the loader supports cascade loading the different faces.
  52419. */
  52420. readonly supportCascades: boolean;
  52421. /**
  52422. * This returns if the loader support the current file information.
  52423. * @param extension defines the file extension of the file being loaded
  52424. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52425. * @param fallback defines the fallback internal texture if any
  52426. * @param isBase64 defines whether the texture is encoded as a base64
  52427. * @param isBuffer defines whether the texture data are stored as a buffer
  52428. * @returns true if the loader can load the specified file
  52429. */
  52430. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52431. /**
  52432. * Transform the url before loading if required.
  52433. * @param rootUrl the url of the texture
  52434. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52435. * @returns the transformed texture
  52436. */
  52437. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52438. /**
  52439. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52440. * @param rootUrl the url of the texture
  52441. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52442. * @returns the fallback texture
  52443. */
  52444. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52445. /**
  52446. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52447. * @param data contains the texture data
  52448. * @param texture defines the BabylonJS internal texture
  52449. * @param createPolynomials will be true if polynomials have been requested
  52450. * @param onLoad defines the callback to trigger once the texture is ready
  52451. * @param onError defines the callback to trigger in case of error
  52452. */
  52453. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52454. /**
  52455. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52456. * @param data contains the texture data
  52457. * @param texture defines the BabylonJS internal texture
  52458. * @param callback defines the method to call once ready to upload
  52459. */
  52460. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52461. }
  52462. }
  52463. declare module "babylonjs/Misc/basis" {
  52464. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52465. /**
  52466. * Info about the .basis files
  52467. */
  52468. class BasisFileInfo {
  52469. /**
  52470. * If the file has alpha
  52471. */
  52472. hasAlpha: boolean;
  52473. /**
  52474. * Info about each image of the basis file
  52475. */
  52476. images: Array<{
  52477. levels: Array<{
  52478. width: number;
  52479. height: number;
  52480. transcodedPixels: ArrayBufferView;
  52481. }>;
  52482. }>;
  52483. }
  52484. /**
  52485. * Result of transcoding a basis file
  52486. */
  52487. class TranscodeResult {
  52488. /**
  52489. * Info about the .basis file
  52490. */
  52491. fileInfo: BasisFileInfo;
  52492. /**
  52493. * Format to use when loading the file
  52494. */
  52495. format: number;
  52496. }
  52497. /**
  52498. * Configuration options for the Basis transcoder
  52499. */
  52500. export class BasisTranscodeConfiguration {
  52501. /**
  52502. * Supported compression formats used to determine the supported output format of the transcoder
  52503. */
  52504. supportedCompressionFormats?: {
  52505. /**
  52506. * etc1 compression format
  52507. */
  52508. etc1?: boolean;
  52509. /**
  52510. * s3tc compression format
  52511. */
  52512. s3tc?: boolean;
  52513. /**
  52514. * pvrtc compression format
  52515. */
  52516. pvrtc?: boolean;
  52517. /**
  52518. * etc2 compression format
  52519. */
  52520. etc2?: boolean;
  52521. };
  52522. /**
  52523. * If mipmap levels should be loaded for transcoded images (Default: true)
  52524. */
  52525. loadMipmapLevels?: boolean;
  52526. /**
  52527. * Index of a single image to load (Default: all images)
  52528. */
  52529. loadSingleImage?: number;
  52530. }
  52531. /**
  52532. * Used to load .Basis files
  52533. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  52534. */
  52535. export class BasisTools {
  52536. private static _IgnoreSupportedFormats;
  52537. /**
  52538. * URL to use when loading the basis transcoder
  52539. */
  52540. static JSModuleURL: string;
  52541. /**
  52542. * URL to use when loading the wasm module for the transcoder
  52543. */
  52544. static WasmModuleURL: string;
  52545. /**
  52546. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  52547. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  52548. * @returns internal format corresponding to the Basis format
  52549. */
  52550. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  52551. private static _WorkerPromise;
  52552. private static _Worker;
  52553. private static _actionId;
  52554. private static _CreateWorkerAsync;
  52555. /**
  52556. * Transcodes a loaded image file to compressed pixel data
  52557. * @param imageData image data to transcode
  52558. * @param config configuration options for the transcoding
  52559. * @returns a promise resulting in the transcoded image
  52560. */
  52561. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  52562. /**
  52563. * Loads a texture from the transcode result
  52564. * @param texture texture load to
  52565. * @param transcodeResult the result of transcoding the basis file to load from
  52566. */
  52567. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  52568. }
  52569. }
  52570. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  52571. import { Nullable } from "babylonjs/types";
  52572. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52573. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  52574. /**
  52575. * Loader for .basis file format
  52576. */
  52577. export class _BasisTextureLoader implements IInternalTextureLoader {
  52578. /**
  52579. * Defines whether the loader supports cascade loading the different faces.
  52580. */
  52581. readonly supportCascades: boolean;
  52582. /**
  52583. * This returns if the loader support the current file information.
  52584. * @param extension defines the file extension of the file being loaded
  52585. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52586. * @param fallback defines the fallback internal texture if any
  52587. * @param isBase64 defines whether the texture is encoded as a base64
  52588. * @param isBuffer defines whether the texture data are stored as a buffer
  52589. * @returns true if the loader can load the specified file
  52590. */
  52591. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52592. /**
  52593. * Transform the url before loading if required.
  52594. * @param rootUrl the url of the texture
  52595. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52596. * @returns the transformed texture
  52597. */
  52598. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52599. /**
  52600. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52601. * @param rootUrl the url of the texture
  52602. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52603. * @returns the fallback texture
  52604. */
  52605. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52606. /**
  52607. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  52608. * @param data contains the texture data
  52609. * @param texture defines the BabylonJS internal texture
  52610. * @param createPolynomials will be true if polynomials have been requested
  52611. * @param onLoad defines the callback to trigger once the texture is ready
  52612. * @param onError defines the callback to trigger in case of error
  52613. */
  52614. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52615. /**
  52616. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52617. * @param data contains the texture data
  52618. * @param texture defines the BabylonJS internal texture
  52619. * @param callback defines the method to call once ready to upload
  52620. */
  52621. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52622. }
  52623. }
  52624. declare module "babylonjs/Materials/Textures/Loaders/index" {
  52625. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  52626. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  52627. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  52628. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  52629. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  52630. }
  52631. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  52632. import { Scene } from "babylonjs/scene";
  52633. import { Texture } from "babylonjs/Materials/Textures/texture";
  52634. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52635. /**
  52636. * 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.
  52637. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52638. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52639. */
  52640. export class CustomProceduralTexture extends ProceduralTexture {
  52641. private _animate;
  52642. private _time;
  52643. private _config;
  52644. private _texturePath;
  52645. /**
  52646. * Instantiates a new Custom Procedural Texture.
  52647. * 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.
  52648. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  52649. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  52650. * @param name Define the name of the texture
  52651. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  52652. * @param size Define the size of the texture to create
  52653. * @param scene Define the scene the texture belongs to
  52654. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  52655. * @param generateMipMaps Define if the texture should creates mip maps or not
  52656. */
  52657. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52658. private _loadJson;
  52659. /**
  52660. * Is the texture ready to be used ? (rendered at least once)
  52661. * @returns true if ready, otherwise, false.
  52662. */
  52663. isReady(): boolean;
  52664. /**
  52665. * Render the texture to its associated render target.
  52666. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  52667. */
  52668. render(useCameraPostProcess?: boolean): void;
  52669. /**
  52670. * Update the list of dependant textures samplers in the shader.
  52671. */
  52672. updateTextures(): void;
  52673. /**
  52674. * Update the uniform values of the procedural texture in the shader.
  52675. */
  52676. updateShaderUniforms(): void;
  52677. /**
  52678. * Define if the texture animates or not.
  52679. */
  52680. animate: boolean;
  52681. }
  52682. }
  52683. declare module "babylonjs/Shaders/noise.fragment" {
  52684. /** @hidden */
  52685. export var noisePixelShader: {
  52686. name: string;
  52687. shader: string;
  52688. };
  52689. }
  52690. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  52691. import { Nullable } from "babylonjs/types";
  52692. import { Scene } from "babylonjs/scene";
  52693. import { Texture } from "babylonjs/Materials/Textures/texture";
  52694. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52695. import "babylonjs/Shaders/noise.fragment";
  52696. /**
  52697. * Class used to generate noise procedural textures
  52698. */
  52699. export class NoiseProceduralTexture extends ProceduralTexture {
  52700. private _time;
  52701. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  52702. brightness: number;
  52703. /** Defines the number of octaves to process */
  52704. octaves: number;
  52705. /** Defines the level of persistence (0.8 by default) */
  52706. persistence: number;
  52707. /** Gets or sets animation speed factor (default is 1) */
  52708. animationSpeedFactor: number;
  52709. /**
  52710. * Creates a new NoiseProceduralTexture
  52711. * @param name defines the name fo the texture
  52712. * @param size defines the size of the texture (default is 256)
  52713. * @param scene defines the hosting scene
  52714. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  52715. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  52716. */
  52717. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52718. private _updateShaderUniforms;
  52719. protected _getDefines(): string;
  52720. /** Generate the current state of the procedural texture */
  52721. render(useCameraPostProcess?: boolean): void;
  52722. /**
  52723. * Serializes this noise procedural texture
  52724. * @returns a serialized noise procedural texture object
  52725. */
  52726. serialize(): any;
  52727. /**
  52728. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  52729. * @param parsedTexture defines parsed texture data
  52730. * @param scene defines the current scene
  52731. * @param rootUrl defines the root URL containing noise procedural texture information
  52732. * @returns a parsed NoiseProceduralTexture
  52733. */
  52734. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  52735. }
  52736. }
  52737. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  52738. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  52739. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  52740. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52741. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  52742. }
  52743. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  52744. import { Nullable } from "babylonjs/types";
  52745. import { Scene } from "babylonjs/scene";
  52746. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  52747. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52748. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  52749. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52750. /**
  52751. * Raw cube texture where the raw buffers are passed in
  52752. */
  52753. export class RawCubeTexture extends CubeTexture {
  52754. /**
  52755. * Creates a cube texture where the raw buffers are passed in.
  52756. * @param scene defines the scene the texture is attached to
  52757. * @param data defines the array of data to use to create each face
  52758. * @param size defines the size of the textures
  52759. * @param format defines the format of the data
  52760. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  52761. * @param generateMipMaps defines if the engine should generate the mip levels
  52762. * @param invertY defines if data must be stored with Y axis inverted
  52763. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  52764. * @param compression defines the compression used (null by default)
  52765. */
  52766. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  52767. /**
  52768. * Updates the raw cube texture.
  52769. * @param data defines the data to store
  52770. * @param format defines the data format
  52771. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  52772. * @param invertY defines if data must be stored with Y axis inverted
  52773. * @param compression defines the compression used (null by default)
  52774. * @param level defines which level of the texture to update
  52775. */
  52776. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  52777. /**
  52778. * Updates a raw cube texture with RGBD encoded data.
  52779. * @param data defines the array of data [mipmap][face] to use to create each face
  52780. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  52781. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52782. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52783. * @returns a promsie that resolves when the operation is complete
  52784. */
  52785. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  52786. /**
  52787. * Clones the raw cube texture.
  52788. * @return a new cube texture
  52789. */
  52790. clone(): CubeTexture;
  52791. /** @hidden */
  52792. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52793. }
  52794. }
  52795. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  52796. import { Scene } from "babylonjs/scene";
  52797. import { Texture } from "babylonjs/Materials/Textures/texture";
  52798. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52799. /**
  52800. * Class used to store 3D textures containing user data
  52801. */
  52802. export class RawTexture3D extends Texture {
  52803. /** Gets or sets the texture format to use */
  52804. format: number;
  52805. private _engine;
  52806. /**
  52807. * Create a new RawTexture3D
  52808. * @param data defines the data of the texture
  52809. * @param width defines the width of the texture
  52810. * @param height defines the height of the texture
  52811. * @param depth defines the depth of the texture
  52812. * @param format defines the texture format to use
  52813. * @param scene defines the hosting scene
  52814. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  52815. * @param invertY defines if texture must be stored with Y axis inverted
  52816. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52817. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  52818. */
  52819. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  52820. /** Gets or sets the texture format to use */
  52821. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  52822. /**
  52823. * Update the texture with new data
  52824. * @param data defines the data to store in the texture
  52825. */
  52826. update(data: ArrayBufferView): void;
  52827. }
  52828. }
  52829. declare module "babylonjs/Materials/Textures/refractionTexture" {
  52830. import { Scene } from "babylonjs/scene";
  52831. import { Plane } from "babylonjs/Maths/math";
  52832. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52833. /**
  52834. * Creates a refraction texture used by refraction channel of the standard material.
  52835. * It is like a mirror but to see through a material.
  52836. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52837. */
  52838. export class RefractionTexture extends RenderTargetTexture {
  52839. /**
  52840. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  52841. * 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.
  52842. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52843. */
  52844. refractionPlane: Plane;
  52845. /**
  52846. * Define how deep under the surface we should see.
  52847. */
  52848. depth: number;
  52849. /**
  52850. * Creates a refraction texture used by refraction channel of the standard material.
  52851. * It is like a mirror but to see through a material.
  52852. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52853. * @param name Define the texture name
  52854. * @param size Define the size of the underlying texture
  52855. * @param scene Define the scene the refraction belongs to
  52856. * @param generateMipMaps Define if we need to generate mips level for the refraction
  52857. */
  52858. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  52859. /**
  52860. * Clone the refraction texture.
  52861. * @returns the cloned texture
  52862. */
  52863. clone(): RefractionTexture;
  52864. /**
  52865. * Serialize the texture to a JSON representation you could use in Parse later on
  52866. * @returns the serialized JSON representation
  52867. */
  52868. serialize(): any;
  52869. }
  52870. }
  52871. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  52872. import { Nullable } from "babylonjs/types";
  52873. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52874. import { Matrix } from "babylonjs/Maths/math";
  52875. import { Engine } from "babylonjs/Engines/engine";
  52876. import { Scene } from "babylonjs/scene";
  52877. /**
  52878. * Defines the options related to the creation of an HtmlElementTexture
  52879. */
  52880. export interface IHtmlElementTextureOptions {
  52881. /**
  52882. * Defines wether mip maps should be created or not.
  52883. */
  52884. generateMipMaps?: boolean;
  52885. /**
  52886. * Defines the sampling mode of the texture.
  52887. */
  52888. samplingMode?: number;
  52889. /**
  52890. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  52891. */
  52892. engine: Nullable<Engine>;
  52893. /**
  52894. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  52895. */
  52896. scene: Nullable<Scene>;
  52897. }
  52898. /**
  52899. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  52900. * To be as efficient as possible depending on your constraints nothing aside the first upload
  52901. * is automatically managed.
  52902. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  52903. * in your application.
  52904. *
  52905. * As the update is not automatic, you need to call them manually.
  52906. */
  52907. export class HtmlElementTexture extends BaseTexture {
  52908. /**
  52909. * The texture URL.
  52910. */
  52911. element: HTMLVideoElement | HTMLCanvasElement;
  52912. private static readonly DefaultOptions;
  52913. private _textureMatrix;
  52914. private _engine;
  52915. private _isVideo;
  52916. private _generateMipMaps;
  52917. private _samplingMode;
  52918. /**
  52919. * Instantiates a HtmlElementTexture from the following parameters.
  52920. *
  52921. * @param name Defines the name of the texture
  52922. * @param element Defines the video or canvas the texture is filled with
  52923. * @param options Defines the other none mandatory texture creation options
  52924. */
  52925. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  52926. private _createInternalTexture;
  52927. /**
  52928. * Returns the texture matrix used in most of the material.
  52929. */
  52930. getTextureMatrix(): Matrix;
  52931. /**
  52932. * Updates the content of the texture.
  52933. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  52934. */
  52935. update(invertY?: Nullable<boolean>): void;
  52936. }
  52937. }
  52938. declare module "babylonjs/Materials/Textures/index" {
  52939. export * from "babylonjs/Materials/Textures/baseTexture";
  52940. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  52941. export * from "babylonjs/Materials/Textures/cubeTexture";
  52942. export * from "babylonjs/Materials/Textures/dynamicTexture";
  52943. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  52944. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  52945. export * from "babylonjs/Materials/Textures/internalTexture";
  52946. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  52947. export * from "babylonjs/Materials/Textures/Loaders/index";
  52948. export * from "babylonjs/Materials/Textures/mirrorTexture";
  52949. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  52950. export * from "babylonjs/Materials/Textures/Procedurals/index";
  52951. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  52952. export * from "babylonjs/Materials/Textures/rawTexture";
  52953. export * from "babylonjs/Materials/Textures/rawTexture3D";
  52954. export * from "babylonjs/Materials/Textures/refractionTexture";
  52955. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  52956. export * from "babylonjs/Materials/Textures/texture";
  52957. export * from "babylonjs/Materials/Textures/videoTexture";
  52958. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  52959. }
  52960. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  52961. /**
  52962. * Enum used to define the target of a block
  52963. */
  52964. export enum NodeMaterialBlockTargets {
  52965. /** Vertex shader */
  52966. Vertex = 1,
  52967. /** Fragment shader */
  52968. Fragment = 2,
  52969. /** Vertex and Fragment */
  52970. VertexAndFragment = 3
  52971. }
  52972. }
  52973. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  52974. /**
  52975. * Defines the kind of connection point for node based material
  52976. */
  52977. export enum NodeMaterialBlockConnectionPointTypes {
  52978. /** Float */
  52979. Float = 1,
  52980. /** Int */
  52981. Int = 2,
  52982. /** Vector2 */
  52983. Vector2 = 4,
  52984. /** Vector3 */
  52985. Vector3 = 8,
  52986. /** Vector4 */
  52987. Vector4 = 16,
  52988. /** Color3 */
  52989. Color3 = 32,
  52990. /** Color4 */
  52991. Color4 = 64,
  52992. /** Matrix */
  52993. Matrix = 128,
  52994. /** Texture */
  52995. Texture = 256,
  52996. /** Texture3D */
  52997. Texture3D = 512,
  52998. /** Vector3 or Color3 */
  52999. Vector3OrColor3 = 40,
  53000. /** Vector3 or Vector4 */
  53001. Vector3OrVector4 = 24,
  53002. /** Vector4 or Color4 */
  53003. Vector4OrColor4 = 80,
  53004. /** Color3 or Color4 */
  53005. Color3OrColor4 = 96,
  53006. /** Vector3 or Color3 */
  53007. Vector3OrColor3OrVector4OrColor4 = 120,
  53008. /** Detect type based on connection */
  53009. AutoDetect = 1024,
  53010. /** Output type that will be defined by input type */
  53011. BasedOnInput = 2048,
  53012. /** Light */
  53013. Light = 4096
  53014. }
  53015. }
  53016. declare module "babylonjs/Materials/Node/nodeMaterialWellKnownValues" {
  53017. /**
  53018. * Enum used to define well known values e.g. values automatically provided by the system
  53019. */
  53020. export enum NodeMaterialWellKnownValues {
  53021. /** World */
  53022. World = 1,
  53023. /** View */
  53024. View = 2,
  53025. /** Projection */
  53026. Projection = 3,
  53027. /** ViewProjection */
  53028. ViewProjection = 4,
  53029. /** WorldView */
  53030. WorldView = 5,
  53031. /** WorldViewProjection */
  53032. WorldViewProjection = 6,
  53033. /** CameraPosition */
  53034. CameraPosition = 7,
  53035. /** Will be filled by the block itself */
  53036. Automatic = 8
  53037. }
  53038. }
  53039. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  53040. /**
  53041. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  53042. */
  53043. export enum NodeMaterialBlockConnectionPointMode {
  53044. /** Value is an uniform */
  53045. Uniform = 0,
  53046. /** Value is a mesh attribute */
  53047. Attribute = 1,
  53048. /** Value is a varying between vertex and fragment shaders */
  53049. Varying = 2,
  53050. /** Mode is undefined */
  53051. Undefined = 3
  53052. }
  53053. }
  53054. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  53055. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53056. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53057. /**
  53058. * Class used to store shared data between 2 NodeMaterialBuildState
  53059. */
  53060. export class NodeMaterialBuildStateSharedData {
  53061. /**
  53062. * Gets the list of emitted varyings
  53063. */
  53064. varyings: string[];
  53065. /**
  53066. * Gets the varying declaration string
  53067. */
  53068. varyingDeclaration: string;
  53069. /**
  53070. * Uniform connection points
  53071. */
  53072. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  53073. /**
  53074. * Bindable blocks (Blocks that need to set data to the effect)
  53075. */
  53076. bindableBlocks: NodeMaterialBlock[];
  53077. /**
  53078. * List of blocks that can provide a compilation fallback
  53079. */
  53080. blocksWithFallbacks: NodeMaterialBlock[];
  53081. /**
  53082. * List of blocks that can provide a define update
  53083. */
  53084. blocksWithDefines: NodeMaterialBlock[];
  53085. /**
  53086. * List of blocks that can provide a repeatable content
  53087. */
  53088. repeatableContentBlocks: NodeMaterialBlock[];
  53089. /**
  53090. * List of blocks that can provide a dynamic list of uniforms
  53091. */
  53092. dynamicUniformBlocks: NodeMaterialBlock[];
  53093. /**
  53094. * List of blocks that can block the isReady function for the material
  53095. */
  53096. blockingBlocks: NodeMaterialBlock[];
  53097. /**
  53098. * Build Id used to avoid multiple recompilations
  53099. */
  53100. buildId: number;
  53101. /** List of emitted variables */
  53102. variableNames: {
  53103. [key: string]: number;
  53104. };
  53105. /** List of emitted defines */
  53106. defineNames: {
  53107. [key: string]: number;
  53108. };
  53109. /** Should emit comments? */
  53110. emitComments: boolean;
  53111. /** Emit build activity */
  53112. verbose: boolean;
  53113. /**
  53114. * Gets the compilation hints emitted at compilation time
  53115. */
  53116. hints: {
  53117. needWorldViewMatrix: boolean;
  53118. needWorldViewProjectionMatrix: boolean;
  53119. needAlphaBlending: boolean;
  53120. needAlphaTesting: boolean;
  53121. };
  53122. /**
  53123. * List of compilation checks
  53124. */
  53125. checks: {
  53126. emitVertex: boolean;
  53127. emitFragment: boolean;
  53128. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  53129. };
  53130. /** Creates a new shared data */
  53131. constructor();
  53132. /**
  53133. * Emits console errors and exceptions if there is a failing check
  53134. */
  53135. emitErrors(): void;
  53136. }
  53137. }
  53138. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  53139. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53140. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53141. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53142. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  53143. import { Nullable } from "babylonjs/types";
  53144. /**
  53145. * Class used to store node based material build state
  53146. */
  53147. export class NodeMaterialBuildState {
  53148. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  53149. supportUniformBuffers: boolean;
  53150. /**
  53151. * Gets the list of emitted attributes
  53152. */
  53153. attributes: string[];
  53154. /**
  53155. * Gets the list of emitted uniforms
  53156. */
  53157. uniforms: string[];
  53158. /**
  53159. * Gets the list of emitted uniform buffers
  53160. */
  53161. uniformBuffers: string[];
  53162. /**
  53163. * Gets the list of emitted samplers
  53164. */
  53165. samplers: string[];
  53166. /**
  53167. * Gets the list of emitted functions
  53168. */
  53169. functions: {
  53170. [key: string]: string;
  53171. };
  53172. /**
  53173. * Gets the target of the compilation state
  53174. */
  53175. target: NodeMaterialBlockTargets;
  53176. /**
  53177. * Gets the list of emitted counters
  53178. */
  53179. counters: {
  53180. [key: string]: number;
  53181. };
  53182. /**
  53183. * Shared data between multiple NodeMaterialBuildState instances
  53184. */
  53185. sharedData: NodeMaterialBuildStateSharedData;
  53186. /** @hidden */
  53187. _vertexState: NodeMaterialBuildState;
  53188. private _attributeDeclaration;
  53189. private _uniformDeclaration;
  53190. private _samplerDeclaration;
  53191. private _varyingTransfer;
  53192. private _repeatableContentAnchorIndex;
  53193. /** @hidden */
  53194. _builtCompilationString: string;
  53195. /**
  53196. * Gets the emitted compilation strings
  53197. */
  53198. compilationString: string;
  53199. /**
  53200. * Finalize the compilation strings
  53201. * @param state defines the current compilation state
  53202. */
  53203. finalize(state: NodeMaterialBuildState): void;
  53204. /** @hidden */
  53205. readonly _repeatableContentAnchor: string;
  53206. /** @hidden */
  53207. _getFreeVariableName(prefix: string): string;
  53208. /** @hidden */
  53209. _getFreeDefineName(prefix: string): string;
  53210. /** @hidden */
  53211. _excludeVariableName(name: string): void;
  53212. /** @hidden */
  53213. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  53214. /** @hidden */
  53215. _emitFunction(name: string, code: string, comments: string): void;
  53216. /** @hidden */
  53217. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  53218. replaceStrings?: {
  53219. search: RegExp;
  53220. replace: string;
  53221. }[];
  53222. repeatKey?: string;
  53223. }): string;
  53224. /** @hidden */
  53225. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  53226. repeatKey?: string;
  53227. removeAttributes?: boolean;
  53228. removeUniforms?: boolean;
  53229. removeVaryings?: boolean;
  53230. removeIfDef?: boolean;
  53231. replaceStrings?: {
  53232. search: RegExp;
  53233. replace: string;
  53234. }[];
  53235. }, storeKey?: string): void;
  53236. /** @hidden */
  53237. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string, type?: Nullable<NodeMaterialBlockConnectionPointTypes>): void;
  53238. private _emitDefine;
  53239. /** @hidden */
  53240. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  53241. }
  53242. }
  53243. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  53244. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53245. /**
  53246. * Root class for all node material optimizers
  53247. */
  53248. export class NodeMaterialOptimizer {
  53249. /**
  53250. * Function used to optimize a NodeMaterial graph
  53251. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  53252. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  53253. */
  53254. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  53255. }
  53256. }
  53257. declare module "babylonjs/Materials/Node/Blocks/vector4TransformBlock" {
  53258. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53259. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53260. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53261. /**
  53262. * Block used to transform a vector4 with a matrix
  53263. */
  53264. export class Vector4TransformBlock extends NodeMaterialBlock {
  53265. /**
  53266. * Defines the value to use to complement Vector3 to transform it to a Vector4
  53267. */
  53268. complementW: number;
  53269. /**
  53270. * Creates a new Vector4TransformBlock
  53271. * @param name defines the block name
  53272. */
  53273. constructor(name: string);
  53274. /**
  53275. * Gets the current class name
  53276. * @returns the class name
  53277. */
  53278. getClassName(): string;
  53279. /**
  53280. * Gets the vector input
  53281. */
  53282. readonly vector: NodeMaterialConnectionPoint;
  53283. /**
  53284. * Gets the output component
  53285. */
  53286. readonly output: NodeMaterialConnectionPoint;
  53287. /**
  53288. * Gets the matrix transform input
  53289. */
  53290. readonly transform: NodeMaterialConnectionPoint;
  53291. protected _buildBlock(state: NodeMaterialBuildState): this;
  53292. }
  53293. }
  53294. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  53295. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53296. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53297. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53298. /**
  53299. * Block used to output the vertex position
  53300. */
  53301. export class VertexOutputBlock extends NodeMaterialBlock {
  53302. /**
  53303. * Creates a new VertexOutputBlock
  53304. * @param name defines the block name
  53305. */
  53306. constructor(name: string);
  53307. /**
  53308. * Gets the current class name
  53309. * @returns the class name
  53310. */
  53311. getClassName(): string;
  53312. /**
  53313. * Gets the vector input component
  53314. */
  53315. readonly vector: NodeMaterialConnectionPoint;
  53316. protected _buildBlock(state: NodeMaterialBuildState): this;
  53317. }
  53318. }
  53319. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  53320. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53321. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53322. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53323. /**
  53324. * Block used to output the final color
  53325. */
  53326. export class FragmentOutputBlock extends NodeMaterialBlock {
  53327. /**
  53328. * Gets or sets a boolean indicating if this block will output an alpha value
  53329. */
  53330. alphaBlendingEnabled: boolean;
  53331. /**
  53332. * Create a new FragmentOutputBlock
  53333. * @param name defines the block name
  53334. */
  53335. constructor(name: string);
  53336. /**
  53337. * Gets the current class name
  53338. * @returns the class name
  53339. */
  53340. getClassName(): string;
  53341. /**
  53342. * Gets the color input component
  53343. */
  53344. readonly color: NodeMaterialConnectionPoint;
  53345. protected _buildBlock(state: NodeMaterialBuildState): this;
  53346. }
  53347. }
  53348. declare module "babylonjs/Materials/Node/nodeMaterial" {
  53349. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53350. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53351. import { Scene } from "babylonjs/scene";
  53352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53353. import { Matrix } from "babylonjs/Maths/math";
  53354. import { Mesh } from "babylonjs/Meshes/mesh";
  53355. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53356. import { Observable } from "babylonjs/Misc/observable";
  53357. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53358. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53359. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  53360. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53361. import { Nullable } from "babylonjs/types";
  53362. /**
  53363. * Interface used to configure the node material editor
  53364. */
  53365. export interface INodeMaterialEditorOptions {
  53366. /** Define the URl to load node editor script */
  53367. editorURL?: string;
  53368. }
  53369. /** @hidden */
  53370. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  53371. /** BONES */
  53372. NUM_BONE_INFLUENCERS: number;
  53373. BonesPerMesh: number;
  53374. BONETEXTURE: boolean;
  53375. /** MORPH TARGETS */
  53376. MORPHTARGETS: boolean;
  53377. MORPHTARGETS_NORMAL: boolean;
  53378. MORPHTARGETS_TANGENT: boolean;
  53379. MORPHTARGETS_UV: boolean;
  53380. NUM_MORPH_INFLUENCERS: number;
  53381. /** IMAGE PROCESSING */
  53382. IMAGEPROCESSING: boolean;
  53383. VIGNETTE: boolean;
  53384. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53385. VIGNETTEBLENDMODEOPAQUE: boolean;
  53386. TONEMAPPING: boolean;
  53387. TONEMAPPING_ACES: boolean;
  53388. CONTRAST: boolean;
  53389. EXPOSURE: boolean;
  53390. COLORCURVES: boolean;
  53391. COLORGRADING: boolean;
  53392. COLORGRADING3D: boolean;
  53393. SAMPLER3DGREENDEPTH: boolean;
  53394. SAMPLER3DBGRMAP: boolean;
  53395. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53396. constructor();
  53397. setValue(name: string, value: boolean): void;
  53398. }
  53399. /**
  53400. * Class used to configure NodeMaterial
  53401. */
  53402. export interface INodeMaterialOptions {
  53403. /**
  53404. * Defines if blocks should emit comments
  53405. */
  53406. emitComments: boolean;
  53407. }
  53408. /**
  53409. * Class used to create a node based material built by assembling shader blocks
  53410. */
  53411. export class NodeMaterial extends PushMaterial {
  53412. private _options;
  53413. private _vertexCompilationState;
  53414. private _fragmentCompilationState;
  53415. private _sharedData;
  53416. private _buildId;
  53417. private _buildWasSuccessful;
  53418. private _cachedWorldViewMatrix;
  53419. private _cachedWorldViewProjectionMatrix;
  53420. private _textureConnectionPoints;
  53421. private _optimizers;
  53422. /** Define the URl to load node editor script */
  53423. static EditorURL: string;
  53424. private BJSNODEMATERIALEDITOR;
  53425. /** Get the inspector from bundle or global */
  53426. private _getGlobalNodeMaterialEditor;
  53427. /**
  53428. * Defines the maximum number of lights that can be used in the material
  53429. */
  53430. maxSimultaneousLights: number;
  53431. /**
  53432. * Observable raised when the material is built
  53433. */
  53434. onBuildObservable: Observable<NodeMaterial>;
  53435. /**
  53436. * Gets or sets the root nodes of the material vertex shader
  53437. */
  53438. _vertexOutputNodes: NodeMaterialBlock[];
  53439. /**
  53440. * Gets or sets the root nodes of the material fragment (pixel) shader
  53441. */
  53442. _fragmentOutputNodes: NodeMaterialBlock[];
  53443. /** Gets or sets options to control the node material overall behavior */
  53444. options: INodeMaterialOptions;
  53445. /**
  53446. * Default configuration related to image processing available in the standard Material.
  53447. */
  53448. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53449. /**
  53450. * Gets the image processing configuration used either in this material.
  53451. */
  53452. /**
  53453. * Sets the Default image processing configuration used either in the this material.
  53454. *
  53455. * If sets to null, the scene one is in use.
  53456. */
  53457. imageProcessingConfiguration: ImageProcessingConfiguration;
  53458. /**
  53459. * Create a new node based material
  53460. * @param name defines the material name
  53461. * @param scene defines the hosting scene
  53462. * @param options defines creation option
  53463. */
  53464. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  53465. /**
  53466. * Gets the current class name of the material e.g. "NodeMaterial"
  53467. * @returns the class name
  53468. */
  53469. getClassName(): string;
  53470. /**
  53471. * Keep track of the image processing observer to allow dispose and replace.
  53472. */
  53473. private _imageProcessingObserver;
  53474. /**
  53475. * Attaches a new image processing configuration to the Standard Material.
  53476. * @param configuration
  53477. */
  53478. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53479. /**
  53480. * Adds a new optimizer to the list of optimizers
  53481. * @param optimizer defines the optimizers to add
  53482. * @returns the current material
  53483. */
  53484. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53485. /**
  53486. * Remove an optimizer from the list of optimizers
  53487. * @param optimizer defines the optimizers to remove
  53488. * @returns the current material
  53489. */
  53490. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  53491. /**
  53492. * Add a new block to the list of output nodes
  53493. * @param node defines the node to add
  53494. * @returns the current material
  53495. */
  53496. addOutputNode(node: NodeMaterialBlock): this;
  53497. /**
  53498. * Remove a block from the list of root nodes
  53499. * @param node defines the node to remove
  53500. * @returns the current material
  53501. */
  53502. removeOutputNode(node: NodeMaterialBlock): this;
  53503. private _addVertexOutputNode;
  53504. private _removeVertexOutputNode;
  53505. private _addFragmentOutputNode;
  53506. private _removeFragmentOutputNode;
  53507. /**
  53508. * Specifies if the material will require alpha blending
  53509. * @returns a boolean specifying if alpha blending is needed
  53510. */
  53511. needAlphaBlending(): boolean;
  53512. /**
  53513. * Specifies if this material should be rendered in alpha test mode
  53514. * @returns a boolean specifying if an alpha test is needed.
  53515. */
  53516. needAlphaTesting(): boolean;
  53517. private _initializeBlock;
  53518. private _resetDualBlocks;
  53519. /**
  53520. * Build the material and generates the inner effect
  53521. * @param verbose defines if the build should log activity
  53522. */
  53523. build(verbose?: boolean): void;
  53524. /**
  53525. * Runs an otpimization phase to try to improve the shader code
  53526. */
  53527. optimize(): void;
  53528. private _prepareDefinesForAttributes;
  53529. /**
  53530. * Get if the submesh is ready to be used and all its information available.
  53531. * Child classes can use it to update shaders
  53532. * @param mesh defines the mesh to check
  53533. * @param subMesh defines which submesh to check
  53534. * @param useInstances specifies that instances should be used
  53535. * @returns a boolean indicating that the submesh is ready or not
  53536. */
  53537. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53538. /**
  53539. * Binds the world matrix to the material
  53540. * @param world defines the world transformation matrix
  53541. */
  53542. bindOnlyWorldMatrix(world: Matrix): void;
  53543. /**
  53544. * Binds the submesh to this material by preparing the effect and shader to draw
  53545. * @param world defines the world transformation matrix
  53546. * @param mesh defines the mesh containing the submesh
  53547. * @param subMesh defines the submesh to bind the material to
  53548. */
  53549. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53550. /**
  53551. * Gets the active textures from the material
  53552. * @returns an array of textures
  53553. */
  53554. getActiveTextures(): BaseTexture[];
  53555. /**
  53556. * Specifies if the material uses a texture
  53557. * @param texture defines the texture to check against the material
  53558. * @returns a boolean specifying if the material uses the texture
  53559. */
  53560. hasTexture(texture: BaseTexture): boolean;
  53561. /**
  53562. * Disposes the material
  53563. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  53564. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  53565. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  53566. */
  53567. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  53568. /** Creates the node editor window. */
  53569. private _createNodeEditor;
  53570. /**
  53571. * Launch the node material editor
  53572. * @param config Define the configuration of the editor
  53573. * @return a promise fulfilled when the node editor is visible
  53574. */
  53575. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  53576. /**
  53577. * Clear the current material
  53578. */
  53579. clear(): void;
  53580. /**
  53581. * Clear the current material and set it to a default state
  53582. */
  53583. setToDefault(): void;
  53584. }
  53585. }
  53586. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  53587. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53588. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53589. import { Nullable } from "babylonjs/types";
  53590. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53591. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53592. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53593. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53594. import { Mesh } from "babylonjs/Meshes/mesh";
  53595. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53596. /**
  53597. * Defines a block that can be used inside a node based material
  53598. */
  53599. export class NodeMaterialBlock {
  53600. private _buildId;
  53601. private _target;
  53602. private _isFinalMerger;
  53603. /** @hidden */
  53604. _inputs: NodeMaterialConnectionPoint[];
  53605. /** @hidden */
  53606. _outputs: NodeMaterialConnectionPoint[];
  53607. /**
  53608. * Gets or sets the name of the block
  53609. */
  53610. name: string;
  53611. /**
  53612. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  53613. */
  53614. readonly isFinalMerger: boolean;
  53615. /**
  53616. * Gets or sets the build Id
  53617. */
  53618. buildId: number;
  53619. /**
  53620. * Gets or sets the target of the block
  53621. */
  53622. target: NodeMaterialBlockTargets;
  53623. /**
  53624. * Gets the list of input points
  53625. */
  53626. readonly inputs: NodeMaterialConnectionPoint[];
  53627. /** Gets the list of output points */
  53628. readonly outputs: NodeMaterialConnectionPoint[];
  53629. /**
  53630. * Find an input by its name
  53631. * @param name defines the name of the input to look for
  53632. * @returns the input or null if not found
  53633. */
  53634. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53635. /**
  53636. * Find an output by its name
  53637. * @param name defines the name of the outputto look for
  53638. * @returns the output or null if not found
  53639. */
  53640. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  53641. /**
  53642. * Creates a new NodeMaterialBlock
  53643. * @param name defines the block name
  53644. * @param target defines the target of that block (Vertex by default)
  53645. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  53646. */
  53647. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  53648. /**
  53649. * Initialize the block and prepare the context for build
  53650. * @param state defines the state that will be used for the build
  53651. */
  53652. initialize(state: NodeMaterialBuildState): void;
  53653. /**
  53654. * Bind data to effect. Will only be called for blocks with isBindable === true
  53655. * @param effect defines the effect to bind data to
  53656. * @param nodeMaterial defines the hosting NodeMaterial
  53657. * @param mesh defines the mesh that will be rendered
  53658. */
  53659. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53660. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  53661. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  53662. protected _writeFloat(value: number): string;
  53663. /**
  53664. * Gets the current class name e.g. "NodeMaterialBlock"
  53665. * @returns the class name
  53666. */
  53667. getClassName(): string;
  53668. /**
  53669. * Register a new input. Must be called inside a block constructor
  53670. * @param name defines the connection point name
  53671. * @param type defines the connection point type
  53672. * @param isOptional defines a boolean indicating that this input can be omitted
  53673. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  53674. * @returns the current block
  53675. */
  53676. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  53677. /**
  53678. * Register a new output. Must be called inside a block constructor
  53679. * @param name defines the connection point name
  53680. * @param type defines the connection point type
  53681. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  53682. * @returns the current block
  53683. */
  53684. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  53685. /**
  53686. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  53687. * @param forOutput defines an optional connection point to check compatibility with
  53688. * @returns the first available input or null
  53689. */
  53690. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  53691. /**
  53692. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  53693. * @param forBlock defines an optional block to check compatibility with
  53694. * @returns the first available input or null
  53695. */
  53696. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  53697. /**
  53698. * Connect current block with another block
  53699. * @param other defines the block to connect with
  53700. * @param options define the various options to help pick the right connections
  53701. * @returns the current block
  53702. */
  53703. connectTo(other: NodeMaterialBlock, options?: {
  53704. input?: string;
  53705. output?: string;
  53706. outputSwizzle?: string;
  53707. }): this | undefined;
  53708. protected _buildBlock(state: NodeMaterialBuildState): void;
  53709. /**
  53710. * Add uniforms, samplers and uniform buffers at compilation time
  53711. * @param state defines the state to update
  53712. * @param nodeMaterial defines the node material requesting the update
  53713. * @param defines defines the material defines to update
  53714. */
  53715. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53716. /**
  53717. * Add potential fallbacks if shader compilation fails
  53718. * @param mesh defines the mesh to be rendered
  53719. * @param fallbacks defines the current prioritized list of fallbacks
  53720. */
  53721. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53722. /**
  53723. * Update defines for shader compilation
  53724. * @param mesh defines the mesh to be rendered
  53725. * @param nodeMaterial defines the node material requesting the update
  53726. * @param defines defines the material defines to update
  53727. * @param useInstances specifies that instances should be used
  53728. */
  53729. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53730. /**
  53731. * Lets the block try to connect some inputs automatically
  53732. */
  53733. autoConfigure(): void;
  53734. /**
  53735. * Function called when a block is declared as repeatable content generator
  53736. * @param vertexShaderState defines the current compilation state for the vertex shader
  53737. * @param fragmentShaderState defines the current compilation state for the fragment shader
  53738. * @param mesh defines the mesh to be rendered
  53739. * @param defines defines the material defines to update
  53740. */
  53741. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53742. /**
  53743. * Checks if the block is ready
  53744. * @param mesh defines the mesh to be rendered
  53745. * @param nodeMaterial defines the node material requesting the update
  53746. * @param defines defines the material defines to update
  53747. * @param useInstances specifies that instances should be used
  53748. * @returns true if the block is ready
  53749. */
  53750. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  53751. /**
  53752. * Compile the current node and generate the shader code
  53753. * @param state defines the current compilation state (uniforms, samplers, current string)
  53754. * @returns the current block
  53755. */
  53756. build(state: NodeMaterialBuildState): this | undefined;
  53757. }
  53758. }
  53759. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  53760. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53761. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53762. import { Nullable } from "babylonjs/types";
  53763. import { Effect } from "babylonjs/Materials/effect";
  53764. import { NodeMaterialWellKnownValues } from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  53765. import { Scene } from "babylonjs/scene";
  53766. import { Matrix } from "babylonjs/Maths/math";
  53767. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53768. /**
  53769. * Defines a connection point for a block
  53770. */
  53771. export class NodeMaterialConnectionPoint {
  53772. /** @hidden */
  53773. _ownerBlock: NodeMaterialBlock;
  53774. /** @hidden */
  53775. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53776. private _associatedVariableName;
  53777. private _endpoints;
  53778. private _storedValue;
  53779. private _valueCallback;
  53780. private _mode;
  53781. /** @hidden */
  53782. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  53783. /** @hidden */
  53784. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  53785. /** @hidden */
  53786. _needToEmitVarying: boolean;
  53787. /** @hidden */
  53788. _forceUniformInVertexShaderOnly: boolean;
  53789. private _type;
  53790. /**
  53791. * Gets or sets the connection point type (default is float)
  53792. */
  53793. type: NodeMaterialBlockConnectionPointTypes;
  53794. /**
  53795. * Gets or sets the connection point name
  53796. */
  53797. name: string;
  53798. /**
  53799. * Gets or sets the swizzle to apply to this connection point when reading or writing
  53800. */
  53801. swizzle: string;
  53802. /**
  53803. * Gets or sets a boolean indicating that this connection point can be omitted
  53804. */
  53805. isOptional: boolean;
  53806. /**
  53807. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  53808. */
  53809. define: string;
  53810. /** Gets or sets the target of that connection point */
  53811. target: NodeMaterialBlockTargets;
  53812. /**
  53813. * Gets or sets the value of that point.
  53814. * Please note that this value will be ignored if valueCallback is defined
  53815. */
  53816. value: any;
  53817. /**
  53818. * Gets or sets a callback used to get the value of that point.
  53819. * Please note that setting this value will force the connection point to ignore the value property
  53820. */
  53821. valueCallback: () => any;
  53822. /**
  53823. * Gets or sets the associated variable name in the shader
  53824. */
  53825. associatedVariableName: string;
  53826. /**
  53827. * Gets a boolean indicating that this connection point not defined yet
  53828. */
  53829. readonly isUndefined: boolean;
  53830. /**
  53831. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53832. * In this case the connection point name must be the name of the uniform to use.
  53833. * Can only be set on inputs
  53834. */
  53835. isUniform: boolean;
  53836. /**
  53837. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53838. * In this case the connection point name must be the name of the attribute to use
  53839. * Can only be set on inputs
  53840. */
  53841. isAttribute: boolean;
  53842. /**
  53843. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53844. * Can only be set on exit points
  53845. */
  53846. isVarying: boolean;
  53847. /** Get the other side of the connection (if any) */
  53848. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53849. /** Get the block that owns this connection point */
  53850. readonly ownerBlock: NodeMaterialBlock;
  53851. /** Get the block connected on the other side of this connection (if any) */
  53852. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  53853. /** Get the block connected on the endpoints of this connection (if any) */
  53854. readonly connectedBlocks: Array<NodeMaterialBlock>;
  53855. /**
  53856. * Creates a new connection point
  53857. * @param name defines the connection point name
  53858. * @param ownerBlock defines the block hosting this connection point
  53859. */
  53860. constructor(name: string, ownerBlock: NodeMaterialBlock);
  53861. /**
  53862. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  53863. * @returns the class name
  53864. */
  53865. getClassName(): string;
  53866. /**
  53867. * Set the source of this connection point to a vertex attribute
  53868. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  53869. * @returns the current connection point
  53870. */
  53871. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  53872. /**
  53873. * Set the source of this connection point to a well known value
  53874. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  53875. * @returns the current connection point
  53876. */
  53877. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  53878. /**
  53879. * Gets a boolean indicating that the current connection point is a well known value
  53880. */
  53881. readonly isWellKnownValue: boolean;
  53882. /**
  53883. * Gets or sets the current well known value or null if not defined as well know value
  53884. */
  53885. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  53886. private _getTypeLength;
  53887. /**
  53888. * Gets an boolean indicating if the current point can be connected to another point
  53889. * @param connectionPoint defines the other connection point
  53890. * @returns true if the connection is possible
  53891. */
  53892. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  53893. /**
  53894. * Connect this point to another connection point
  53895. * @param connectionPoint defines the other connection point
  53896. * @returns the current connection point
  53897. */
  53898. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53899. /**
  53900. * Disconnect this point from one of his endpoint
  53901. * @param endpoint defines the other connection point
  53902. * @returns the current connection point
  53903. */
  53904. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53905. /**
  53906. * When connection point is an uniform, this function will send its value to the effect
  53907. * @param effect defines the effect to transmit value to
  53908. * @param world defines the world matrix
  53909. * @param worldView defines the worldxview matrix
  53910. * @param worldViewProjection defines the worldxviewxprojection matrix
  53911. */
  53912. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53913. /**
  53914. * When connection point is an uniform, this function will send its value to the effect
  53915. * @param effect defines the effect to transmit value to
  53916. * @param scene defines the hosting scene
  53917. */
  53918. transmit(effect: Effect, scene: Scene): void;
  53919. }
  53920. }
  53921. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  53922. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53923. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53924. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53925. import { Mesh } from "babylonjs/Meshes/mesh";
  53926. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53927. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53928. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53929. /**
  53930. * Block used to add support for vertex skinning (bones)
  53931. */
  53932. export class BonesBlock extends NodeMaterialBlock {
  53933. /**
  53934. * Creates a new BonesBlock
  53935. * @param name defines the block name
  53936. */
  53937. constructor(name: string);
  53938. /**
  53939. * Initialize the block and prepare the context for build
  53940. * @param state defines the state that will be used for the build
  53941. */
  53942. initialize(state: NodeMaterialBuildState): void;
  53943. /**
  53944. * Gets the current class name
  53945. * @returns the class name
  53946. */
  53947. getClassName(): string;
  53948. /**
  53949. * Gets the matrix indices input component
  53950. */
  53951. readonly matricesIndices: NodeMaterialConnectionPoint;
  53952. /**
  53953. * Gets the matrix weights input component
  53954. */
  53955. readonly matricesWeights: NodeMaterialConnectionPoint;
  53956. /**
  53957. * Gets the extra matrix indices input component
  53958. */
  53959. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  53960. /**
  53961. * Gets the extra matrix weights input component
  53962. */
  53963. readonly matricesWeightsExtra: 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. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53974. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53975. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53976. protected _buildBlock(state: NodeMaterialBuildState): this;
  53977. }
  53978. }
  53979. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  53980. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53981. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53982. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53984. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53985. /**
  53986. * Block used to add support for instances
  53987. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  53988. */
  53989. export class InstancesBlock extends NodeMaterialBlock {
  53990. /**
  53991. * Creates a new InstancesBlock
  53992. * @param name defines the block name
  53993. */
  53994. constructor(name: string);
  53995. /**
  53996. * Gets the current class name
  53997. * @returns the class name
  53998. */
  53999. getClassName(): string;
  54000. /**
  54001. * Gets the first world row input component
  54002. */
  54003. readonly world0: NodeMaterialConnectionPoint;
  54004. /**
  54005. * Gets the second world row input component
  54006. */
  54007. readonly world1: NodeMaterialConnectionPoint;
  54008. /**
  54009. * Gets the third world row input component
  54010. */
  54011. readonly world2: NodeMaterialConnectionPoint;
  54012. /**
  54013. * Gets the forth world row input component
  54014. */
  54015. readonly world3: NodeMaterialConnectionPoint;
  54016. /**
  54017. * Gets the world input component
  54018. */
  54019. readonly world: NodeMaterialConnectionPoint;
  54020. /**
  54021. * Gets the output component
  54022. */
  54023. readonly output: NodeMaterialConnectionPoint;
  54024. autoConfigure(): void;
  54025. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  54026. protected _buildBlock(state: NodeMaterialBuildState): this;
  54027. }
  54028. }
  54029. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  54030. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54031. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54032. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54033. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54034. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54035. import { Effect } from "babylonjs/Materials/effect";
  54036. import { Mesh } from "babylonjs/Meshes/mesh";
  54037. /**
  54038. * Block used to add morph targets support to vertex shader
  54039. */
  54040. export class MorphTargetsBlock extends NodeMaterialBlock {
  54041. private _repeatableContentAnchor;
  54042. private _repeatebleContentGenerated;
  54043. /**
  54044. * Create a new MorphTargetsBlock
  54045. * @param name defines the block name
  54046. */
  54047. constructor(name: string);
  54048. /**
  54049. * Gets the current class name
  54050. * @returns the class name
  54051. */
  54052. getClassName(): string;
  54053. /**
  54054. * Gets the position input component
  54055. */
  54056. readonly position: NodeMaterialConnectionPoint;
  54057. /**
  54058. * Gets the normal input component
  54059. */
  54060. readonly normal: NodeMaterialConnectionPoint;
  54061. /**
  54062. * Gets the tangent input component
  54063. */
  54064. readonly tangent: NodeMaterialConnectionPoint;
  54065. /**
  54066. * Gets the tangent input component
  54067. */
  54068. readonly uv: NodeMaterialConnectionPoint;
  54069. /**
  54070. * Gets the position output component
  54071. */
  54072. readonly positionOutput: NodeMaterialConnectionPoint;
  54073. /**
  54074. * Gets the normal output component
  54075. */
  54076. readonly normalOutput: NodeMaterialConnectionPoint;
  54077. /**
  54078. * Gets the tangent output component
  54079. */
  54080. readonly tangentOutput: NodeMaterialConnectionPoint;
  54081. /**
  54082. * Gets the tangent output component
  54083. */
  54084. readonly uvOutput: NodeMaterialConnectionPoint;
  54085. initialize(state: NodeMaterialBuildState): void;
  54086. autoConfigure(): void;
  54087. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54088. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54089. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  54090. protected _buildBlock(state: NodeMaterialBuildState): this;
  54091. }
  54092. }
  54093. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  54094. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  54095. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  54096. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  54097. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  54098. }
  54099. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  54100. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54101. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54102. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54103. /**
  54104. * Block used to add an alpha test in the fragment shader
  54105. */
  54106. export class AlphaTestBlock extends NodeMaterialBlock {
  54107. /**
  54108. * Gets or sets the alpha value where alpha testing happens
  54109. */
  54110. alphaCutOff: number;
  54111. /**
  54112. * Create a new AlphaTestBlock
  54113. * @param name defines the block name
  54114. */
  54115. constructor(name: string);
  54116. /**
  54117. * Gets the current class name
  54118. * @returns the class name
  54119. */
  54120. getClassName(): string;
  54121. /**
  54122. * Gets the color input component
  54123. */
  54124. readonly color: NodeMaterialConnectionPoint;
  54125. protected _buildBlock(state: NodeMaterialBuildState): this;
  54126. }
  54127. }
  54128. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock" {
  54129. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54130. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54131. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54132. /**
  54133. * Block used to create a Color4 out of 4 inputs (one for each component)
  54134. */
  54135. export class RGBAMergerBlock extends NodeMaterialBlock {
  54136. /**
  54137. * Create a new RGBAMergerBlock
  54138. * @param name defines the block name
  54139. */
  54140. constructor(name: string);
  54141. /**
  54142. * Gets the current class name
  54143. * @returns the class name
  54144. */
  54145. getClassName(): string;
  54146. /**
  54147. * Gets the R input component
  54148. */
  54149. readonly r: NodeMaterialConnectionPoint;
  54150. /**
  54151. * Gets the G input component
  54152. */
  54153. readonly g: NodeMaterialConnectionPoint;
  54154. /**
  54155. * Gets the B input component
  54156. */
  54157. readonly b: NodeMaterialConnectionPoint;
  54158. /**
  54159. * Gets the RGB input component
  54160. */
  54161. readonly rgb: NodeMaterialConnectionPoint;
  54162. /**
  54163. * Gets the R input component
  54164. */
  54165. readonly a: NodeMaterialConnectionPoint;
  54166. /**
  54167. * Gets the output component
  54168. */
  54169. readonly output: NodeMaterialConnectionPoint;
  54170. protected _buildBlock(state: NodeMaterialBuildState): this;
  54171. }
  54172. }
  54173. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock" {
  54174. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54175. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54176. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54177. /**
  54178. * Block used to create a Color3 out of 3 inputs (one for each component)
  54179. */
  54180. export class RGBMergerBlock extends NodeMaterialBlock {
  54181. /**
  54182. * Create a new RGBMergerBlock
  54183. * @param name defines the block name
  54184. */
  54185. constructor(name: string);
  54186. /**
  54187. * Gets the current class name
  54188. * @returns the class name
  54189. */
  54190. getClassName(): string;
  54191. /**
  54192. * Gets the R component input
  54193. */
  54194. readonly r: NodeMaterialConnectionPoint;
  54195. /**
  54196. * Gets the G component input
  54197. */
  54198. readonly g: NodeMaterialConnectionPoint;
  54199. /**
  54200. * Gets the B component input
  54201. */
  54202. readonly b: NodeMaterialConnectionPoint;
  54203. /**
  54204. * Gets the output component
  54205. */
  54206. readonly output: NodeMaterialConnectionPoint;
  54207. protected _buildBlock(state: NodeMaterialBuildState): this;
  54208. }
  54209. }
  54210. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock" {
  54211. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54212. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54213. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54214. /**
  54215. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  54216. */
  54217. export class RGBASplitterBlock extends NodeMaterialBlock {
  54218. /**
  54219. * Create a new RGBASplitterBlock
  54220. * @param name defines the block name
  54221. */
  54222. constructor(name: string);
  54223. /**
  54224. * Gets the current class name
  54225. * @returns the class name
  54226. */
  54227. getClassName(): string;
  54228. /**
  54229. * Gets the input component
  54230. */
  54231. readonly input: NodeMaterialConnectionPoint;
  54232. protected _buildBlock(state: NodeMaterialBuildState): this;
  54233. }
  54234. }
  54235. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock" {
  54236. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54237. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54238. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54239. /**
  54240. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  54241. */
  54242. export class RGBSplitterBlock extends NodeMaterialBlock {
  54243. /**
  54244. * Create a new RGBSplitterBlock
  54245. * @param name defines the block name
  54246. */
  54247. constructor(name: string);
  54248. /**
  54249. * Gets the current class name
  54250. * @returns the class name
  54251. */
  54252. getClassName(): string;
  54253. /**
  54254. * Gets the input component
  54255. */
  54256. readonly input: NodeMaterialConnectionPoint;
  54257. protected _buildBlock(state: NodeMaterialBuildState): this;
  54258. }
  54259. }
  54260. declare module "babylonjs/Materials/Node/Blocks/Fragment/textureBlock" {
  54261. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54262. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54263. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54264. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54265. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54266. /**
  54267. * Block used to read a texture from a sampler
  54268. */
  54269. export class TextureBlock extends NodeMaterialBlock {
  54270. private _defineName;
  54271. /**
  54272. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  54273. */
  54274. autoConnectTextureMatrix: boolean;
  54275. /**
  54276. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  54277. */
  54278. autoSelectUV: boolean;
  54279. /**
  54280. * Create a new TextureBlock
  54281. * @param name defines the block name
  54282. */
  54283. constructor(name: string);
  54284. /**
  54285. * Gets the current class name
  54286. * @returns the class name
  54287. */
  54288. getClassName(): string;
  54289. /**
  54290. * Gets the uv input component
  54291. */
  54292. readonly uv: NodeMaterialConnectionPoint;
  54293. /**
  54294. * Gets the texture information input component
  54295. */
  54296. readonly textureInfo: NodeMaterialConnectionPoint;
  54297. /**
  54298. * Gets the transformed uv input component
  54299. */
  54300. readonly transformedUV: NodeMaterialConnectionPoint;
  54301. /**
  54302. * Gets the texture input component
  54303. */
  54304. readonly texture: NodeMaterialConnectionPoint;
  54305. /**
  54306. * Gets the texture transform input component
  54307. */
  54308. readonly textureTransform: NodeMaterialConnectionPoint;
  54309. /**
  54310. * Gets the output component
  54311. */
  54312. readonly output: NodeMaterialConnectionPoint;
  54313. autoConfigure(): void;
  54314. initialize(state: NodeMaterialBuildState): void;
  54315. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54316. isReady(): boolean;
  54317. private _injectVertexCode;
  54318. protected _buildBlock(state: NodeMaterialBuildState): this;
  54319. }
  54320. }
  54321. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  54322. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54323. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54324. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54325. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54326. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54327. import { Effect } from "babylonjs/Materials/effect";
  54328. import { Mesh } from "babylonjs/Meshes/mesh";
  54329. /**
  54330. * Block used to add image processing support to fragment shader
  54331. */
  54332. export class ImageProcessingBlock extends NodeMaterialBlock {
  54333. /**
  54334. * Create a new ImageProcessingBlock
  54335. * @param name defines the block name
  54336. */
  54337. constructor(name: string);
  54338. /**
  54339. * Gets the current class name
  54340. * @returns the class name
  54341. */
  54342. getClassName(): string;
  54343. /**
  54344. * Gets the color input component
  54345. */
  54346. readonly color: NodeMaterialConnectionPoint;
  54347. /**
  54348. * Gets the output component
  54349. */
  54350. readonly output: NodeMaterialConnectionPoint;
  54351. /**
  54352. * Initialize the block and prepare the context for build
  54353. * @param state defines the state that will be used for the build
  54354. */
  54355. initialize(state: NodeMaterialBuildState): void;
  54356. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  54357. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54358. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54359. protected _buildBlock(state: NodeMaterialBuildState): this;
  54360. }
  54361. }
  54362. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  54363. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  54364. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  54365. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock";
  54366. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock";
  54367. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock";
  54368. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock";
  54369. export * from "babylonjs/Materials/Node/Blocks/Fragment/textureBlock";
  54370. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  54371. }
  54372. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  54373. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54374. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54375. import { Mesh } from "babylonjs/Meshes/mesh";
  54376. import { Effect } from "babylonjs/Materials/effect";
  54377. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54378. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54379. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54380. /**
  54381. * Block used to add support for scene fog
  54382. */
  54383. export class FogBlock extends NodeMaterialBlock {
  54384. /**
  54385. * Create a new FogBlock
  54386. * @param name defines the block name
  54387. */
  54388. constructor(name: string);
  54389. /**
  54390. * Gets the current class name
  54391. * @returns the class name
  54392. */
  54393. getClassName(): string;
  54394. /**
  54395. * Gets the world position input component
  54396. */
  54397. readonly worldPosition: NodeMaterialConnectionPoint;
  54398. /**
  54399. * Gets the view input component
  54400. */
  54401. readonly view: NodeMaterialConnectionPoint;
  54402. /**
  54403. * Gets the color input component
  54404. */
  54405. readonly color: NodeMaterialConnectionPoint;
  54406. /**
  54407. * Gets the fog color input component
  54408. */
  54409. readonly fogColor: NodeMaterialConnectionPoint;
  54410. /**
  54411. * Gets the for parameter input component
  54412. */
  54413. readonly fogParameters: NodeMaterialConnectionPoint;
  54414. /**
  54415. * Gets the output component
  54416. */
  54417. readonly output: NodeMaterialConnectionPoint;
  54418. autoConfigure(): void;
  54419. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54420. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54421. protected _buildBlock(state: NodeMaterialBuildState): this;
  54422. }
  54423. }
  54424. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  54425. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54426. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54427. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54428. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54429. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  54430. import { Effect } from "babylonjs/Materials/effect";
  54431. import { Mesh } from "babylonjs/Meshes/mesh";
  54432. /**
  54433. * Block used to add light in the fragment shader
  54434. */
  54435. export class LightBlock extends NodeMaterialBlock {
  54436. private _lightId;
  54437. /**
  54438. * Create a new LightBlock
  54439. * @param name defines the block name
  54440. */
  54441. constructor(name: string);
  54442. /**
  54443. * Gets the current class name
  54444. * @returns the class name
  54445. */
  54446. getClassName(): string;
  54447. /**
  54448. * Gets the world position input component
  54449. */
  54450. readonly worldPosition: NodeMaterialConnectionPoint;
  54451. /**
  54452. * Gets the world normal input component
  54453. */
  54454. readonly worldNormal: NodeMaterialConnectionPoint;
  54455. /**
  54456. * Gets the light input component.
  54457. * If not defined, all lights will be considered
  54458. */
  54459. readonly light: NodeMaterialConnectionPoint;
  54460. /**
  54461. * Gets the camera (or eye) position component
  54462. */
  54463. readonly cameraPosition: NodeMaterialConnectionPoint;
  54464. /**
  54465. * Gets the diffuse output component
  54466. */
  54467. readonly diffuseOutput: NodeMaterialConnectionPoint;
  54468. /**
  54469. * Gets the specular output component
  54470. */
  54471. readonly specularOutput: NodeMaterialConnectionPoint;
  54472. autoConfigure(): void;
  54473. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54474. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  54475. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  54476. private _injectVertexCode;
  54477. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  54478. }
  54479. }
  54480. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  54481. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  54482. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  54483. }
  54484. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  54485. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54486. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54487. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54488. /**
  54489. * Block used to multiply 2 values
  54490. */
  54491. export class MultiplyBlock extends NodeMaterialBlock {
  54492. /**
  54493. * Creates a new MultiplyBlock
  54494. * @param name defines the block name
  54495. */
  54496. constructor(name: string);
  54497. /**
  54498. * Gets the current class name
  54499. * @returns the class name
  54500. */
  54501. getClassName(): string;
  54502. /**
  54503. * Gets the left operand input component
  54504. */
  54505. readonly left: NodeMaterialConnectionPoint;
  54506. /**
  54507. * Gets the right operand input component
  54508. */
  54509. readonly right: NodeMaterialConnectionPoint;
  54510. /**
  54511. * Gets the output component
  54512. */
  54513. readonly output: NodeMaterialConnectionPoint;
  54514. protected _buildBlock(state: NodeMaterialBuildState): this;
  54515. }
  54516. }
  54517. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  54518. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54519. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54520. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54521. /**
  54522. * Block used to add 2 vector4
  54523. */
  54524. export class AddBlock extends NodeMaterialBlock {
  54525. /**
  54526. * Creates a new AddBlock
  54527. * @param name defines the block name
  54528. */
  54529. constructor(name: string);
  54530. /**
  54531. * Gets the current class name
  54532. * @returns the class name
  54533. */
  54534. getClassName(): string;
  54535. /**
  54536. * Gets the left operand input component
  54537. */
  54538. readonly left: NodeMaterialConnectionPoint;
  54539. /**
  54540. * Gets the right operand input component
  54541. */
  54542. readonly right: NodeMaterialConnectionPoint;
  54543. /**
  54544. * Gets the output component
  54545. */
  54546. readonly output: NodeMaterialConnectionPoint;
  54547. protected _buildBlock(state: NodeMaterialBuildState): this;
  54548. }
  54549. }
  54550. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  54551. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54552. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54553. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54554. /**
  54555. * Block used to clamp a float
  54556. */
  54557. export class ClampBlock extends NodeMaterialBlock {
  54558. /** Gets or sets the minimum range */
  54559. minimum: number;
  54560. /** Gets or sets the maximum range */
  54561. maximum: number;
  54562. /**
  54563. * Creates a new ClampBlock
  54564. * @param name defines the block name
  54565. */
  54566. constructor(name: string);
  54567. /**
  54568. * Gets the current class name
  54569. * @returns the class name
  54570. */
  54571. getClassName(): string;
  54572. /**
  54573. * Gets the value input component
  54574. */
  54575. readonly value: NodeMaterialConnectionPoint;
  54576. /**
  54577. * Gets the output component
  54578. */
  54579. readonly output: NodeMaterialConnectionPoint;
  54580. protected _buildBlock(state: NodeMaterialBuildState): this;
  54581. }
  54582. }
  54583. declare module "babylonjs/Materials/Node/Blocks/vector2TransformBlock" {
  54584. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54585. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54586. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54587. /**
  54588. * Block used to transform a vector2 with a matrix
  54589. */
  54590. export class Vector2TransformBlock extends NodeMaterialBlock {
  54591. /**
  54592. * Defines the value to use to complement Vector2 to transform it to a Vector4
  54593. */
  54594. complementZ: number;
  54595. /**
  54596. * Defines the value to use to complement Vector2 to transform it to a Vector4
  54597. */
  54598. complementW: number;
  54599. /**
  54600. * Creates a new Vector2TransformBlock
  54601. * @param name defines the block name
  54602. */
  54603. constructor(name: string);
  54604. /**
  54605. * Gets the vector input
  54606. */
  54607. readonly vector: NodeMaterialConnectionPoint;
  54608. /**
  54609. * Gets the matrix transform input
  54610. */
  54611. readonly transform: NodeMaterialConnectionPoint;
  54612. /**
  54613. * Gets the output component
  54614. */
  54615. readonly output: NodeMaterialConnectionPoint;
  54616. /**
  54617. * Gets the current class name
  54618. * @returns the class name
  54619. */
  54620. getClassName(): string;
  54621. protected _buildBlock(state: NodeMaterialBuildState): this;
  54622. }
  54623. }
  54624. declare module "babylonjs/Materials/Node/Blocks/vector3TransformBlock" {
  54625. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  54626. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  54627. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54628. /**
  54629. * Block used to transform a vector3 with a matrix
  54630. */
  54631. export class Vector3TransformBlock extends NodeMaterialBlock {
  54632. /**
  54633. * Defines the value to use to complement Vector3 to transform it to a Vector4
  54634. */
  54635. complement: number;
  54636. /**
  54637. * Creates a new Vector3TransformBlock
  54638. * @param name defines the block name
  54639. */
  54640. constructor(name: string);
  54641. /**
  54642. * Gets the vector input
  54643. */
  54644. readonly vector: NodeMaterialConnectionPoint;
  54645. /**
  54646. * Gets the matrix transform input
  54647. */
  54648. readonly transform: NodeMaterialConnectionPoint;
  54649. /**
  54650. * Gets the output component
  54651. */
  54652. readonly output: NodeMaterialConnectionPoint;
  54653. /**
  54654. * Gets the current class name
  54655. * @returns the class name
  54656. */
  54657. getClassName(): string;
  54658. protected _buildBlock(state: NodeMaterialBuildState): this;
  54659. }
  54660. }
  54661. declare module "babylonjs/Materials/Node/Blocks/index" {
  54662. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  54663. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  54664. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  54665. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  54666. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  54667. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  54668. export * from "babylonjs/Materials/Node/Blocks/vector2TransformBlock";
  54669. export * from "babylonjs/Materials/Node/Blocks/vector3TransformBlock";
  54670. export * from "babylonjs/Materials/Node/Blocks/vector4TransformBlock";
  54671. }
  54672. declare module "babylonjs/Materials/Node/Optimizers/index" {
  54673. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  54674. }
  54675. declare module "babylonjs/Materials/Node/index" {
  54676. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  54677. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  54678. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  54679. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  54680. export * from "babylonjs/Materials/Node/nodeMaterial";
  54681. export * from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  54682. export * from "babylonjs/Materials/Node/Blocks/index";
  54683. export * from "babylonjs/Materials/Node/Optimizers/index";
  54684. }
  54685. declare module "babylonjs/Materials/effectRenderer" {
  54686. import { Nullable } from "babylonjs/types";
  54687. import { Texture } from "babylonjs/Materials/Textures/texture";
  54688. import { Engine } from "babylonjs/Engines/engine";
  54689. import { Observable } from "babylonjs/Misc/observable";
  54690. import { Effect } from "babylonjs/Materials/effect";
  54691. /**
  54692. * Helper class to render one or more effects
  54693. */
  54694. export class EffectRenderer {
  54695. private engine;
  54696. private static _Vertices;
  54697. private static _Indices;
  54698. private _vertexBuffers;
  54699. private _indexBuffer;
  54700. private _ringBufferIndex;
  54701. private _ringScreenBuffer;
  54702. private _getNextFrameBuffer;
  54703. /**
  54704. * Creates an effect renderer
  54705. * @param engine the engine to use for rendering
  54706. */
  54707. constructor(engine: Engine);
  54708. /**
  54709. * renders one or more effects to a specified texture
  54710. * @param effectWrappers list of effects to renderer
  54711. * @param outputTexture texture to draw to, if null it will render to the screen
  54712. */
  54713. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  54714. /**
  54715. * Disposes of the effect renderer
  54716. */
  54717. dispose(): void;
  54718. }
  54719. /**
  54720. * Options to create an EffectWrapper
  54721. */
  54722. interface EffectWrapperCreationOptions {
  54723. /**
  54724. * Engine to use to create the effect
  54725. */
  54726. engine: Engine;
  54727. /**
  54728. * Fragment shader for the effect
  54729. */
  54730. fragmentShader: string;
  54731. /**
  54732. * Attributes to use in the shader
  54733. */
  54734. attributeNames: Array<string>;
  54735. /**
  54736. * Uniforms to use in the shader
  54737. */
  54738. uniformNames: Array<string>;
  54739. /**
  54740. * Texture sampler names to use in the shader
  54741. */
  54742. samplerNames: Array<string>;
  54743. }
  54744. /**
  54745. * Wraps an effect to be used for rendering
  54746. */
  54747. export class EffectWrapper {
  54748. /**
  54749. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  54750. */
  54751. onApplyObservable: Observable<{}>;
  54752. /**
  54753. * The underlying effect
  54754. */
  54755. effect: Effect;
  54756. /**
  54757. * Creates an effect to be renderer
  54758. * @param creationOptions options to create the effect
  54759. */
  54760. constructor(creationOptions: EffectWrapperCreationOptions);
  54761. /**
  54762. * Disposes of the effect wrapper
  54763. */
  54764. dispose(): void;
  54765. }
  54766. }
  54767. declare module "babylonjs/Materials/index" {
  54768. export * from "babylonjs/Materials/Background/index";
  54769. export * from "babylonjs/Materials/colorCurves";
  54770. export * from "babylonjs/Materials/effect";
  54771. export * from "babylonjs/Materials/fresnelParameters";
  54772. export * from "babylonjs/Materials/imageProcessingConfiguration";
  54773. export * from "babylonjs/Materials/material";
  54774. export * from "babylonjs/Materials/materialDefines";
  54775. export * from "babylonjs/Materials/materialHelper";
  54776. export * from "babylonjs/Materials/multiMaterial";
  54777. export * from "babylonjs/Materials/PBR/index";
  54778. export * from "babylonjs/Materials/pushMaterial";
  54779. export * from "babylonjs/Materials/shaderMaterial";
  54780. export * from "babylonjs/Materials/standardMaterial";
  54781. export * from "babylonjs/Materials/Textures/index";
  54782. export * from "babylonjs/Materials/uniformBuffer";
  54783. export * from "babylonjs/Materials/materialFlags";
  54784. export * from "babylonjs/Materials/Node/index";
  54785. export * from "babylonjs/Materials/effectRenderer";
  54786. }
  54787. declare module "babylonjs/Maths/index" {
  54788. export * from "babylonjs/Maths/math.scalar";
  54789. export * from "babylonjs/Maths/math";
  54790. export * from "babylonjs/Maths/sphericalPolynomial";
  54791. }
  54792. declare module "babylonjs/Misc/workerPool" {
  54793. import { IDisposable } from "babylonjs/scene";
  54794. /**
  54795. * Helper class to push actions to a pool of workers.
  54796. */
  54797. export class WorkerPool implements IDisposable {
  54798. private _workerInfos;
  54799. private _pendingActions;
  54800. /**
  54801. * Constructor
  54802. * @param workers Array of workers to use for actions
  54803. */
  54804. constructor(workers: Array<Worker>);
  54805. /**
  54806. * Terminates all workers and clears any pending actions.
  54807. */
  54808. dispose(): void;
  54809. /**
  54810. * Pushes an action to the worker pool. If all the workers are active, the action will be
  54811. * pended until a worker has completed its action.
  54812. * @param action The action to perform. Call onComplete when the action is complete.
  54813. */
  54814. push(action: (worker: Worker, onComplete: () => void) => void): void;
  54815. private _execute;
  54816. }
  54817. }
  54818. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  54819. import { IDisposable } from "babylonjs/scene";
  54820. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  54821. /**
  54822. * Configuration for Draco compression
  54823. */
  54824. export interface IDracoCompressionConfiguration {
  54825. /**
  54826. * Configuration for the decoder.
  54827. */
  54828. decoder: {
  54829. /**
  54830. * The url to the WebAssembly module.
  54831. */
  54832. wasmUrl?: string;
  54833. /**
  54834. * The url to the WebAssembly binary.
  54835. */
  54836. wasmBinaryUrl?: string;
  54837. /**
  54838. * The url to the fallback JavaScript module.
  54839. */
  54840. fallbackUrl?: string;
  54841. };
  54842. }
  54843. /**
  54844. * Draco compression (https://google.github.io/draco/)
  54845. *
  54846. * This class wraps the Draco module.
  54847. *
  54848. * **Encoder**
  54849. *
  54850. * The encoder is not currently implemented.
  54851. *
  54852. * **Decoder**
  54853. *
  54854. * 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.
  54855. *
  54856. * To update the configuration, use the following code:
  54857. * ```javascript
  54858. * DracoCompression.Configuration = {
  54859. * decoder: {
  54860. * wasmUrl: "<url to the WebAssembly library>",
  54861. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  54862. * fallbackUrl: "<url to the fallback JavaScript library>",
  54863. * }
  54864. * };
  54865. * ```
  54866. *
  54867. * 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.
  54868. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  54869. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  54870. *
  54871. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  54872. * ```javascript
  54873. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  54874. * ```
  54875. *
  54876. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  54877. */
  54878. export class DracoCompression implements IDisposable {
  54879. private _workerPoolPromise?;
  54880. private _decoderModulePromise?;
  54881. /**
  54882. * The configuration. Defaults to the following urls:
  54883. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  54884. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  54885. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  54886. */
  54887. static Configuration: IDracoCompressionConfiguration;
  54888. /**
  54889. * Returns true if the decoder configuration is available.
  54890. */
  54891. static readonly DecoderAvailable: boolean;
  54892. /**
  54893. * Default number of workers to create when creating the draco compression object.
  54894. */
  54895. static DefaultNumWorkers: number;
  54896. private static GetDefaultNumWorkers;
  54897. private static _Default;
  54898. /**
  54899. * Default instance for the draco compression object.
  54900. */
  54901. static readonly Default: DracoCompression;
  54902. /**
  54903. * Constructor
  54904. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  54905. */
  54906. constructor(numWorkers?: number);
  54907. /**
  54908. * Stop all async operations and release resources.
  54909. */
  54910. dispose(): void;
  54911. /**
  54912. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  54913. * @returns a promise that resolves when ready
  54914. */
  54915. whenReadyAsync(): Promise<void>;
  54916. /**
  54917. * Decode Draco compressed mesh data to vertex data.
  54918. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  54919. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  54920. * @returns A promise that resolves with the decoded vertex data
  54921. */
  54922. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  54923. [kind: string]: number;
  54924. }): Promise<VertexData>;
  54925. }
  54926. }
  54927. declare module "babylonjs/Meshes/Compression/index" {
  54928. export * from "babylonjs/Meshes/Compression/dracoCompression";
  54929. }
  54930. declare module "babylonjs/Meshes/csg" {
  54931. import { Nullable } from "babylonjs/types";
  54932. import { Scene } from "babylonjs/scene";
  54933. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  54934. import { Mesh } from "babylonjs/Meshes/mesh";
  54935. import { Material } from "babylonjs/Materials/material";
  54936. /**
  54937. * Class for building Constructive Solid Geometry
  54938. */
  54939. export class CSG {
  54940. private polygons;
  54941. /**
  54942. * The world matrix
  54943. */
  54944. matrix: Matrix;
  54945. /**
  54946. * Stores the position
  54947. */
  54948. position: Vector3;
  54949. /**
  54950. * Stores the rotation
  54951. */
  54952. rotation: Vector3;
  54953. /**
  54954. * Stores the rotation quaternion
  54955. */
  54956. rotationQuaternion: Nullable<Quaternion>;
  54957. /**
  54958. * Stores the scaling vector
  54959. */
  54960. scaling: Vector3;
  54961. /**
  54962. * Convert the Mesh to CSG
  54963. * @param mesh The Mesh to convert to CSG
  54964. * @returns A new CSG from the Mesh
  54965. */
  54966. static FromMesh(mesh: Mesh): CSG;
  54967. /**
  54968. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  54969. * @param polygons Polygons used to construct a CSG solid
  54970. */
  54971. private static FromPolygons;
  54972. /**
  54973. * Clones, or makes a deep copy, of the CSG
  54974. * @returns A new CSG
  54975. */
  54976. clone(): CSG;
  54977. /**
  54978. * Unions this CSG with another CSG
  54979. * @param csg The CSG to union against this CSG
  54980. * @returns The unioned CSG
  54981. */
  54982. union(csg: CSG): CSG;
  54983. /**
  54984. * Unions this CSG with another CSG in place
  54985. * @param csg The CSG to union against this CSG
  54986. */
  54987. unionInPlace(csg: CSG): void;
  54988. /**
  54989. * Subtracts this CSG with another CSG
  54990. * @param csg The CSG to subtract against this CSG
  54991. * @returns A new CSG
  54992. */
  54993. subtract(csg: CSG): CSG;
  54994. /**
  54995. * Subtracts this CSG with another CSG in place
  54996. * @param csg The CSG to subtact against this CSG
  54997. */
  54998. subtractInPlace(csg: CSG): void;
  54999. /**
  55000. * Intersect this CSG with another CSG
  55001. * @param csg The CSG to intersect against this CSG
  55002. * @returns A new CSG
  55003. */
  55004. intersect(csg: CSG): CSG;
  55005. /**
  55006. * Intersects this CSG with another CSG in place
  55007. * @param csg The CSG to intersect against this CSG
  55008. */
  55009. intersectInPlace(csg: CSG): void;
  55010. /**
  55011. * Return a new CSG solid with solid and empty space switched. This solid is
  55012. * not modified.
  55013. * @returns A new CSG solid with solid and empty space switched
  55014. */
  55015. inverse(): CSG;
  55016. /**
  55017. * Inverses the CSG in place
  55018. */
  55019. inverseInPlace(): void;
  55020. /**
  55021. * This is used to keep meshes transformations so they can be restored
  55022. * when we build back a Babylon Mesh
  55023. * NB : All CSG operations are performed in world coordinates
  55024. * @param csg The CSG to copy the transform attributes from
  55025. * @returns This CSG
  55026. */
  55027. copyTransformAttributes(csg: CSG): CSG;
  55028. /**
  55029. * Build Raw mesh from CSG
  55030. * Coordinates here are in world space
  55031. * @param name The name of the mesh geometry
  55032. * @param scene The Scene
  55033. * @param keepSubMeshes Specifies if the submeshes should be kept
  55034. * @returns A new Mesh
  55035. */
  55036. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  55037. /**
  55038. * Build Mesh from CSG taking material and transforms into account
  55039. * @param name The name of the Mesh
  55040. * @param material The material of the Mesh
  55041. * @param scene The Scene
  55042. * @param keepSubMeshes Specifies if submeshes should be kept
  55043. * @returns The new Mesh
  55044. */
  55045. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  55046. }
  55047. }
  55048. declare module "babylonjs/Meshes/trailMesh" {
  55049. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55050. import { Mesh } from "babylonjs/Meshes/mesh";
  55051. import { Scene } from "babylonjs/scene";
  55052. /**
  55053. * Class used to create a trail following a mesh
  55054. */
  55055. export class TrailMesh extends Mesh {
  55056. private _generator;
  55057. private _autoStart;
  55058. private _running;
  55059. private _diameter;
  55060. private _length;
  55061. private _sectionPolygonPointsCount;
  55062. private _sectionVectors;
  55063. private _sectionNormalVectors;
  55064. private _beforeRenderObserver;
  55065. /**
  55066. * @constructor
  55067. * @param name The value used by scene.getMeshByName() to do a lookup.
  55068. * @param generator The mesh to generate a trail.
  55069. * @param scene The scene to add this mesh to.
  55070. * @param diameter Diameter of trailing mesh. Default is 1.
  55071. * @param length Length of trailing mesh. Default is 60.
  55072. * @param autoStart Automatically start trailing mesh. Default true.
  55073. */
  55074. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  55075. /**
  55076. * "TrailMesh"
  55077. * @returns "TrailMesh"
  55078. */
  55079. getClassName(): string;
  55080. private _createMesh;
  55081. /**
  55082. * Start trailing mesh.
  55083. */
  55084. start(): void;
  55085. /**
  55086. * Stop trailing mesh.
  55087. */
  55088. stop(): void;
  55089. /**
  55090. * Update trailing mesh geometry.
  55091. */
  55092. update(): void;
  55093. /**
  55094. * Returns a new TrailMesh object.
  55095. * @param name is a string, the name given to the new mesh
  55096. * @param newGenerator use new generator object for cloned trail mesh
  55097. * @returns a new mesh
  55098. */
  55099. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  55100. /**
  55101. * Serializes this trail mesh
  55102. * @param serializationObject object to write serialization to
  55103. */
  55104. serialize(serializationObject: any): void;
  55105. /**
  55106. * Parses a serialized trail mesh
  55107. * @param parsedMesh the serialized mesh
  55108. * @param scene the scene to create the trail mesh in
  55109. * @returns the created trail mesh
  55110. */
  55111. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  55112. }
  55113. }
  55114. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  55115. import { Nullable } from "babylonjs/types";
  55116. import { Scene } from "babylonjs/scene";
  55117. import { Vector4, Color4 } from "babylonjs/Maths/math";
  55118. import { Mesh } from "babylonjs/Meshes/mesh";
  55119. /**
  55120. * Class containing static functions to help procedurally build meshes
  55121. */
  55122. export class TiledBoxBuilder {
  55123. /**
  55124. * Creates a box mesh
  55125. * 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)
  55126. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55127. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55128. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55129. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55130. * @param name defines the name of the mesh
  55131. * @param options defines the options used to create the mesh
  55132. * @param scene defines the hosting scene
  55133. * @returns the box mesh
  55134. */
  55135. static CreateTiledBox(name: string, options: {
  55136. pattern?: number;
  55137. width?: number;
  55138. height?: number;
  55139. depth?: number;
  55140. tileSize?: number;
  55141. tileWidth?: number;
  55142. tileHeight?: number;
  55143. alignHorizontal?: number;
  55144. alignVertical?: number;
  55145. faceUV?: Vector4[];
  55146. faceColors?: Color4[];
  55147. sideOrientation?: number;
  55148. updatable?: boolean;
  55149. }, scene?: Nullable<Scene>): Mesh;
  55150. }
  55151. }
  55152. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  55153. import { Vector4 } from "babylonjs/Maths/math";
  55154. import { Mesh } from "babylonjs/Meshes/mesh";
  55155. /**
  55156. * Class containing static functions to help procedurally build meshes
  55157. */
  55158. export class TorusKnotBuilder {
  55159. /**
  55160. * Creates a torus knot mesh
  55161. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55162. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55163. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55164. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55165. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55166. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55167. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55168. * @param name defines the name of the mesh
  55169. * @param options defines the options used to create the mesh
  55170. * @param scene defines the hosting scene
  55171. * @returns the torus knot mesh
  55172. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55173. */
  55174. static CreateTorusKnot(name: string, options: {
  55175. radius?: number;
  55176. tube?: number;
  55177. radialSegments?: number;
  55178. tubularSegments?: number;
  55179. p?: number;
  55180. q?: number;
  55181. updatable?: boolean;
  55182. sideOrientation?: number;
  55183. frontUVs?: Vector4;
  55184. backUVs?: Vector4;
  55185. }, scene: any): Mesh;
  55186. }
  55187. }
  55188. declare module "babylonjs/Meshes/polygonMesh" {
  55189. import { Scene } from "babylonjs/scene";
  55190. import { Vector2, Path2 } from "babylonjs/Maths/math";
  55191. import { Mesh } from "babylonjs/Meshes/mesh";
  55192. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  55193. /**
  55194. * Polygon
  55195. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  55196. */
  55197. export class Polygon {
  55198. /**
  55199. * Creates a rectangle
  55200. * @param xmin bottom X coord
  55201. * @param ymin bottom Y coord
  55202. * @param xmax top X coord
  55203. * @param ymax top Y coord
  55204. * @returns points that make the resulting rectation
  55205. */
  55206. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  55207. /**
  55208. * Creates a circle
  55209. * @param radius radius of circle
  55210. * @param cx scale in x
  55211. * @param cy scale in y
  55212. * @param numberOfSides number of sides that make up the circle
  55213. * @returns points that make the resulting circle
  55214. */
  55215. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  55216. /**
  55217. * Creates a polygon from input string
  55218. * @param input Input polygon data
  55219. * @returns the parsed points
  55220. */
  55221. static Parse(input: string): Vector2[];
  55222. /**
  55223. * Starts building a polygon from x and y coordinates
  55224. * @param x x coordinate
  55225. * @param y y coordinate
  55226. * @returns the started path2
  55227. */
  55228. static StartingAt(x: number, y: number): Path2;
  55229. }
  55230. /**
  55231. * Builds a polygon
  55232. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  55233. */
  55234. export class PolygonMeshBuilder {
  55235. private _points;
  55236. private _outlinepoints;
  55237. private _holes;
  55238. private _name;
  55239. private _scene;
  55240. private _epoints;
  55241. private _eholes;
  55242. private _addToepoint;
  55243. /**
  55244. * Babylon reference to the earcut plugin.
  55245. */
  55246. bjsEarcut: any;
  55247. /**
  55248. * Creates a PolygonMeshBuilder
  55249. * @param name name of the builder
  55250. * @param contours Path of the polygon
  55251. * @param scene scene to add to when creating the mesh
  55252. * @param earcutInjection can be used to inject your own earcut reference
  55253. */
  55254. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  55255. /**
  55256. * Adds a whole within the polygon
  55257. * @param hole Array of points defining the hole
  55258. * @returns this
  55259. */
  55260. addHole(hole: Vector2[]): PolygonMeshBuilder;
  55261. /**
  55262. * Creates the polygon
  55263. * @param updatable If the mesh should be updatable
  55264. * @param depth The depth of the mesh created
  55265. * @returns the created mesh
  55266. */
  55267. build(updatable?: boolean, depth?: number): Mesh;
  55268. /**
  55269. * Creates the polygon
  55270. * @param depth The depth of the mesh created
  55271. * @returns the created VertexData
  55272. */
  55273. buildVertexData(depth?: number): VertexData;
  55274. /**
  55275. * Adds a side to the polygon
  55276. * @param positions points that make the polygon
  55277. * @param normals normals of the polygon
  55278. * @param uvs uvs of the polygon
  55279. * @param indices indices of the polygon
  55280. * @param bounds bounds of the polygon
  55281. * @param points points of the polygon
  55282. * @param depth depth of the polygon
  55283. * @param flip flip of the polygon
  55284. */
  55285. private addSide;
  55286. }
  55287. }
  55288. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  55289. import { Scene } from "babylonjs/scene";
  55290. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  55291. import { Mesh } from "babylonjs/Meshes/mesh";
  55292. import { Nullable } from "babylonjs/types";
  55293. /**
  55294. * Class containing static functions to help procedurally build meshes
  55295. */
  55296. export class PolygonBuilder {
  55297. /**
  55298. * Creates a polygon mesh
  55299. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55300. * * 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
  55301. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55303. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  55304. * * Remember you can only change the shape positions, not their number when updating a polygon
  55305. * @param name defines the name of the mesh
  55306. * @param options defines the options used to create the mesh
  55307. * @param scene defines the hosting scene
  55308. * @param earcutInjection can be used to inject your own earcut reference
  55309. * @returns the polygon mesh
  55310. */
  55311. static CreatePolygon(name: string, options: {
  55312. shape: Vector3[];
  55313. holes?: Vector3[][];
  55314. depth?: number;
  55315. faceUV?: Vector4[];
  55316. faceColors?: Color4[];
  55317. updatable?: boolean;
  55318. sideOrientation?: number;
  55319. frontUVs?: Vector4;
  55320. backUVs?: Vector4;
  55321. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55322. /**
  55323. * Creates an extruded polygon mesh, with depth in the Y direction.
  55324. * * 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)
  55325. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55326. * @param name defines the name of the mesh
  55327. * @param options defines the options used to create the mesh
  55328. * @param scene defines the hosting scene
  55329. * @param earcutInjection can be used to inject your own earcut reference
  55330. * @returns the polygon mesh
  55331. */
  55332. static ExtrudePolygon(name: string, options: {
  55333. shape: Vector3[];
  55334. holes?: Vector3[][];
  55335. depth?: number;
  55336. faceUV?: Vector4[];
  55337. faceColors?: Color4[];
  55338. updatable?: boolean;
  55339. sideOrientation?: number;
  55340. frontUVs?: Vector4;
  55341. backUVs?: Vector4;
  55342. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55343. }
  55344. }
  55345. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  55346. import { Scene } from "babylonjs/scene";
  55347. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  55348. import { Mesh } from "babylonjs/Meshes/mesh";
  55349. import { Nullable } from "babylonjs/types";
  55350. /**
  55351. * Class containing static functions to help procedurally build meshes
  55352. */
  55353. export class LatheBuilder {
  55354. /**
  55355. * Creates lathe mesh.
  55356. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55357. * * 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
  55358. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55359. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55360. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55361. * * 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
  55362. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55363. * * 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
  55364. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55365. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55366. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55367. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55368. * @param name defines the name of the mesh
  55369. * @param options defines the options used to create the mesh
  55370. * @param scene defines the hosting scene
  55371. * @returns the lathe mesh
  55372. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55373. */
  55374. static CreateLathe(name: string, options: {
  55375. shape: Vector3[];
  55376. radius?: number;
  55377. tessellation?: number;
  55378. clip?: number;
  55379. arc?: number;
  55380. closed?: boolean;
  55381. updatable?: boolean;
  55382. sideOrientation?: number;
  55383. frontUVs?: Vector4;
  55384. backUVs?: Vector4;
  55385. cap?: number;
  55386. invertUV?: boolean;
  55387. }, scene?: Nullable<Scene>): Mesh;
  55388. }
  55389. }
  55390. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  55391. import { Nullable } from "babylonjs/types";
  55392. import { Scene } from "babylonjs/scene";
  55393. import { Vector4 } from "babylonjs/Maths/math";
  55394. import { Mesh } from "babylonjs/Meshes/mesh";
  55395. /**
  55396. * Class containing static functions to help procedurally build meshes
  55397. */
  55398. export class TiledPlaneBuilder {
  55399. /**
  55400. * Creates a tiled plane mesh
  55401. * * The parameter `pattern` will, depending on value, do nothing or
  55402. * * * flip (reflect about central vertical) alternate tiles across and up
  55403. * * * flip every tile on alternate rows
  55404. * * * rotate (180 degs) alternate tiles across and up
  55405. * * * rotate every tile on alternate rows
  55406. * * * flip and rotate alternate tiles across and up
  55407. * * * flip and rotate every tile on alternate rows
  55408. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  55409. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  55410. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55411. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55412. * * 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)
  55413. * * 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)
  55414. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55415. * @param name defines the name of the mesh
  55416. * @param options defines the options used to create the mesh
  55417. * @param scene defines the hosting scene
  55418. * @returns the box mesh
  55419. */
  55420. static CreateTiledPlane(name: string, options: {
  55421. pattern?: number;
  55422. tileSize?: number;
  55423. tileWidth?: number;
  55424. tileHeight?: number;
  55425. size?: number;
  55426. width?: number;
  55427. height?: number;
  55428. alignHorizontal?: number;
  55429. alignVertical?: number;
  55430. sideOrientation?: number;
  55431. frontUVs?: Vector4;
  55432. backUVs?: Vector4;
  55433. updatable?: boolean;
  55434. }, scene?: Nullable<Scene>): Mesh;
  55435. }
  55436. }
  55437. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  55438. import { Nullable } from "babylonjs/types";
  55439. import { Scene } from "babylonjs/scene";
  55440. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  55441. import { Mesh } from "babylonjs/Meshes/mesh";
  55442. /**
  55443. * Class containing static functions to help procedurally build meshes
  55444. */
  55445. export class TubeBuilder {
  55446. /**
  55447. * Creates a tube mesh.
  55448. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55449. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55450. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55451. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55452. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55453. * * 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)
  55454. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55455. * * 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
  55456. * * 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
  55457. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55458. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55459. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55461. * @param name defines the name of the mesh
  55462. * @param options defines the options used to create the mesh
  55463. * @param scene defines the hosting scene
  55464. * @returns the tube mesh
  55465. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55466. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55467. */
  55468. static CreateTube(name: string, options: {
  55469. path: Vector3[];
  55470. radius?: number;
  55471. tessellation?: number;
  55472. radiusFunction?: {
  55473. (i: number, distance: number): number;
  55474. };
  55475. cap?: number;
  55476. arc?: number;
  55477. updatable?: boolean;
  55478. sideOrientation?: number;
  55479. frontUVs?: Vector4;
  55480. backUVs?: Vector4;
  55481. instance?: Mesh;
  55482. invertUV?: boolean;
  55483. }, scene?: Nullable<Scene>): Mesh;
  55484. }
  55485. }
  55486. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  55487. import { Scene } from "babylonjs/scene";
  55488. import { Vector4 } from "babylonjs/Maths/math";
  55489. import { Mesh } from "babylonjs/Meshes/mesh";
  55490. import { Nullable } from "babylonjs/types";
  55491. /**
  55492. * Class containing static functions to help procedurally build meshes
  55493. */
  55494. export class IcoSphereBuilder {
  55495. /**
  55496. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55497. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55498. * * 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`)
  55499. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55500. * * 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
  55501. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55502. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55504. * @param name defines the name of the mesh
  55505. * @param options defines the options used to create the mesh
  55506. * @param scene defines the hosting scene
  55507. * @returns the icosahedron mesh
  55508. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55509. */
  55510. static CreateIcoSphere(name: string, options: {
  55511. radius?: number;
  55512. radiusX?: number;
  55513. radiusY?: number;
  55514. radiusZ?: number;
  55515. flat?: boolean;
  55516. subdivisions?: number;
  55517. sideOrientation?: number;
  55518. frontUVs?: Vector4;
  55519. backUVs?: Vector4;
  55520. updatable?: boolean;
  55521. }, scene?: Nullable<Scene>): Mesh;
  55522. }
  55523. }
  55524. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  55525. import { Vector3 } from "babylonjs/Maths/math";
  55526. import { Mesh } from "babylonjs/Meshes/mesh";
  55527. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55528. /**
  55529. * Class containing static functions to help procedurally build meshes
  55530. */
  55531. export class DecalBuilder {
  55532. /**
  55533. * Creates a decal mesh.
  55534. * 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
  55535. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55536. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55537. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55538. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55539. * @param name defines the name of the mesh
  55540. * @param sourceMesh defines the mesh where the decal must be applied
  55541. * @param options defines the options used to create the mesh
  55542. * @param scene defines the hosting scene
  55543. * @returns the decal mesh
  55544. * @see https://doc.babylonjs.com/how_to/decals
  55545. */
  55546. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55547. position?: Vector3;
  55548. normal?: Vector3;
  55549. size?: Vector3;
  55550. angle?: number;
  55551. }): Mesh;
  55552. }
  55553. }
  55554. declare module "babylonjs/Meshes/meshBuilder" {
  55555. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  55556. import { Nullable } from "babylonjs/types";
  55557. import { Scene } from "babylonjs/scene";
  55558. import { Mesh } from "babylonjs/Meshes/mesh";
  55559. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  55560. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  55561. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55562. /**
  55563. * Class containing static functions to help procedurally build meshes
  55564. */
  55565. export class MeshBuilder {
  55566. /**
  55567. * Creates a box mesh
  55568. * * The parameter `size` sets the size (float) of each box side (default 1)
  55569. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  55570. * * 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)
  55571. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55572. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55573. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55575. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  55576. * @param name defines the name of the mesh
  55577. * @param options defines the options used to create the mesh
  55578. * @param scene defines the hosting scene
  55579. * @returns the box mesh
  55580. */
  55581. static CreateBox(name: string, options: {
  55582. size?: number;
  55583. width?: number;
  55584. height?: number;
  55585. depth?: number;
  55586. faceUV?: Vector4[];
  55587. faceColors?: Color4[];
  55588. sideOrientation?: number;
  55589. frontUVs?: Vector4;
  55590. backUVs?: Vector4;
  55591. updatable?: boolean;
  55592. }, scene?: Nullable<Scene>): Mesh;
  55593. /**
  55594. * Creates a tiled box mesh
  55595. * * faceTiles sets the pattern, tile size and number of tiles for a face
  55596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55597. * @param name defines the name of the mesh
  55598. * @param options defines the options used to create the mesh
  55599. * @param scene defines the hosting scene
  55600. * @returns the tiled box mesh
  55601. */
  55602. static CreateTiledBox(name: string, options: {
  55603. pattern?: number;
  55604. size?: number;
  55605. width?: number;
  55606. height?: number;
  55607. depth: number;
  55608. tileSize?: number;
  55609. tileWidth?: number;
  55610. tileHeight?: number;
  55611. faceUV?: Vector4[];
  55612. faceColors?: Color4[];
  55613. alignHorizontal?: number;
  55614. alignVertical?: number;
  55615. sideOrientation?: number;
  55616. updatable?: boolean;
  55617. }, scene?: Nullable<Scene>): Mesh;
  55618. /**
  55619. * Creates a sphere mesh
  55620. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  55621. * * 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`)
  55622. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  55623. * * 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
  55624. * * 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)
  55625. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55626. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55627. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55628. * @param name defines the name of the mesh
  55629. * @param options defines the options used to create the mesh
  55630. * @param scene defines the hosting scene
  55631. * @returns the sphere mesh
  55632. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  55633. */
  55634. static CreateSphere(name: string, options: {
  55635. segments?: number;
  55636. diameter?: number;
  55637. diameterX?: number;
  55638. diameterY?: number;
  55639. diameterZ?: number;
  55640. arc?: number;
  55641. slice?: number;
  55642. sideOrientation?: number;
  55643. frontUVs?: Vector4;
  55644. backUVs?: Vector4;
  55645. updatable?: boolean;
  55646. }, scene?: Nullable<Scene>): Mesh;
  55647. /**
  55648. * Creates a plane polygonal mesh. By default, this is a disc
  55649. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  55650. * * 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
  55651. * * 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
  55652. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55653. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55654. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55655. * @param name defines the name of the mesh
  55656. * @param options defines the options used to create the mesh
  55657. * @param scene defines the hosting scene
  55658. * @returns the plane polygonal mesh
  55659. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  55660. */
  55661. static CreateDisc(name: string, options: {
  55662. radius?: number;
  55663. tessellation?: number;
  55664. arc?: number;
  55665. updatable?: boolean;
  55666. sideOrientation?: number;
  55667. frontUVs?: Vector4;
  55668. backUVs?: Vector4;
  55669. }, scene?: Nullable<Scene>): Mesh;
  55670. /**
  55671. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  55672. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  55673. * * 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`)
  55674. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  55675. * * 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
  55676. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55677. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55679. * @param name defines the name of the mesh
  55680. * @param options defines the options used to create the mesh
  55681. * @param scene defines the hosting scene
  55682. * @returns the icosahedron mesh
  55683. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  55684. */
  55685. static CreateIcoSphere(name: string, options: {
  55686. radius?: number;
  55687. radiusX?: number;
  55688. radiusY?: number;
  55689. radiusZ?: number;
  55690. flat?: boolean;
  55691. subdivisions?: number;
  55692. sideOrientation?: number;
  55693. frontUVs?: Vector4;
  55694. backUVs?: Vector4;
  55695. updatable?: boolean;
  55696. }, scene?: Nullable<Scene>): Mesh;
  55697. /**
  55698. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55699. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55700. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55701. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55702. * * 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
  55703. * * 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
  55704. * * 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
  55705. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55706. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55707. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55708. * * 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
  55709. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55710. * * 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
  55711. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55712. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55713. * @param name defines the name of the mesh
  55714. * @param options defines the options used to create the mesh
  55715. * @param scene defines the hosting scene
  55716. * @returns the ribbon mesh
  55717. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55718. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55719. */
  55720. static CreateRibbon(name: string, options: {
  55721. pathArray: Vector3[][];
  55722. closeArray?: boolean;
  55723. closePath?: boolean;
  55724. offset?: number;
  55725. updatable?: boolean;
  55726. sideOrientation?: number;
  55727. frontUVs?: Vector4;
  55728. backUVs?: Vector4;
  55729. instance?: Mesh;
  55730. invertUV?: boolean;
  55731. uvs?: Vector2[];
  55732. colors?: Color4[];
  55733. }, scene?: Nullable<Scene>): Mesh;
  55734. /**
  55735. * Creates a cylinder or a cone mesh
  55736. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  55737. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  55738. * * 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.
  55739. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  55740. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  55741. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  55742. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  55743. * * 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).
  55744. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  55745. * * 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).
  55746. * * 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
  55747. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  55748. * * 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
  55749. * * 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.
  55750. * * If `enclose` is false, a ring surface is one element.
  55751. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  55752. * * 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
  55753. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55754. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55756. * @param name defines the name of the mesh
  55757. * @param options defines the options used to create the mesh
  55758. * @param scene defines the hosting scene
  55759. * @returns the cylinder mesh
  55760. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  55761. */
  55762. static CreateCylinder(name: string, options: {
  55763. height?: number;
  55764. diameterTop?: number;
  55765. diameterBottom?: number;
  55766. diameter?: number;
  55767. tessellation?: number;
  55768. subdivisions?: number;
  55769. arc?: number;
  55770. faceColors?: Color4[];
  55771. faceUV?: Vector4[];
  55772. updatable?: boolean;
  55773. hasRings?: boolean;
  55774. enclose?: boolean;
  55775. cap?: number;
  55776. sideOrientation?: number;
  55777. frontUVs?: Vector4;
  55778. backUVs?: Vector4;
  55779. }, scene?: Nullable<Scene>): Mesh;
  55780. /**
  55781. * Creates a torus mesh
  55782. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  55783. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  55784. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  55785. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55786. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55788. * @param name defines the name of the mesh
  55789. * @param options defines the options used to create the mesh
  55790. * @param scene defines the hosting scene
  55791. * @returns the torus mesh
  55792. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  55793. */
  55794. static CreateTorus(name: string, options: {
  55795. diameter?: number;
  55796. thickness?: number;
  55797. tessellation?: number;
  55798. updatable?: boolean;
  55799. sideOrientation?: number;
  55800. frontUVs?: Vector4;
  55801. backUVs?: Vector4;
  55802. }, scene?: Nullable<Scene>): Mesh;
  55803. /**
  55804. * Creates a torus knot mesh
  55805. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  55806. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  55807. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  55808. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  55809. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55810. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55811. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55812. * @param name defines the name of the mesh
  55813. * @param options defines the options used to create the mesh
  55814. * @param scene defines the hosting scene
  55815. * @returns the torus knot mesh
  55816. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  55817. */
  55818. static CreateTorusKnot(name: string, options: {
  55819. radius?: number;
  55820. tube?: number;
  55821. radialSegments?: number;
  55822. tubularSegments?: number;
  55823. p?: number;
  55824. q?: number;
  55825. updatable?: boolean;
  55826. sideOrientation?: number;
  55827. frontUVs?: Vector4;
  55828. backUVs?: Vector4;
  55829. }, scene?: Nullable<Scene>): Mesh;
  55830. /**
  55831. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  55832. * * 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
  55833. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  55834. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  55835. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  55836. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  55837. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55838. * * 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
  55839. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  55840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55841. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  55842. * @param name defines the name of the new line system
  55843. * @param options defines the options used to create the line system
  55844. * @param scene defines the hosting scene
  55845. * @returns a new line system mesh
  55846. */
  55847. static CreateLineSystem(name: string, options: {
  55848. lines: Vector3[][];
  55849. updatable?: boolean;
  55850. instance?: Nullable<LinesMesh>;
  55851. colors?: Nullable<Color4[][]>;
  55852. useVertexAlpha?: boolean;
  55853. }, scene: Nullable<Scene>): LinesMesh;
  55854. /**
  55855. * Creates a line mesh
  55856. * 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
  55857. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55858. * * The parameter `points` is an array successive Vector3
  55859. * * 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
  55860. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55861. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55862. * * When updating an instance, remember that only point positions can change, not the number of points
  55863. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55864. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55865. * @param name defines the name of the new line system
  55866. * @param options defines the options used to create the line system
  55867. * @param scene defines the hosting scene
  55868. * @returns a new line mesh
  55869. */
  55870. static CreateLines(name: string, options: {
  55871. points: Vector3[];
  55872. updatable?: boolean;
  55873. instance?: Nullable<LinesMesh>;
  55874. colors?: Color4[];
  55875. useVertexAlpha?: boolean;
  55876. }, scene?: Nullable<Scene>): LinesMesh;
  55877. /**
  55878. * Creates a dashed line mesh
  55879. * * 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
  55880. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55881. * * The parameter `points` is an array successive Vector3
  55882. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55883. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55884. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55885. * * 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
  55886. * * When updating an instance, remember that only point positions can change, not the number of points
  55887. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55888. * @param name defines the name of the mesh
  55889. * @param options defines the options used to create the mesh
  55890. * @param scene defines the hosting scene
  55891. * @returns the dashed line mesh
  55892. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55893. */
  55894. static CreateDashedLines(name: string, options: {
  55895. points: Vector3[];
  55896. dashSize?: number;
  55897. gapSize?: number;
  55898. dashNb?: number;
  55899. updatable?: boolean;
  55900. instance?: LinesMesh;
  55901. }, scene?: Nullable<Scene>): LinesMesh;
  55902. /**
  55903. * 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.
  55904. * * 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.
  55905. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55906. * * 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.
  55907. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55908. * * 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
  55909. * * 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
  55910. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55911. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55912. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55913. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55914. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55915. * @param name defines the name of the mesh
  55916. * @param options defines the options used to create the mesh
  55917. * @param scene defines the hosting scene
  55918. * @returns the extruded shape mesh
  55919. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55920. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55921. */
  55922. static ExtrudeShape(name: string, options: {
  55923. shape: Vector3[];
  55924. path: Vector3[];
  55925. scale?: number;
  55926. rotation?: number;
  55927. cap?: number;
  55928. updatable?: boolean;
  55929. sideOrientation?: number;
  55930. frontUVs?: Vector4;
  55931. backUVs?: Vector4;
  55932. instance?: Mesh;
  55933. invertUV?: boolean;
  55934. }, scene?: Nullable<Scene>): Mesh;
  55935. /**
  55936. * Creates an custom extruded shape mesh.
  55937. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55938. * * 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.
  55939. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55940. * * 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
  55941. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55942. * * 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
  55943. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55944. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55945. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55946. * * 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
  55947. * * 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
  55948. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55949. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55950. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55951. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55952. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55953. * @param name defines the name of the mesh
  55954. * @param options defines the options used to create the mesh
  55955. * @param scene defines the hosting scene
  55956. * @returns the custom extruded shape mesh
  55957. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55958. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55959. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55960. */
  55961. static ExtrudeShapeCustom(name: string, options: {
  55962. shape: Vector3[];
  55963. path: Vector3[];
  55964. scaleFunction?: any;
  55965. rotationFunction?: any;
  55966. ribbonCloseArray?: boolean;
  55967. ribbonClosePath?: boolean;
  55968. cap?: number;
  55969. updatable?: boolean;
  55970. sideOrientation?: number;
  55971. frontUVs?: Vector4;
  55972. backUVs?: Vector4;
  55973. instance?: Mesh;
  55974. invertUV?: boolean;
  55975. }, scene?: Nullable<Scene>): Mesh;
  55976. /**
  55977. * Creates lathe mesh.
  55978. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55979. * * 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
  55980. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55981. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55982. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55983. * * 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
  55984. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55985. * * 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
  55986. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55987. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55988. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55990. * @param name defines the name of the mesh
  55991. * @param options defines the options used to create the mesh
  55992. * @param scene defines the hosting scene
  55993. * @returns the lathe mesh
  55994. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55995. */
  55996. static CreateLathe(name: string, options: {
  55997. shape: Vector3[];
  55998. radius?: number;
  55999. tessellation?: number;
  56000. clip?: number;
  56001. arc?: number;
  56002. closed?: boolean;
  56003. updatable?: boolean;
  56004. sideOrientation?: number;
  56005. frontUVs?: Vector4;
  56006. backUVs?: Vector4;
  56007. cap?: number;
  56008. invertUV?: boolean;
  56009. }, scene?: Nullable<Scene>): Mesh;
  56010. /**
  56011. * Creates a tiled plane mesh
  56012. * * You can set a limited pattern arrangement with the tiles
  56013. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56014. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56016. * @param name defines the name of the mesh
  56017. * @param options defines the options used to create the mesh
  56018. * @param scene defines the hosting scene
  56019. * @returns the plane mesh
  56020. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56021. */
  56022. static CreateTiledPlane(name: string, options: {
  56023. pattern?: number;
  56024. tileSize?: number;
  56025. tileWidth?: number;
  56026. tileHeight?: number;
  56027. size?: number;
  56028. width?: number;
  56029. height?: number;
  56030. alignHorizontal?: number;
  56031. alignVertical?: number;
  56032. sideOrientation?: number;
  56033. frontUVs?: Vector4;
  56034. backUVs?: Vector4;
  56035. updatable?: boolean;
  56036. }, scene?: Nullable<Scene>): Mesh;
  56037. /**
  56038. * Creates a plane mesh
  56039. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  56040. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  56041. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  56042. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56043. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56044. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56045. * @param name defines the name of the mesh
  56046. * @param options defines the options used to create the mesh
  56047. * @param scene defines the hosting scene
  56048. * @returns the plane mesh
  56049. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  56050. */
  56051. static CreatePlane(name: string, options: {
  56052. size?: number;
  56053. width?: number;
  56054. height?: number;
  56055. sideOrientation?: number;
  56056. frontUVs?: Vector4;
  56057. backUVs?: Vector4;
  56058. updatable?: boolean;
  56059. sourcePlane?: Plane;
  56060. }, scene?: Nullable<Scene>): Mesh;
  56061. /**
  56062. * Creates a ground mesh
  56063. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  56064. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  56065. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56066. * @param name defines the name of the mesh
  56067. * @param options defines the options used to create the mesh
  56068. * @param scene defines the hosting scene
  56069. * @returns the ground mesh
  56070. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  56071. */
  56072. static CreateGround(name: string, options: {
  56073. width?: number;
  56074. height?: number;
  56075. subdivisions?: number;
  56076. subdivisionsX?: number;
  56077. subdivisionsY?: number;
  56078. updatable?: boolean;
  56079. }, scene?: Nullable<Scene>): Mesh;
  56080. /**
  56081. * Creates a tiled ground mesh
  56082. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  56083. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  56084. * * 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
  56085. * * 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
  56086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56087. * @param name defines the name of the mesh
  56088. * @param options defines the options used to create the mesh
  56089. * @param scene defines the hosting scene
  56090. * @returns the tiled ground mesh
  56091. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  56092. */
  56093. static CreateTiledGround(name: string, options: {
  56094. xmin: number;
  56095. zmin: number;
  56096. xmax: number;
  56097. zmax: number;
  56098. subdivisions?: {
  56099. w: number;
  56100. h: number;
  56101. };
  56102. precision?: {
  56103. w: number;
  56104. h: number;
  56105. };
  56106. updatable?: boolean;
  56107. }, scene?: Nullable<Scene>): Mesh;
  56108. /**
  56109. * Creates a ground mesh from a height map
  56110. * * The parameter `url` sets the URL of the height map image resource.
  56111. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  56112. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  56113. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  56114. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  56115. * * 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.
  56116. * * 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).
  56117. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  56118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56119. * @param name defines the name of the mesh
  56120. * @param url defines the url to the height map
  56121. * @param options defines the options used to create the mesh
  56122. * @param scene defines the hosting scene
  56123. * @returns the ground mesh
  56124. * @see https://doc.babylonjs.com/babylon101/height_map
  56125. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  56126. */
  56127. static CreateGroundFromHeightMap(name: string, url: string, options: {
  56128. width?: number;
  56129. height?: number;
  56130. subdivisions?: number;
  56131. minHeight?: number;
  56132. maxHeight?: number;
  56133. colorFilter?: Color3;
  56134. alphaFilter?: number;
  56135. updatable?: boolean;
  56136. onReady?: (mesh: GroundMesh) => void;
  56137. }, scene?: Nullable<Scene>): GroundMesh;
  56138. /**
  56139. * Creates a polygon mesh
  56140. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  56141. * * 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
  56142. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  56143. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56144. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  56145. * * Remember you can only change the shape positions, not their number when updating a polygon
  56146. * @param name defines the name of the mesh
  56147. * @param options defines the options used to create the mesh
  56148. * @param scene defines the hosting scene
  56149. * @param earcutInjection can be used to inject your own earcut reference
  56150. * @returns the polygon mesh
  56151. */
  56152. static CreatePolygon(name: string, options: {
  56153. shape: Vector3[];
  56154. holes?: Vector3[][];
  56155. depth?: number;
  56156. faceUV?: Vector4[];
  56157. faceColors?: Color4[];
  56158. updatable?: boolean;
  56159. sideOrientation?: number;
  56160. frontUVs?: Vector4;
  56161. backUVs?: Vector4;
  56162. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56163. /**
  56164. * Creates an extruded polygon mesh, with depth in the Y direction.
  56165. * * 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)
  56166. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56167. * @param name defines the name of the mesh
  56168. * @param options defines the options used to create the mesh
  56169. * @param scene defines the hosting scene
  56170. * @param earcutInjection can be used to inject your own earcut reference
  56171. * @returns the polygon mesh
  56172. */
  56173. static ExtrudePolygon(name: string, options: {
  56174. shape: Vector3[];
  56175. holes?: Vector3[][];
  56176. depth?: number;
  56177. faceUV?: Vector4[];
  56178. faceColors?: Color4[];
  56179. updatable?: boolean;
  56180. sideOrientation?: number;
  56181. frontUVs?: Vector4;
  56182. backUVs?: Vector4;
  56183. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  56184. /**
  56185. * Creates a tube mesh.
  56186. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56187. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  56188. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  56189. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  56190. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  56191. * * 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)
  56192. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  56193. * * 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
  56194. * * 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
  56195. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56196. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56197. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56199. * @param name defines the name of the mesh
  56200. * @param options defines the options used to create the mesh
  56201. * @param scene defines the hosting scene
  56202. * @returns the tube mesh
  56203. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56204. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  56205. */
  56206. static CreateTube(name: string, options: {
  56207. path: Vector3[];
  56208. radius?: number;
  56209. tessellation?: number;
  56210. radiusFunction?: {
  56211. (i: number, distance: number): number;
  56212. };
  56213. cap?: number;
  56214. arc?: number;
  56215. updatable?: boolean;
  56216. sideOrientation?: number;
  56217. frontUVs?: Vector4;
  56218. backUVs?: Vector4;
  56219. instance?: Mesh;
  56220. invertUV?: boolean;
  56221. }, scene?: Nullable<Scene>): Mesh;
  56222. /**
  56223. * Creates a polyhedron mesh
  56224. * * 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
  56225. * * The parameter `size` (positive float, default 1) sets the polygon size
  56226. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56227. * * 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`
  56228. * * 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
  56229. * * 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)`)
  56230. * * 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
  56231. * * 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
  56232. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56233. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56234. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56235. * @param name defines the name of the mesh
  56236. * @param options defines the options used to create the mesh
  56237. * @param scene defines the hosting scene
  56238. * @returns the polyhedron mesh
  56239. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56240. */
  56241. static CreatePolyhedron(name: string, options: {
  56242. type?: number;
  56243. size?: number;
  56244. sizeX?: number;
  56245. sizeY?: number;
  56246. sizeZ?: number;
  56247. custom?: any;
  56248. faceUV?: Vector4[];
  56249. faceColors?: Color4[];
  56250. flat?: boolean;
  56251. updatable?: boolean;
  56252. sideOrientation?: number;
  56253. frontUVs?: Vector4;
  56254. backUVs?: Vector4;
  56255. }, scene?: Nullable<Scene>): Mesh;
  56256. /**
  56257. * Creates a decal mesh.
  56258. * 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
  56259. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  56260. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  56261. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  56262. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  56263. * @param name defines the name of the mesh
  56264. * @param sourceMesh defines the mesh where the decal must be applied
  56265. * @param options defines the options used to create the mesh
  56266. * @param scene defines the hosting scene
  56267. * @returns the decal mesh
  56268. * @see https://doc.babylonjs.com/how_to/decals
  56269. */
  56270. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  56271. position?: Vector3;
  56272. normal?: Vector3;
  56273. size?: Vector3;
  56274. angle?: number;
  56275. }): Mesh;
  56276. }
  56277. }
  56278. declare module "babylonjs/Meshes/meshSimplification" {
  56279. import { Mesh } from "babylonjs/Meshes/mesh";
  56280. /**
  56281. * A simplifier interface for future simplification implementations
  56282. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56283. */
  56284. export interface ISimplifier {
  56285. /**
  56286. * Simplification of a given mesh according to the given settings.
  56287. * Since this requires computation, it is assumed that the function runs async.
  56288. * @param settings The settings of the simplification, including quality and distance
  56289. * @param successCallback A callback that will be called after the mesh was simplified.
  56290. * @param errorCallback in case of an error, this callback will be called. optional.
  56291. */
  56292. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  56293. }
  56294. /**
  56295. * Expected simplification settings.
  56296. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  56297. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56298. */
  56299. export interface ISimplificationSettings {
  56300. /**
  56301. * Gets or sets the expected quality
  56302. */
  56303. quality: number;
  56304. /**
  56305. * Gets or sets the distance when this optimized version should be used
  56306. */
  56307. distance: number;
  56308. /**
  56309. * Gets an already optimized mesh
  56310. */
  56311. optimizeMesh?: boolean;
  56312. }
  56313. /**
  56314. * Class used to specify simplification options
  56315. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56316. */
  56317. export class SimplificationSettings implements ISimplificationSettings {
  56318. /** expected quality */
  56319. quality: number;
  56320. /** distance when this optimized version should be used */
  56321. distance: number;
  56322. /** already optimized mesh */
  56323. optimizeMesh?: boolean | undefined;
  56324. /**
  56325. * Creates a SimplificationSettings
  56326. * @param quality expected quality
  56327. * @param distance distance when this optimized version should be used
  56328. * @param optimizeMesh already optimized mesh
  56329. */
  56330. constructor(
  56331. /** expected quality */
  56332. quality: number,
  56333. /** distance when this optimized version should be used */
  56334. distance: number,
  56335. /** already optimized mesh */
  56336. optimizeMesh?: boolean | undefined);
  56337. }
  56338. /**
  56339. * Interface used to define a simplification task
  56340. */
  56341. export interface ISimplificationTask {
  56342. /**
  56343. * Array of settings
  56344. */
  56345. settings: Array<ISimplificationSettings>;
  56346. /**
  56347. * Simplification type
  56348. */
  56349. simplificationType: SimplificationType;
  56350. /**
  56351. * Mesh to simplify
  56352. */
  56353. mesh: Mesh;
  56354. /**
  56355. * Callback called on success
  56356. */
  56357. successCallback?: () => void;
  56358. /**
  56359. * Defines if parallel processing can be used
  56360. */
  56361. parallelProcessing: boolean;
  56362. }
  56363. /**
  56364. * Queue used to order the simplification tasks
  56365. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56366. */
  56367. export class SimplificationQueue {
  56368. private _simplificationArray;
  56369. /**
  56370. * Gets a boolean indicating that the process is still running
  56371. */
  56372. running: boolean;
  56373. /**
  56374. * Creates a new queue
  56375. */
  56376. constructor();
  56377. /**
  56378. * Adds a new simplification task
  56379. * @param task defines a task to add
  56380. */
  56381. addTask(task: ISimplificationTask): void;
  56382. /**
  56383. * Execute next task
  56384. */
  56385. executeNext(): void;
  56386. /**
  56387. * Execute a simplification task
  56388. * @param task defines the task to run
  56389. */
  56390. runSimplification(task: ISimplificationTask): void;
  56391. private getSimplifier;
  56392. }
  56393. /**
  56394. * The implemented types of simplification
  56395. * At the moment only Quadratic Error Decimation is implemented
  56396. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56397. */
  56398. export enum SimplificationType {
  56399. /** Quadratic error decimation */
  56400. QUADRATIC = 0
  56401. }
  56402. }
  56403. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  56404. import { Scene } from "babylonjs/scene";
  56405. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  56406. import { ISceneComponent } from "babylonjs/sceneComponent";
  56407. module "babylonjs/scene" {
  56408. interface Scene {
  56409. /** @hidden (Backing field) */
  56410. _simplificationQueue: SimplificationQueue;
  56411. /**
  56412. * Gets or sets the simplification queue attached to the scene
  56413. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  56414. */
  56415. simplificationQueue: SimplificationQueue;
  56416. }
  56417. }
  56418. module "babylonjs/Meshes/mesh" {
  56419. interface Mesh {
  56420. /**
  56421. * Simplify the mesh according to the given array of settings.
  56422. * Function will return immediately and will simplify async
  56423. * @param settings a collection of simplification settings
  56424. * @param parallelProcessing should all levels calculate parallel or one after the other
  56425. * @param simplificationType the type of simplification to run
  56426. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  56427. * @returns the current mesh
  56428. */
  56429. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  56430. }
  56431. }
  56432. /**
  56433. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  56434. * created in a scene
  56435. */
  56436. export class SimplicationQueueSceneComponent implements ISceneComponent {
  56437. /**
  56438. * The component name helpfull to identify the component in the list of scene components.
  56439. */
  56440. readonly name: string;
  56441. /**
  56442. * The scene the component belongs to.
  56443. */
  56444. scene: Scene;
  56445. /**
  56446. * Creates a new instance of the component for the given scene
  56447. * @param scene Defines the scene to register the component in
  56448. */
  56449. constructor(scene: Scene);
  56450. /**
  56451. * Registers the component in a given scene
  56452. */
  56453. register(): void;
  56454. /**
  56455. * Rebuilds the elements related to this component in case of
  56456. * context lost for instance.
  56457. */
  56458. rebuild(): void;
  56459. /**
  56460. * Disposes the component and the associated ressources
  56461. */
  56462. dispose(): void;
  56463. private _beforeCameraUpdate;
  56464. }
  56465. }
  56466. declare module "babylonjs/Meshes/Builders/index" {
  56467. export * from "babylonjs/Meshes/Builders/boxBuilder";
  56468. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  56469. export * from "babylonjs/Meshes/Builders/discBuilder";
  56470. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  56471. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  56472. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  56473. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  56474. export * from "babylonjs/Meshes/Builders/torusBuilder";
  56475. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  56476. export * from "babylonjs/Meshes/Builders/linesBuilder";
  56477. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  56478. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  56479. export * from "babylonjs/Meshes/Builders/latheBuilder";
  56480. export * from "babylonjs/Meshes/Builders/planeBuilder";
  56481. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  56482. export * from "babylonjs/Meshes/Builders/groundBuilder";
  56483. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  56484. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  56485. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  56486. export * from "babylonjs/Meshes/Builders/decalBuilder";
  56487. }
  56488. declare module "babylonjs/Meshes/index" {
  56489. export * from "babylonjs/Meshes/abstractMesh";
  56490. export * from "babylonjs/Meshes/buffer";
  56491. export * from "babylonjs/Meshes/Compression/index";
  56492. export * from "babylonjs/Meshes/csg";
  56493. export * from "babylonjs/Meshes/geometry";
  56494. export * from "babylonjs/Meshes/groundMesh";
  56495. export * from "babylonjs/Meshes/trailMesh";
  56496. export * from "babylonjs/Meshes/instancedMesh";
  56497. export * from "babylonjs/Meshes/linesMesh";
  56498. export * from "babylonjs/Meshes/mesh";
  56499. export * from "babylonjs/Meshes/mesh.vertexData";
  56500. export * from "babylonjs/Meshes/meshBuilder";
  56501. export * from "babylonjs/Meshes/meshSimplification";
  56502. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  56503. export * from "babylonjs/Meshes/polygonMesh";
  56504. export * from "babylonjs/Meshes/subMesh";
  56505. export * from "babylonjs/Meshes/meshLODLevel";
  56506. export * from "babylonjs/Meshes/transformNode";
  56507. export * from "babylonjs/Meshes/Builders/index";
  56508. export * from "babylonjs/Meshes/dataBuffer";
  56509. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  56510. }
  56511. declare module "babylonjs/Morph/index" {
  56512. export * from "babylonjs/Morph/morphTarget";
  56513. export * from "babylonjs/Morph/morphTargetManager";
  56514. }
  56515. declare module "babylonjs/Offline/database" {
  56516. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  56517. /**
  56518. * Class used to enable access to IndexedDB
  56519. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  56520. */
  56521. export class Database implements IOfflineProvider {
  56522. private _callbackManifestChecked;
  56523. private _currentSceneUrl;
  56524. private _db;
  56525. private _enableSceneOffline;
  56526. private _enableTexturesOffline;
  56527. private _manifestVersionFound;
  56528. private _mustUpdateRessources;
  56529. private _hasReachedQuota;
  56530. private _isSupported;
  56531. private _idbFactory;
  56532. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  56533. private static IsUASupportingBlobStorage;
  56534. /**
  56535. * Gets a boolean indicating if Database storate is enabled (off by default)
  56536. */
  56537. static IDBStorageEnabled: boolean;
  56538. /**
  56539. * Gets a boolean indicating if scene must be saved in the database
  56540. */
  56541. readonly enableSceneOffline: boolean;
  56542. /**
  56543. * Gets a boolean indicating if textures must be saved in the database
  56544. */
  56545. readonly enableTexturesOffline: boolean;
  56546. /**
  56547. * Creates a new Database
  56548. * @param urlToScene defines the url to load the scene
  56549. * @param callbackManifestChecked defines the callback to use when manifest is checked
  56550. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  56551. */
  56552. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  56553. private static _ParseURL;
  56554. private static _ReturnFullUrlLocation;
  56555. private _checkManifestFile;
  56556. /**
  56557. * Open the database and make it available
  56558. * @param successCallback defines the callback to call on success
  56559. * @param errorCallback defines the callback to call on error
  56560. */
  56561. open(successCallback: () => void, errorCallback: () => void): void;
  56562. /**
  56563. * Loads an image from the database
  56564. * @param url defines the url to load from
  56565. * @param image defines the target DOM image
  56566. */
  56567. loadImage(url: string, image: HTMLImageElement): void;
  56568. private _loadImageFromDBAsync;
  56569. private _saveImageIntoDBAsync;
  56570. private _checkVersionFromDB;
  56571. private _loadVersionFromDBAsync;
  56572. private _saveVersionIntoDBAsync;
  56573. /**
  56574. * Loads a file from database
  56575. * @param url defines the URL to load from
  56576. * @param sceneLoaded defines a callback to call on success
  56577. * @param progressCallBack defines a callback to call when progress changed
  56578. * @param errorCallback defines a callback to call on error
  56579. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  56580. */
  56581. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  56582. private _loadFileAsync;
  56583. private _saveFileAsync;
  56584. /**
  56585. * Validates if xhr data is correct
  56586. * @param xhr defines the request to validate
  56587. * @param dataType defines the expected data type
  56588. * @returns true if data is correct
  56589. */
  56590. private static _ValidateXHRData;
  56591. }
  56592. }
  56593. declare module "babylonjs/Offline/index" {
  56594. export * from "babylonjs/Offline/database";
  56595. export * from "babylonjs/Offline/IOfflineProvider";
  56596. }
  56597. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  56598. /** @hidden */
  56599. export var gpuUpdateParticlesPixelShader: {
  56600. name: string;
  56601. shader: string;
  56602. };
  56603. }
  56604. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  56605. /** @hidden */
  56606. export var gpuUpdateParticlesVertexShader: {
  56607. name: string;
  56608. shader: string;
  56609. };
  56610. }
  56611. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  56612. /** @hidden */
  56613. export var clipPlaneFragmentDeclaration2: {
  56614. name: string;
  56615. shader: string;
  56616. };
  56617. }
  56618. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  56619. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  56620. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56621. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56622. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56623. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56624. /** @hidden */
  56625. export var gpuRenderParticlesPixelShader: {
  56626. name: string;
  56627. shader: string;
  56628. };
  56629. }
  56630. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  56631. /** @hidden */
  56632. export var clipPlaneVertexDeclaration2: {
  56633. name: string;
  56634. shader: string;
  56635. };
  56636. }
  56637. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  56638. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  56639. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56640. /** @hidden */
  56641. export var gpuRenderParticlesVertexShader: {
  56642. name: string;
  56643. shader: string;
  56644. };
  56645. }
  56646. declare module "babylonjs/Particles/gpuParticleSystem" {
  56647. import { Nullable } from "babylonjs/types";
  56648. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  56649. import { Observable } from "babylonjs/Misc/observable";
  56650. import { Color4, Color3 } from "babylonjs/Maths/math";
  56651. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56652. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  56653. import { Scene, IDisposable } from "babylonjs/scene";
  56654. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  56655. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  56656. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  56657. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  56658. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  56659. /**
  56660. * This represents a GPU particle system in Babylon
  56661. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  56662. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  56663. */
  56664. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  56665. /**
  56666. * The layer mask we are rendering the particles through.
  56667. */
  56668. layerMask: number;
  56669. private _capacity;
  56670. private _activeCount;
  56671. private _currentActiveCount;
  56672. private _accumulatedCount;
  56673. private _renderEffect;
  56674. private _updateEffect;
  56675. private _buffer0;
  56676. private _buffer1;
  56677. private _spriteBuffer;
  56678. private _updateVAO;
  56679. private _renderVAO;
  56680. private _targetIndex;
  56681. private _sourceBuffer;
  56682. private _targetBuffer;
  56683. private _engine;
  56684. private _currentRenderId;
  56685. private _started;
  56686. private _stopped;
  56687. private _timeDelta;
  56688. private _randomTexture;
  56689. private _randomTexture2;
  56690. private _attributesStrideSize;
  56691. private _updateEffectOptions;
  56692. private _randomTextureSize;
  56693. private _actualFrame;
  56694. private readonly _rawTextureWidth;
  56695. /**
  56696. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  56697. */
  56698. static readonly IsSupported: boolean;
  56699. /**
  56700. * An event triggered when the system is disposed.
  56701. */
  56702. onDisposeObservable: Observable<GPUParticleSystem>;
  56703. /**
  56704. * Gets the maximum number of particles active at the same time.
  56705. * @returns The max number of active particles.
  56706. */
  56707. getCapacity(): number;
  56708. /**
  56709. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  56710. * to override the particles.
  56711. */
  56712. forceDepthWrite: boolean;
  56713. /**
  56714. * Gets or set the number of active particles
  56715. */
  56716. activeParticleCount: number;
  56717. private _preWarmDone;
  56718. /**
  56719. * Is this system ready to be used/rendered
  56720. * @return true if the system is ready
  56721. */
  56722. isReady(): boolean;
  56723. /**
  56724. * Gets if the system has been started. (Note: this will still be true after stop is called)
  56725. * @returns True if it has been started, otherwise false.
  56726. */
  56727. isStarted(): boolean;
  56728. /**
  56729. * Starts the particle system and begins to emit
  56730. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  56731. */
  56732. start(delay?: number): void;
  56733. /**
  56734. * Stops the particle system.
  56735. */
  56736. stop(): void;
  56737. /**
  56738. * Remove all active particles
  56739. */
  56740. reset(): void;
  56741. /**
  56742. * Returns the string "GPUParticleSystem"
  56743. * @returns a string containing the class name
  56744. */
  56745. getClassName(): string;
  56746. private _colorGradientsTexture;
  56747. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  56748. /**
  56749. * Adds a new color gradient
  56750. * @param gradient defines the gradient to use (between 0 and 1)
  56751. * @param color1 defines the color to affect to the specified gradient
  56752. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  56753. * @returns the current particle system
  56754. */
  56755. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  56756. /**
  56757. * Remove a specific color gradient
  56758. * @param gradient defines the gradient to remove
  56759. * @returns the current particle system
  56760. */
  56761. removeColorGradient(gradient: number): GPUParticleSystem;
  56762. private _angularSpeedGradientsTexture;
  56763. private _sizeGradientsTexture;
  56764. private _velocityGradientsTexture;
  56765. private _limitVelocityGradientsTexture;
  56766. private _dragGradientsTexture;
  56767. private _addFactorGradient;
  56768. /**
  56769. * Adds a new size gradient
  56770. * @param gradient defines the gradient to use (between 0 and 1)
  56771. * @param factor defines the size factor to affect to the specified gradient
  56772. * @returns the current particle system
  56773. */
  56774. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  56775. /**
  56776. * Remove a specific size gradient
  56777. * @param gradient defines the gradient to remove
  56778. * @returns the current particle system
  56779. */
  56780. removeSizeGradient(gradient: number): GPUParticleSystem;
  56781. /**
  56782. * Adds a new angular speed gradient
  56783. * @param gradient defines the gradient to use (between 0 and 1)
  56784. * @param factor defines the angular speed to affect to the specified gradient
  56785. * @returns the current particle system
  56786. */
  56787. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  56788. /**
  56789. * Remove a specific angular speed gradient
  56790. * @param gradient defines the gradient to remove
  56791. * @returns the current particle system
  56792. */
  56793. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  56794. /**
  56795. * Adds a new velocity gradient
  56796. * @param gradient defines the gradient to use (between 0 and 1)
  56797. * @param factor defines the velocity to affect to the specified gradient
  56798. * @returns the current particle system
  56799. */
  56800. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56801. /**
  56802. * Remove a specific velocity gradient
  56803. * @param gradient defines the gradient to remove
  56804. * @returns the current particle system
  56805. */
  56806. removeVelocityGradient(gradient: number): GPUParticleSystem;
  56807. /**
  56808. * Adds a new limit velocity gradient
  56809. * @param gradient defines the gradient to use (between 0 and 1)
  56810. * @param factor defines the limit velocity value to affect to the specified gradient
  56811. * @returns the current particle system
  56812. */
  56813. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  56814. /**
  56815. * Remove a specific limit velocity gradient
  56816. * @param gradient defines the gradient to remove
  56817. * @returns the current particle system
  56818. */
  56819. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  56820. /**
  56821. * Adds a new drag gradient
  56822. * @param gradient defines the gradient to use (between 0 and 1)
  56823. * @param factor defines the drag value to affect to the specified gradient
  56824. * @returns the current particle system
  56825. */
  56826. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  56827. /**
  56828. * Remove a specific drag gradient
  56829. * @param gradient defines the gradient to remove
  56830. * @returns the current particle system
  56831. */
  56832. removeDragGradient(gradient: number): GPUParticleSystem;
  56833. /**
  56834. * Not supported by GPUParticleSystem
  56835. * @param gradient defines the gradient to use (between 0 and 1)
  56836. * @param factor defines the emit rate value to affect to the specified gradient
  56837. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56838. * @returns the current particle system
  56839. */
  56840. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56841. /**
  56842. * Not supported by GPUParticleSystem
  56843. * @param gradient defines the gradient to remove
  56844. * @returns the current particle system
  56845. */
  56846. removeEmitRateGradient(gradient: number): IParticleSystem;
  56847. /**
  56848. * Not supported by GPUParticleSystem
  56849. * @param gradient defines the gradient to use (between 0 and 1)
  56850. * @param factor defines the start size value to affect to the specified gradient
  56851. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56852. * @returns the current particle system
  56853. */
  56854. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56855. /**
  56856. * Not supported by GPUParticleSystem
  56857. * @param gradient defines the gradient to remove
  56858. * @returns the current particle system
  56859. */
  56860. removeStartSizeGradient(gradient: number): IParticleSystem;
  56861. /**
  56862. * Not supported by GPUParticleSystem
  56863. * @param gradient defines the gradient to use (between 0 and 1)
  56864. * @param min defines the color remap minimal range
  56865. * @param max defines the color remap maximal range
  56866. * @returns the current particle system
  56867. */
  56868. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56869. /**
  56870. * Not supported by GPUParticleSystem
  56871. * @param gradient defines the gradient to remove
  56872. * @returns the current particle system
  56873. */
  56874. removeColorRemapGradient(): IParticleSystem;
  56875. /**
  56876. * Not supported by GPUParticleSystem
  56877. * @param gradient defines the gradient to use (between 0 and 1)
  56878. * @param min defines the alpha remap minimal range
  56879. * @param max defines the alpha remap maximal range
  56880. * @returns the current particle system
  56881. */
  56882. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56883. /**
  56884. * Not supported by GPUParticleSystem
  56885. * @param gradient defines the gradient to remove
  56886. * @returns the current particle system
  56887. */
  56888. removeAlphaRemapGradient(): IParticleSystem;
  56889. /**
  56890. * Not supported by GPUParticleSystem
  56891. * @param gradient defines the gradient to use (between 0 and 1)
  56892. * @param color defines the color to affect to the specified gradient
  56893. * @returns the current particle system
  56894. */
  56895. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  56896. /**
  56897. * Not supported by GPUParticleSystem
  56898. * @param gradient defines the gradient to remove
  56899. * @returns the current particle system
  56900. */
  56901. removeRampGradient(): IParticleSystem;
  56902. /**
  56903. * Not supported by GPUParticleSystem
  56904. * @returns the list of ramp gradients
  56905. */
  56906. getRampGradients(): Nullable<Array<Color3Gradient>>;
  56907. /**
  56908. * Not supported by GPUParticleSystem
  56909. * Gets or sets a boolean indicating that ramp gradients must be used
  56910. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  56911. */
  56912. useRampGradients: boolean;
  56913. /**
  56914. * Not supported by GPUParticleSystem
  56915. * @param gradient defines the gradient to use (between 0 and 1)
  56916. * @param factor defines the life time factor to affect to the specified gradient
  56917. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56918. * @returns the current particle system
  56919. */
  56920. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56921. /**
  56922. * Not supported by GPUParticleSystem
  56923. * @param gradient defines the gradient to remove
  56924. * @returns the current particle system
  56925. */
  56926. removeLifeTimeGradient(gradient: number): IParticleSystem;
  56927. /**
  56928. * Instantiates a GPU particle system.
  56929. * 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.
  56930. * @param name The name of the particle system
  56931. * @param options The options used to create the system
  56932. * @param scene The scene the particle system belongs to
  56933. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  56934. */
  56935. constructor(name: string, options: Partial<{
  56936. capacity: number;
  56937. randomTextureSize: number;
  56938. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  56939. protected _reset(): void;
  56940. private _createUpdateVAO;
  56941. private _createRenderVAO;
  56942. private _initialize;
  56943. /** @hidden */
  56944. _recreateUpdateEffect(): void;
  56945. /** @hidden */
  56946. _recreateRenderEffect(): void;
  56947. /**
  56948. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  56949. * @param preWarm defines if we are in the pre-warmimg phase
  56950. */
  56951. animate(preWarm?: boolean): void;
  56952. private _createFactorGradientTexture;
  56953. private _createSizeGradientTexture;
  56954. private _createAngularSpeedGradientTexture;
  56955. private _createVelocityGradientTexture;
  56956. private _createLimitVelocityGradientTexture;
  56957. private _createDragGradientTexture;
  56958. private _createColorGradientTexture;
  56959. /**
  56960. * Renders the particle system in its current state
  56961. * @param preWarm defines if the system should only update the particles but not render them
  56962. * @returns the current number of particles
  56963. */
  56964. render(preWarm?: boolean): number;
  56965. /**
  56966. * Rebuilds the particle system
  56967. */
  56968. rebuild(): void;
  56969. private _releaseBuffers;
  56970. private _releaseVAOs;
  56971. /**
  56972. * Disposes the particle system and free the associated resources
  56973. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  56974. */
  56975. dispose(disposeTexture?: boolean): void;
  56976. /**
  56977. * Clones the particle system.
  56978. * @param name The name of the cloned object
  56979. * @param newEmitter The new emitter to use
  56980. * @returns the cloned particle system
  56981. */
  56982. clone(name: string, newEmitter: any): GPUParticleSystem;
  56983. /**
  56984. * Serializes the particle system to a JSON object.
  56985. * @returns the JSON object
  56986. */
  56987. serialize(): any;
  56988. /**
  56989. * Parses a JSON object to create a GPU particle system.
  56990. * @param parsedParticleSystem The JSON object to parse
  56991. * @param scene The scene to create the particle system in
  56992. * @param rootUrl The root url to use to load external dependencies like texture
  56993. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  56994. * @returns the parsed GPU particle system
  56995. */
  56996. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  56997. }
  56998. }
  56999. declare module "babylonjs/Particles/particleSystemSet" {
  57000. import { Nullable } from "babylonjs/types";
  57001. import { Color3 } from "babylonjs/Maths/math";
  57002. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57004. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57005. import { Scene, IDisposable } from "babylonjs/scene";
  57006. /**
  57007. * Represents a set of particle systems working together to create a specific effect
  57008. */
  57009. export class ParticleSystemSet implements IDisposable {
  57010. private _emitterCreationOptions;
  57011. private _emitterNode;
  57012. /**
  57013. * Gets the particle system list
  57014. */
  57015. systems: IParticleSystem[];
  57016. /**
  57017. * Gets the emitter node used with this set
  57018. */
  57019. readonly emitterNode: Nullable<TransformNode>;
  57020. /**
  57021. * Creates a new emitter mesh as a sphere
  57022. * @param options defines the options used to create the sphere
  57023. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  57024. * @param scene defines the hosting scene
  57025. */
  57026. setEmitterAsSphere(options: {
  57027. diameter: number;
  57028. segments: number;
  57029. color: Color3;
  57030. }, renderingGroupId: number, scene: Scene): void;
  57031. /**
  57032. * Starts all particle systems of the set
  57033. * @param emitter defines an optional mesh to use as emitter for the particle systems
  57034. */
  57035. start(emitter?: AbstractMesh): void;
  57036. /**
  57037. * Release all associated resources
  57038. */
  57039. dispose(): void;
  57040. /**
  57041. * Serialize the set into a JSON compatible object
  57042. * @returns a JSON compatible representation of the set
  57043. */
  57044. serialize(): any;
  57045. /**
  57046. * Parse a new ParticleSystemSet from a serialized source
  57047. * @param data defines a JSON compatible representation of the set
  57048. * @param scene defines the hosting scene
  57049. * @param gpu defines if we want GPU particles or CPU particles
  57050. * @returns a new ParticleSystemSet
  57051. */
  57052. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  57053. }
  57054. }
  57055. declare module "babylonjs/Particles/particleHelper" {
  57056. import { Nullable } from "babylonjs/types";
  57057. import { Scene } from "babylonjs/scene";
  57058. import { Vector3 } from "babylonjs/Maths/math";
  57059. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57060. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57061. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  57062. /**
  57063. * This class is made for on one-liner static method to help creating particle system set.
  57064. */
  57065. export class ParticleHelper {
  57066. /**
  57067. * Gets or sets base Assets URL
  57068. */
  57069. static BaseAssetsUrl: string;
  57070. /**
  57071. * Create a default particle system that you can tweak
  57072. * @param emitter defines the emitter to use
  57073. * @param capacity defines the system capacity (default is 500 particles)
  57074. * @param scene defines the hosting scene
  57075. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  57076. * @returns the new Particle system
  57077. */
  57078. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  57079. /**
  57080. * This is the main static method (one-liner) of this helper to create different particle systems
  57081. * @param type This string represents the type to the particle system to create
  57082. * @param scene The scene where the particle system should live
  57083. * @param gpu If the system will use gpu
  57084. * @returns the ParticleSystemSet created
  57085. */
  57086. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  57087. /**
  57088. * Static function used to export a particle system to a ParticleSystemSet variable.
  57089. * Please note that the emitter shape is not exported
  57090. * @param systems defines the particle systems to export
  57091. * @returns the created particle system set
  57092. */
  57093. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  57094. }
  57095. }
  57096. declare module "babylonjs/Particles/particleSystemComponent" {
  57097. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57098. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  57099. import "babylonjs/Shaders/particles.vertex";
  57100. module "babylonjs/Engines/engine" {
  57101. interface Engine {
  57102. /**
  57103. * Create an effect to use with particle systems.
  57104. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  57105. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  57106. * @param uniformsNames defines a list of attribute names
  57107. * @param samplers defines an array of string used to represent textures
  57108. * @param defines defines the string containing the defines to use to compile the shaders
  57109. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  57110. * @param onCompiled defines a function to call when the effect creation is successful
  57111. * @param onError defines a function to call when the effect creation has failed
  57112. * @returns the new Effect
  57113. */
  57114. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  57115. }
  57116. }
  57117. module "babylonjs/Meshes/mesh" {
  57118. interface Mesh {
  57119. /**
  57120. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  57121. * @returns an array of IParticleSystem
  57122. */
  57123. getEmittedParticleSystems(): IParticleSystem[];
  57124. /**
  57125. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  57126. * @returns an array of IParticleSystem
  57127. */
  57128. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  57129. }
  57130. }
  57131. /**
  57132. * @hidden
  57133. */
  57134. export var _IDoNeedToBeInTheBuild: number;
  57135. }
  57136. declare module "babylonjs/Particles/index" {
  57137. export * from "babylonjs/Particles/baseParticleSystem";
  57138. export * from "babylonjs/Particles/EmitterTypes/index";
  57139. export * from "babylonjs/Particles/gpuParticleSystem";
  57140. export * from "babylonjs/Particles/IParticleSystem";
  57141. export * from "babylonjs/Particles/particle";
  57142. export * from "babylonjs/Particles/particleHelper";
  57143. export * from "babylonjs/Particles/particleSystem";
  57144. export * from "babylonjs/Particles/particleSystemComponent";
  57145. export * from "babylonjs/Particles/particleSystemSet";
  57146. export * from "babylonjs/Particles/solidParticle";
  57147. export * from "babylonjs/Particles/solidParticleSystem";
  57148. export * from "babylonjs/Particles/subEmitter";
  57149. }
  57150. declare module "babylonjs/Physics/physicsEngineComponent" {
  57151. import { Nullable } from "babylonjs/types";
  57152. import { Observable, Observer } from "babylonjs/Misc/observable";
  57153. import { Vector3 } from "babylonjs/Maths/math";
  57154. import { Mesh } from "babylonjs/Meshes/mesh";
  57155. import { ISceneComponent } from "babylonjs/sceneComponent";
  57156. import { Scene } from "babylonjs/scene";
  57157. import { Node } from "babylonjs/node";
  57158. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57159. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57160. module "babylonjs/scene" {
  57161. interface Scene {
  57162. /** @hidden (Backing field) */
  57163. _physicsEngine: Nullable<IPhysicsEngine>;
  57164. /**
  57165. * Gets the current physics engine
  57166. * @returns a IPhysicsEngine or null if none attached
  57167. */
  57168. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  57169. /**
  57170. * Enables physics to the current scene
  57171. * @param gravity defines the scene's gravity for the physics engine
  57172. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  57173. * @return a boolean indicating if the physics engine was initialized
  57174. */
  57175. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  57176. /**
  57177. * Disables and disposes the physics engine associated with the scene
  57178. */
  57179. disablePhysicsEngine(): void;
  57180. /**
  57181. * Gets a boolean indicating if there is an active physics engine
  57182. * @returns a boolean indicating if there is an active physics engine
  57183. */
  57184. isPhysicsEnabled(): boolean;
  57185. /**
  57186. * Deletes a physics compound impostor
  57187. * @param compound defines the compound to delete
  57188. */
  57189. deleteCompoundImpostor(compound: any): void;
  57190. /**
  57191. * An event triggered when physic simulation is about to be run
  57192. */
  57193. onBeforePhysicsObservable: Observable<Scene>;
  57194. /**
  57195. * An event triggered when physic simulation has been done
  57196. */
  57197. onAfterPhysicsObservable: Observable<Scene>;
  57198. }
  57199. }
  57200. module "babylonjs/Meshes/abstractMesh" {
  57201. interface AbstractMesh {
  57202. /** @hidden */
  57203. _physicsImpostor: Nullable<PhysicsImpostor>;
  57204. /**
  57205. * Gets or sets impostor used for physic simulation
  57206. * @see http://doc.babylonjs.com/features/physics_engine
  57207. */
  57208. physicsImpostor: Nullable<PhysicsImpostor>;
  57209. /**
  57210. * Gets the current physics impostor
  57211. * @see http://doc.babylonjs.com/features/physics_engine
  57212. * @returns a physics impostor or null
  57213. */
  57214. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  57215. /** Apply a physic impulse to the mesh
  57216. * @param force defines the force to apply
  57217. * @param contactPoint defines where to apply the force
  57218. * @returns the current mesh
  57219. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57220. */
  57221. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  57222. /**
  57223. * Creates a physic joint between two meshes
  57224. * @param otherMesh defines the other mesh to use
  57225. * @param pivot1 defines the pivot to use on this mesh
  57226. * @param pivot2 defines the pivot to use on the other mesh
  57227. * @param options defines additional options (can be plugin dependent)
  57228. * @returns the current mesh
  57229. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  57230. */
  57231. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  57232. /** @hidden */
  57233. _disposePhysicsObserver: Nullable<Observer<Node>>;
  57234. }
  57235. }
  57236. /**
  57237. * Defines the physics engine scene component responsible to manage a physics engine
  57238. */
  57239. export class PhysicsEngineSceneComponent implements ISceneComponent {
  57240. /**
  57241. * The component name helpful to identify the component in the list of scene components.
  57242. */
  57243. readonly name: string;
  57244. /**
  57245. * The scene the component belongs to.
  57246. */
  57247. scene: Scene;
  57248. /**
  57249. * Creates a new instance of the component for the given scene
  57250. * @param scene Defines the scene to register the component in
  57251. */
  57252. constructor(scene: Scene);
  57253. /**
  57254. * Registers the component in a given scene
  57255. */
  57256. register(): void;
  57257. /**
  57258. * Rebuilds the elements related to this component in case of
  57259. * context lost for instance.
  57260. */
  57261. rebuild(): void;
  57262. /**
  57263. * Disposes the component and the associated ressources
  57264. */
  57265. dispose(): void;
  57266. }
  57267. }
  57268. declare module "babylonjs/Physics/physicsHelper" {
  57269. import { Nullable } from "babylonjs/types";
  57270. import { Vector3 } from "babylonjs/Maths/math";
  57271. import { Mesh } from "babylonjs/Meshes/mesh";
  57272. import { Scene } from "babylonjs/scene";
  57273. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57274. /**
  57275. * A helper for physics simulations
  57276. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57277. */
  57278. export class PhysicsHelper {
  57279. private _scene;
  57280. private _physicsEngine;
  57281. /**
  57282. * Initializes the Physics helper
  57283. * @param scene Babylon.js scene
  57284. */
  57285. constructor(scene: Scene);
  57286. /**
  57287. * Applies a radial explosion impulse
  57288. * @param origin the origin of the explosion
  57289. * @param radiusOrEventOptions the radius or the options of radial explosion
  57290. * @param strength the explosion strength
  57291. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57292. * @returns A physics radial explosion event, or null
  57293. */
  57294. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57295. /**
  57296. * Applies a radial explosion force
  57297. * @param origin the origin of the explosion
  57298. * @param radiusOrEventOptions the radius or the options of radial explosion
  57299. * @param strength the explosion strength
  57300. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57301. * @returns A physics radial explosion event, or null
  57302. */
  57303. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  57304. /**
  57305. * Creates a gravitational field
  57306. * @param origin the origin of the explosion
  57307. * @param radiusOrEventOptions the radius or the options of radial explosion
  57308. * @param strength the explosion strength
  57309. * @param falloff possible options: Constant & Linear. Defaults to Constant
  57310. * @returns A physics gravitational field event, or null
  57311. */
  57312. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  57313. /**
  57314. * Creates a physics updraft event
  57315. * @param origin the origin of the updraft
  57316. * @param radiusOrEventOptions the radius or the options of the updraft
  57317. * @param strength the strength of the updraft
  57318. * @param height the height of the updraft
  57319. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  57320. * @returns A physics updraft event, or null
  57321. */
  57322. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  57323. /**
  57324. * Creates a physics vortex event
  57325. * @param origin the of the vortex
  57326. * @param radiusOrEventOptions the radius or the options of the vortex
  57327. * @param strength the strength of the vortex
  57328. * @param height the height of the vortex
  57329. * @returns a Physics vortex event, or null
  57330. * A physics vortex event or null
  57331. */
  57332. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  57333. }
  57334. /**
  57335. * Represents a physics radial explosion event
  57336. */
  57337. class PhysicsRadialExplosionEvent {
  57338. private _scene;
  57339. private _options;
  57340. private _sphere;
  57341. private _dataFetched;
  57342. /**
  57343. * Initializes a radial explosioin event
  57344. * @param _scene BabylonJS scene
  57345. * @param _options The options for the vortex event
  57346. */
  57347. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  57348. /**
  57349. * Returns the data related to the radial explosion event (sphere).
  57350. * @returns The radial explosion event data
  57351. */
  57352. getData(): PhysicsRadialExplosionEventData;
  57353. /**
  57354. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  57355. * @param impostor A physics imposter
  57356. * @param origin the origin of the explosion
  57357. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  57358. */
  57359. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  57360. /**
  57361. * Triggers affecterd impostors callbacks
  57362. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  57363. */
  57364. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  57365. /**
  57366. * Disposes the sphere.
  57367. * @param force Specifies if the sphere should be disposed by force
  57368. */
  57369. dispose(force?: boolean): void;
  57370. /*** Helpers ***/
  57371. private _prepareSphere;
  57372. private _intersectsWithSphere;
  57373. }
  57374. /**
  57375. * Represents a gravitational field event
  57376. */
  57377. class PhysicsGravitationalFieldEvent {
  57378. private _physicsHelper;
  57379. private _scene;
  57380. private _origin;
  57381. private _options;
  57382. private _tickCallback;
  57383. private _sphere;
  57384. private _dataFetched;
  57385. /**
  57386. * Initializes the physics gravitational field event
  57387. * @param _physicsHelper A physics helper
  57388. * @param _scene BabylonJS scene
  57389. * @param _origin The origin position of the gravitational field event
  57390. * @param _options The options for the vortex event
  57391. */
  57392. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  57393. /**
  57394. * Returns the data related to the gravitational field event (sphere).
  57395. * @returns A gravitational field event
  57396. */
  57397. getData(): PhysicsGravitationalFieldEventData;
  57398. /**
  57399. * Enables the gravitational field.
  57400. */
  57401. enable(): void;
  57402. /**
  57403. * Disables the gravitational field.
  57404. */
  57405. disable(): void;
  57406. /**
  57407. * Disposes the sphere.
  57408. * @param force The force to dispose from the gravitational field event
  57409. */
  57410. dispose(force?: boolean): void;
  57411. private _tick;
  57412. }
  57413. /**
  57414. * Represents a physics updraft event
  57415. */
  57416. class PhysicsUpdraftEvent {
  57417. private _scene;
  57418. private _origin;
  57419. private _options;
  57420. private _physicsEngine;
  57421. private _originTop;
  57422. private _originDirection;
  57423. private _tickCallback;
  57424. private _cylinder;
  57425. private _cylinderPosition;
  57426. private _dataFetched;
  57427. /**
  57428. * Initializes the physics updraft event
  57429. * @param _scene BabylonJS scene
  57430. * @param _origin The origin position of the updraft
  57431. * @param _options The options for the updraft event
  57432. */
  57433. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  57434. /**
  57435. * Returns the data related to the updraft event (cylinder).
  57436. * @returns A physics updraft event
  57437. */
  57438. getData(): PhysicsUpdraftEventData;
  57439. /**
  57440. * Enables the updraft.
  57441. */
  57442. enable(): void;
  57443. /**
  57444. * Disables the updraft.
  57445. */
  57446. disable(): void;
  57447. /**
  57448. * Disposes the cylinder.
  57449. * @param force Specifies if the updraft should be disposed by force
  57450. */
  57451. dispose(force?: boolean): void;
  57452. private getImpostorHitData;
  57453. private _tick;
  57454. /*** Helpers ***/
  57455. private _prepareCylinder;
  57456. private _intersectsWithCylinder;
  57457. }
  57458. /**
  57459. * Represents a physics vortex event
  57460. */
  57461. class PhysicsVortexEvent {
  57462. private _scene;
  57463. private _origin;
  57464. private _options;
  57465. private _physicsEngine;
  57466. private _originTop;
  57467. private _tickCallback;
  57468. private _cylinder;
  57469. private _cylinderPosition;
  57470. private _dataFetched;
  57471. /**
  57472. * Initializes the physics vortex event
  57473. * @param _scene The BabylonJS scene
  57474. * @param _origin The origin position of the vortex
  57475. * @param _options The options for the vortex event
  57476. */
  57477. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  57478. /**
  57479. * Returns the data related to the vortex event (cylinder).
  57480. * @returns The physics vortex event data
  57481. */
  57482. getData(): PhysicsVortexEventData;
  57483. /**
  57484. * Enables the vortex.
  57485. */
  57486. enable(): void;
  57487. /**
  57488. * Disables the cortex.
  57489. */
  57490. disable(): void;
  57491. /**
  57492. * Disposes the sphere.
  57493. * @param force
  57494. */
  57495. dispose(force?: boolean): void;
  57496. private getImpostorHitData;
  57497. private _tick;
  57498. /*** Helpers ***/
  57499. private _prepareCylinder;
  57500. private _intersectsWithCylinder;
  57501. }
  57502. /**
  57503. * Options fot the radial explosion event
  57504. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57505. */
  57506. export class PhysicsRadialExplosionEventOptions {
  57507. /**
  57508. * The radius of the sphere for the radial explosion.
  57509. */
  57510. radius: number;
  57511. /**
  57512. * The strenth of the explosion.
  57513. */
  57514. strength: number;
  57515. /**
  57516. * The strenght of the force in correspondence to the distance of the affected object
  57517. */
  57518. falloff: PhysicsRadialImpulseFalloff;
  57519. /**
  57520. * Sphere options for the radial explosion.
  57521. */
  57522. sphere: {
  57523. segments: number;
  57524. diameter: number;
  57525. };
  57526. /**
  57527. * Sphere options for the radial explosion.
  57528. */
  57529. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  57530. }
  57531. /**
  57532. * Options fot the updraft event
  57533. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57534. */
  57535. export class PhysicsUpdraftEventOptions {
  57536. /**
  57537. * The radius of the cylinder for the vortex
  57538. */
  57539. radius: number;
  57540. /**
  57541. * The strenth of the updraft.
  57542. */
  57543. strength: number;
  57544. /**
  57545. * The height of the cylinder for the updraft.
  57546. */
  57547. height: number;
  57548. /**
  57549. * The mode for the the updraft.
  57550. */
  57551. updraftMode: PhysicsUpdraftMode;
  57552. }
  57553. /**
  57554. * Options fot the vortex event
  57555. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57556. */
  57557. export class PhysicsVortexEventOptions {
  57558. /**
  57559. * The radius of the cylinder for the vortex
  57560. */
  57561. radius: number;
  57562. /**
  57563. * The strenth of the vortex.
  57564. */
  57565. strength: number;
  57566. /**
  57567. * The height of the cylinder for the vortex.
  57568. */
  57569. height: number;
  57570. /**
  57571. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  57572. */
  57573. centripetalForceThreshold: number;
  57574. /**
  57575. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  57576. */
  57577. centripetalForceMultiplier: number;
  57578. /**
  57579. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  57580. */
  57581. centrifugalForceMultiplier: number;
  57582. /**
  57583. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  57584. */
  57585. updraftForceMultiplier: number;
  57586. }
  57587. /**
  57588. * The strenght of the force in correspondence to the distance of the affected object
  57589. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57590. */
  57591. export enum PhysicsRadialImpulseFalloff {
  57592. /** Defines that impulse is constant in strength across it's whole radius */
  57593. Constant = 0,
  57594. /** Defines that impulse gets weaker if it's further from the origin */
  57595. Linear = 1
  57596. }
  57597. /**
  57598. * The strength of the force in correspondence to the distance of the affected object
  57599. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57600. */
  57601. export enum PhysicsUpdraftMode {
  57602. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  57603. Center = 0,
  57604. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  57605. Perpendicular = 1
  57606. }
  57607. /**
  57608. * Interface for a physics hit data
  57609. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57610. */
  57611. export interface PhysicsHitData {
  57612. /**
  57613. * The force applied at the contact point
  57614. */
  57615. force: Vector3;
  57616. /**
  57617. * The contact point
  57618. */
  57619. contactPoint: Vector3;
  57620. /**
  57621. * The distance from the origin to the contact point
  57622. */
  57623. distanceFromOrigin: number;
  57624. }
  57625. /**
  57626. * Interface for radial explosion event data
  57627. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57628. */
  57629. export interface PhysicsRadialExplosionEventData {
  57630. /**
  57631. * A sphere used for the radial explosion event
  57632. */
  57633. sphere: Mesh;
  57634. }
  57635. /**
  57636. * Interface for gravitational field event data
  57637. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57638. */
  57639. export interface PhysicsGravitationalFieldEventData {
  57640. /**
  57641. * A sphere mesh used for the gravitational field event
  57642. */
  57643. sphere: Mesh;
  57644. }
  57645. /**
  57646. * Interface for updraft event data
  57647. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57648. */
  57649. export interface PhysicsUpdraftEventData {
  57650. /**
  57651. * A cylinder used for the updraft event
  57652. */
  57653. cylinder: Mesh;
  57654. }
  57655. /**
  57656. * Interface for vortex event data
  57657. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57658. */
  57659. export interface PhysicsVortexEventData {
  57660. /**
  57661. * A cylinder used for the vortex event
  57662. */
  57663. cylinder: Mesh;
  57664. }
  57665. /**
  57666. * Interface for an affected physics impostor
  57667. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  57668. */
  57669. export interface PhysicsAffectedImpostorWithData {
  57670. /**
  57671. * The impostor affected by the effect
  57672. */
  57673. impostor: PhysicsImpostor;
  57674. /**
  57675. * The data about the hit/horce from the explosion
  57676. */
  57677. hitData: PhysicsHitData;
  57678. }
  57679. }
  57680. declare module "babylonjs/Physics/Plugins/index" {
  57681. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  57682. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  57683. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  57684. }
  57685. declare module "babylonjs/Physics/index" {
  57686. export * from "babylonjs/Physics/IPhysicsEngine";
  57687. export * from "babylonjs/Physics/physicsEngine";
  57688. export * from "babylonjs/Physics/physicsEngineComponent";
  57689. export * from "babylonjs/Physics/physicsHelper";
  57690. export * from "babylonjs/Physics/physicsImpostor";
  57691. export * from "babylonjs/Physics/physicsJoint";
  57692. export * from "babylonjs/Physics/Plugins/index";
  57693. }
  57694. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  57695. /** @hidden */
  57696. export var blackAndWhitePixelShader: {
  57697. name: string;
  57698. shader: string;
  57699. };
  57700. }
  57701. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  57702. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57703. import { Camera } from "babylonjs/Cameras/camera";
  57704. import { Engine } from "babylonjs/Engines/engine";
  57705. import "babylonjs/Shaders/blackAndWhite.fragment";
  57706. /**
  57707. * Post process used to render in black and white
  57708. */
  57709. export class BlackAndWhitePostProcess extends PostProcess {
  57710. /**
  57711. * Linear about to convert he result to black and white (default: 1)
  57712. */
  57713. degree: number;
  57714. /**
  57715. * Creates a black and white post process
  57716. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  57717. * @param name The name of the effect.
  57718. * @param options The required width/height ratio to downsize to before computing the render pass.
  57719. * @param camera The camera to apply the render pass to.
  57720. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57721. * @param engine The engine which the post process will be applied. (default: current engine)
  57722. * @param reusable If the post process can be reused on the same frame. (default: false)
  57723. */
  57724. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57725. }
  57726. }
  57727. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  57728. import { Nullable } from "babylonjs/types";
  57729. import { Camera } from "babylonjs/Cameras/camera";
  57730. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57731. import { Engine } from "babylonjs/Engines/engine";
  57732. /**
  57733. * This represents a set of one or more post processes in Babylon.
  57734. * A post process can be used to apply a shader to a texture after it is rendered.
  57735. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57736. */
  57737. export class PostProcessRenderEffect {
  57738. private _postProcesses;
  57739. private _getPostProcesses;
  57740. private _singleInstance;
  57741. private _cameras;
  57742. private _indicesForCamera;
  57743. /**
  57744. * Name of the effect
  57745. * @hidden
  57746. */
  57747. _name: string;
  57748. /**
  57749. * Instantiates a post process render effect.
  57750. * A post process can be used to apply a shader to a texture after it is rendered.
  57751. * @param engine The engine the effect is tied to
  57752. * @param name The name of the effect
  57753. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  57754. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  57755. */
  57756. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  57757. /**
  57758. * Checks if all the post processes in the effect are supported.
  57759. */
  57760. readonly isSupported: boolean;
  57761. /**
  57762. * Updates the current state of the effect
  57763. * @hidden
  57764. */
  57765. _update(): void;
  57766. /**
  57767. * Attaches the effect on cameras
  57768. * @param cameras The camera to attach to.
  57769. * @hidden
  57770. */
  57771. _attachCameras(cameras: Camera): void;
  57772. /**
  57773. * Attaches the effect on cameras
  57774. * @param cameras The camera to attach to.
  57775. * @hidden
  57776. */
  57777. _attachCameras(cameras: Camera[]): void;
  57778. /**
  57779. * Detaches the effect on cameras
  57780. * @param cameras The camera to detatch from.
  57781. * @hidden
  57782. */
  57783. _detachCameras(cameras: Camera): void;
  57784. /**
  57785. * Detatches the effect on cameras
  57786. * @param cameras The camera to detatch from.
  57787. * @hidden
  57788. */
  57789. _detachCameras(cameras: Camera[]): void;
  57790. /**
  57791. * Enables the effect on given cameras
  57792. * @param cameras The camera to enable.
  57793. * @hidden
  57794. */
  57795. _enable(cameras: Camera): void;
  57796. /**
  57797. * Enables the effect on given cameras
  57798. * @param cameras The camera to enable.
  57799. * @hidden
  57800. */
  57801. _enable(cameras: Nullable<Camera[]>): void;
  57802. /**
  57803. * Disables the effect on the given cameras
  57804. * @param cameras The camera to disable.
  57805. * @hidden
  57806. */
  57807. _disable(cameras: Camera): void;
  57808. /**
  57809. * Disables the effect on the given cameras
  57810. * @param cameras The camera to disable.
  57811. * @hidden
  57812. */
  57813. _disable(cameras: Nullable<Camera[]>): void;
  57814. /**
  57815. * Gets a list of the post processes contained in the effect.
  57816. * @param camera The camera to get the post processes on.
  57817. * @returns The list of the post processes in the effect.
  57818. */
  57819. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  57820. }
  57821. }
  57822. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  57823. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57824. /** @hidden */
  57825. export var extractHighlightsPixelShader: {
  57826. name: string;
  57827. shader: string;
  57828. };
  57829. }
  57830. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  57831. import { Nullable } from "babylonjs/types";
  57832. import { Camera } from "babylonjs/Cameras/camera";
  57833. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57834. import { Engine } from "babylonjs/Engines/engine";
  57835. import "babylonjs/Shaders/extractHighlights.fragment";
  57836. /**
  57837. * 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.
  57838. */
  57839. export class ExtractHighlightsPostProcess extends PostProcess {
  57840. /**
  57841. * The luminance threshold, pixels below this value will be set to black.
  57842. */
  57843. threshold: number;
  57844. /** @hidden */
  57845. _exposure: number;
  57846. /**
  57847. * Post process which has the input texture to be used when performing highlight extraction
  57848. * @hidden
  57849. */
  57850. _inputPostProcess: Nullable<PostProcess>;
  57851. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57852. }
  57853. }
  57854. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  57855. /** @hidden */
  57856. export var bloomMergePixelShader: {
  57857. name: string;
  57858. shader: string;
  57859. };
  57860. }
  57861. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  57862. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57863. import { Nullable } from "babylonjs/types";
  57864. import { Engine } from "babylonjs/Engines/engine";
  57865. import { Camera } from "babylonjs/Cameras/camera";
  57866. import "babylonjs/Shaders/bloomMerge.fragment";
  57867. /**
  57868. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57869. */
  57870. export class BloomMergePostProcess extends PostProcess {
  57871. /** Weight of the bloom to be added to the original input. */
  57872. weight: number;
  57873. /**
  57874. * Creates a new instance of @see BloomMergePostProcess
  57875. * @param name The name of the effect.
  57876. * @param originalFromInput Post process which's input will be used for the merge.
  57877. * @param blurred Blurred highlights post process which's output will be used.
  57878. * @param weight Weight of the bloom to be added to the original input.
  57879. * @param options The required width/height ratio to downsize to before computing the render pass.
  57880. * @param camera The camera to apply the render pass to.
  57881. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57882. * @param engine The engine which the post process will be applied. (default: current engine)
  57883. * @param reusable If the post process can be reused on the same frame. (default: false)
  57884. * @param textureType Type of textures used when performing the post process. (default: 0)
  57885. * @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)
  57886. */
  57887. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  57888. /** Weight of the bloom to be added to the original input. */
  57889. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57890. }
  57891. }
  57892. declare module "babylonjs/PostProcesses/bloomEffect" {
  57893. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  57894. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57895. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  57896. import { Camera } from "babylonjs/Cameras/camera";
  57897. import { Scene } from "babylonjs/scene";
  57898. /**
  57899. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  57900. */
  57901. export class BloomEffect extends PostProcessRenderEffect {
  57902. private bloomScale;
  57903. /**
  57904. * @hidden Internal
  57905. */
  57906. _effects: Array<PostProcess>;
  57907. /**
  57908. * @hidden Internal
  57909. */
  57910. _downscale: ExtractHighlightsPostProcess;
  57911. private _blurX;
  57912. private _blurY;
  57913. private _merge;
  57914. /**
  57915. * The luminance threshold to find bright areas of the image to bloom.
  57916. */
  57917. threshold: number;
  57918. /**
  57919. * The strength of the bloom.
  57920. */
  57921. weight: number;
  57922. /**
  57923. * Specifies the size of the bloom blur kernel, relative to the final output size
  57924. */
  57925. kernel: number;
  57926. /**
  57927. * Creates a new instance of @see BloomEffect
  57928. * @param scene The scene the effect belongs to.
  57929. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  57930. * @param bloomKernel The size of the kernel to be used when applying the blur.
  57931. * @param bloomWeight The the strength of bloom.
  57932. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57933. * @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)
  57934. */
  57935. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  57936. /**
  57937. * Disposes each of the internal effects for a given camera.
  57938. * @param camera The camera to dispose the effect on.
  57939. */
  57940. disposeEffects(camera: Camera): void;
  57941. /**
  57942. * @hidden Internal
  57943. */
  57944. _updateEffects(): void;
  57945. /**
  57946. * Internal
  57947. * @returns if all the contained post processes are ready.
  57948. * @hidden
  57949. */
  57950. _isReady(): boolean;
  57951. }
  57952. }
  57953. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  57954. /** @hidden */
  57955. export var chromaticAberrationPixelShader: {
  57956. name: string;
  57957. shader: string;
  57958. };
  57959. }
  57960. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  57961. import { Vector2 } from "babylonjs/Maths/math";
  57962. import { Nullable } from "babylonjs/types";
  57963. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57964. import { Camera } from "babylonjs/Cameras/camera";
  57965. import { Engine } from "babylonjs/Engines/engine";
  57966. import "babylonjs/Shaders/chromaticAberration.fragment";
  57967. /**
  57968. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  57969. */
  57970. export class ChromaticAberrationPostProcess extends PostProcess {
  57971. /**
  57972. * The amount of seperation of rgb channels (default: 30)
  57973. */
  57974. aberrationAmount: number;
  57975. /**
  57976. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  57977. */
  57978. radialIntensity: number;
  57979. /**
  57980. * 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))
  57981. */
  57982. direction: Vector2;
  57983. /**
  57984. * 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))
  57985. */
  57986. centerPosition: Vector2;
  57987. /**
  57988. * Creates a new instance ChromaticAberrationPostProcess
  57989. * @param name The name of the effect.
  57990. * @param screenWidth The width of the screen to apply the effect on.
  57991. * @param screenHeight The height of the screen to apply the effect on.
  57992. * @param options The required width/height ratio to downsize to before computing the render pass.
  57993. * @param camera The camera to apply the render pass to.
  57994. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57995. * @param engine The engine which the post process will be applied. (default: current engine)
  57996. * @param reusable If the post process can be reused on the same frame. (default: false)
  57997. * @param textureType Type of textures used when performing the post process. (default: 0)
  57998. * @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)
  57999. */
  58000. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58001. }
  58002. }
  58003. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  58004. /** @hidden */
  58005. export var circleOfConfusionPixelShader: {
  58006. name: string;
  58007. shader: string;
  58008. };
  58009. }
  58010. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  58011. import { Nullable } from "babylonjs/types";
  58012. import { Engine } from "babylonjs/Engines/engine";
  58013. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58014. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58015. import { Camera } from "babylonjs/Cameras/camera";
  58016. import "babylonjs/Shaders/circleOfConfusion.fragment";
  58017. /**
  58018. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  58019. */
  58020. export class CircleOfConfusionPostProcess extends PostProcess {
  58021. /**
  58022. * 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.
  58023. */
  58024. lensSize: number;
  58025. /**
  58026. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58027. */
  58028. fStop: number;
  58029. /**
  58030. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58031. */
  58032. focusDistance: number;
  58033. /**
  58034. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  58035. */
  58036. focalLength: number;
  58037. private _depthTexture;
  58038. /**
  58039. * Creates a new instance CircleOfConfusionPostProcess
  58040. * @param name The name of the effect.
  58041. * @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.
  58042. * @param options The required width/height ratio to downsize to before computing the render pass.
  58043. * @param camera The camera to apply the render pass to.
  58044. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58045. * @param engine The engine which the post process will be applied. (default: current engine)
  58046. * @param reusable If the post process can be reused on the same frame. (default: false)
  58047. * @param textureType Type of textures used when performing the post process. (default: 0)
  58048. * @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)
  58049. */
  58050. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58051. /**
  58052. * 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.
  58053. */
  58054. depthTexture: RenderTargetTexture;
  58055. }
  58056. }
  58057. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  58058. /** @hidden */
  58059. export var colorCorrectionPixelShader: {
  58060. name: string;
  58061. shader: string;
  58062. };
  58063. }
  58064. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  58065. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58066. import { Engine } from "babylonjs/Engines/engine";
  58067. import { Camera } from "babylonjs/Cameras/camera";
  58068. import "babylonjs/Shaders/colorCorrection.fragment";
  58069. /**
  58070. *
  58071. * This post-process allows the modification of rendered colors by using
  58072. * a 'look-up table' (LUT). This effect is also called Color Grading.
  58073. *
  58074. * The object needs to be provided an url to a texture containing the color
  58075. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  58076. * Use an image editing software to tweak the LUT to match your needs.
  58077. *
  58078. * For an example of a color LUT, see here:
  58079. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  58080. * For explanations on color grading, see here:
  58081. * @see http://udn.epicgames.com/Three/ColorGrading.html
  58082. *
  58083. */
  58084. export class ColorCorrectionPostProcess extends PostProcess {
  58085. private _colorTableTexture;
  58086. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58087. }
  58088. }
  58089. declare module "babylonjs/Shaders/convolution.fragment" {
  58090. /** @hidden */
  58091. export var convolutionPixelShader: {
  58092. name: string;
  58093. shader: string;
  58094. };
  58095. }
  58096. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  58097. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58098. import { Nullable } from "babylonjs/types";
  58099. import { Camera } from "babylonjs/Cameras/camera";
  58100. import { Engine } from "babylonjs/Engines/engine";
  58101. import "babylonjs/Shaders/convolution.fragment";
  58102. /**
  58103. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  58104. * input texture to perform effects such as edge detection or sharpening
  58105. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58106. */
  58107. export class ConvolutionPostProcess extends PostProcess {
  58108. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58109. kernel: number[];
  58110. /**
  58111. * Creates a new instance ConvolutionPostProcess
  58112. * @param name The name of the effect.
  58113. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  58114. * @param options The required width/height ratio to downsize to before computing the render pass.
  58115. * @param camera The camera to apply the render pass to.
  58116. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58117. * @param engine The engine which the post process will be applied. (default: current engine)
  58118. * @param reusable If the post process can be reused on the same frame. (default: false)
  58119. * @param textureType Type of textures used when performing the post process. (default: 0)
  58120. */
  58121. constructor(name: string,
  58122. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  58123. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58124. /**
  58125. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58126. */
  58127. static EdgeDetect0Kernel: number[];
  58128. /**
  58129. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58130. */
  58131. static EdgeDetect1Kernel: number[];
  58132. /**
  58133. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58134. */
  58135. static EdgeDetect2Kernel: number[];
  58136. /**
  58137. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58138. */
  58139. static SharpenKernel: number[];
  58140. /**
  58141. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58142. */
  58143. static EmbossKernel: number[];
  58144. /**
  58145. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  58146. */
  58147. static GaussianKernel: number[];
  58148. }
  58149. }
  58150. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  58151. import { Nullable } from "babylonjs/types";
  58152. import { Vector2 } from "babylonjs/Maths/math";
  58153. import { Camera } from "babylonjs/Cameras/camera";
  58154. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58155. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  58156. import { Engine } from "babylonjs/Engines/engine";
  58157. import { Scene } from "babylonjs/scene";
  58158. /**
  58159. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  58160. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  58161. * based on samples that have a large difference in distance than the center pixel.
  58162. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  58163. */
  58164. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  58165. direction: Vector2;
  58166. /**
  58167. * Creates a new instance CircleOfConfusionPostProcess
  58168. * @param name The name of the effect.
  58169. * @param scene The scene the effect belongs to.
  58170. * @param direction The direction the blur should be applied.
  58171. * @param kernel The size of the kernel used to blur.
  58172. * @param options The required width/height ratio to downsize to before computing the render pass.
  58173. * @param camera The camera to apply the render pass to.
  58174. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  58175. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  58176. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58177. * @param engine The engine which the post process will be applied. (default: current engine)
  58178. * @param reusable If the post process can be reused on the same frame. (default: false)
  58179. * @param textureType Type of textures used when performing the post process. (default: 0)
  58180. * @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)
  58181. */
  58182. 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);
  58183. }
  58184. }
  58185. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  58186. /** @hidden */
  58187. export var depthOfFieldMergePixelShader: {
  58188. name: string;
  58189. shader: string;
  58190. };
  58191. }
  58192. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  58193. import { Nullable } from "babylonjs/types";
  58194. import { Camera } from "babylonjs/Cameras/camera";
  58195. import { Effect } from "babylonjs/Materials/effect";
  58196. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58197. import { Engine } from "babylonjs/Engines/engine";
  58198. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  58199. /**
  58200. * Options to be set when merging outputs from the default pipeline.
  58201. */
  58202. export class DepthOfFieldMergePostProcessOptions {
  58203. /**
  58204. * The original image to merge on top of
  58205. */
  58206. originalFromInput: PostProcess;
  58207. /**
  58208. * Parameters to perform the merge of the depth of field effect
  58209. */
  58210. depthOfField?: {
  58211. circleOfConfusion: PostProcess;
  58212. blurSteps: Array<PostProcess>;
  58213. };
  58214. /**
  58215. * Parameters to perform the merge of bloom effect
  58216. */
  58217. bloom?: {
  58218. blurred: PostProcess;
  58219. weight: number;
  58220. };
  58221. }
  58222. /**
  58223. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  58224. */
  58225. export class DepthOfFieldMergePostProcess extends PostProcess {
  58226. private blurSteps;
  58227. /**
  58228. * Creates a new instance of DepthOfFieldMergePostProcess
  58229. * @param name The name of the effect.
  58230. * @param originalFromInput Post process which's input will be used for the merge.
  58231. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  58232. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  58233. * @param options The required width/height ratio to downsize to before computing the render pass.
  58234. * @param camera The camera to apply the render pass to.
  58235. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58236. * @param engine The engine which the post process will be applied. (default: current engine)
  58237. * @param reusable If the post process can be reused on the same frame. (default: false)
  58238. * @param textureType Type of textures used when performing the post process. (default: 0)
  58239. * @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)
  58240. */
  58241. 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);
  58242. /**
  58243. * Updates the effect with the current post process compile time values and recompiles the shader.
  58244. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  58245. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  58246. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  58247. * @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
  58248. * @param onCompiled Called when the shader has been compiled.
  58249. * @param onError Called if there is an error when compiling a shader.
  58250. */
  58251. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  58252. }
  58253. }
  58254. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  58255. import { Nullable } from "babylonjs/types";
  58256. import { Camera } from "babylonjs/Cameras/camera";
  58257. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58258. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  58259. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  58260. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  58261. import { Scene } from "babylonjs/scene";
  58262. /**
  58263. * Specifies the level of max blur that should be applied when using the depth of field effect
  58264. */
  58265. export enum DepthOfFieldEffectBlurLevel {
  58266. /**
  58267. * Subtle blur
  58268. */
  58269. Low = 0,
  58270. /**
  58271. * Medium blur
  58272. */
  58273. Medium = 1,
  58274. /**
  58275. * Large blur
  58276. */
  58277. High = 2
  58278. }
  58279. /**
  58280. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  58281. */
  58282. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  58283. private _circleOfConfusion;
  58284. /**
  58285. * @hidden Internal, blurs from high to low
  58286. */
  58287. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  58288. private _depthOfFieldBlurY;
  58289. private _dofMerge;
  58290. /**
  58291. * @hidden Internal post processes in depth of field effect
  58292. */
  58293. _effects: Array<PostProcess>;
  58294. /**
  58295. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  58296. */
  58297. focalLength: number;
  58298. /**
  58299. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  58300. */
  58301. fStop: number;
  58302. /**
  58303. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  58304. */
  58305. focusDistance: number;
  58306. /**
  58307. * 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.
  58308. */
  58309. lensSize: number;
  58310. /**
  58311. * Creates a new instance DepthOfFieldEffect
  58312. * @param scene The scene the effect belongs to.
  58313. * @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.
  58314. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  58315. * @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)
  58316. */
  58317. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  58318. /**
  58319. * Get the current class name of the current effet
  58320. * @returns "DepthOfFieldEffect"
  58321. */
  58322. getClassName(): string;
  58323. /**
  58324. * 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.
  58325. */
  58326. depthTexture: RenderTargetTexture;
  58327. /**
  58328. * Disposes each of the internal effects for a given camera.
  58329. * @param camera The camera to dispose the effect on.
  58330. */
  58331. disposeEffects(camera: Camera): void;
  58332. /**
  58333. * @hidden Internal
  58334. */
  58335. _updateEffects(): void;
  58336. /**
  58337. * Internal
  58338. * @returns if all the contained post processes are ready.
  58339. * @hidden
  58340. */
  58341. _isReady(): boolean;
  58342. }
  58343. }
  58344. declare module "babylonjs/Shaders/displayPass.fragment" {
  58345. /** @hidden */
  58346. export var displayPassPixelShader: {
  58347. name: string;
  58348. shader: string;
  58349. };
  58350. }
  58351. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  58352. import { Nullable } from "babylonjs/types";
  58353. import { Camera } from "babylonjs/Cameras/camera";
  58354. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58355. import { Engine } from "babylonjs/Engines/engine";
  58356. import "babylonjs/Shaders/displayPass.fragment";
  58357. /**
  58358. * DisplayPassPostProcess which produces an output the same as it's input
  58359. */
  58360. export class DisplayPassPostProcess extends PostProcess {
  58361. /**
  58362. * Creates the DisplayPassPostProcess
  58363. * @param name The name of the effect.
  58364. * @param options The required width/height ratio to downsize to before computing the render pass.
  58365. * @param camera The camera to apply the render pass to.
  58366. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58367. * @param engine The engine which the post process will be applied. (default: current engine)
  58368. * @param reusable If the post process can be reused on the same frame. (default: false)
  58369. */
  58370. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58371. }
  58372. }
  58373. declare module "babylonjs/Shaders/filter.fragment" {
  58374. /** @hidden */
  58375. export var filterPixelShader: {
  58376. name: string;
  58377. shader: string;
  58378. };
  58379. }
  58380. declare module "babylonjs/PostProcesses/filterPostProcess" {
  58381. import { Nullable } from "babylonjs/types";
  58382. import { Matrix } from "babylonjs/Maths/math";
  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/filter.fragment";
  58387. /**
  58388. * Applies a kernel filter to the image
  58389. */
  58390. export class FilterPostProcess extends PostProcess {
  58391. /** The matrix to be applied to the image */
  58392. kernelMatrix: Matrix;
  58393. /**
  58394. *
  58395. * @param name The name of the effect.
  58396. * @param kernelMatrix The matrix to be applied to the image
  58397. * @param options The required width/height ratio to downsize to before computing the render pass.
  58398. * @param camera The camera to apply the render pass to.
  58399. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58400. * @param engine The engine which the post process will be applied. (default: current engine)
  58401. * @param reusable If the post process can be reused on the same frame. (default: false)
  58402. */
  58403. constructor(name: string,
  58404. /** The matrix to be applied to the image */
  58405. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58406. }
  58407. }
  58408. declare module "babylonjs/Shaders/fxaa.fragment" {
  58409. /** @hidden */
  58410. export var fxaaPixelShader: {
  58411. name: string;
  58412. shader: string;
  58413. };
  58414. }
  58415. declare module "babylonjs/Shaders/fxaa.vertex" {
  58416. /** @hidden */
  58417. export var fxaaVertexShader: {
  58418. name: string;
  58419. shader: string;
  58420. };
  58421. }
  58422. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  58423. import { Nullable } from "babylonjs/types";
  58424. import { Camera } from "babylonjs/Cameras/camera";
  58425. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58426. import { Engine } from "babylonjs/Engines/engine";
  58427. import "babylonjs/Shaders/fxaa.fragment";
  58428. import "babylonjs/Shaders/fxaa.vertex";
  58429. /**
  58430. * Fxaa post process
  58431. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  58432. */
  58433. export class FxaaPostProcess extends PostProcess {
  58434. /** @hidden */
  58435. texelWidth: number;
  58436. /** @hidden */
  58437. texelHeight: number;
  58438. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58439. private _getDefines;
  58440. }
  58441. }
  58442. declare module "babylonjs/Shaders/grain.fragment" {
  58443. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58444. /** @hidden */
  58445. export var grainPixelShader: {
  58446. name: string;
  58447. shader: string;
  58448. };
  58449. }
  58450. declare module "babylonjs/PostProcesses/grainPostProcess" {
  58451. import { Nullable } from "babylonjs/types";
  58452. import { Camera } from "babylonjs/Cameras/camera";
  58453. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58454. import { Engine } from "babylonjs/Engines/engine";
  58455. import "babylonjs/Shaders/grain.fragment";
  58456. /**
  58457. * The GrainPostProcess adds noise to the image at mid luminance levels
  58458. */
  58459. export class GrainPostProcess extends PostProcess {
  58460. /**
  58461. * The intensity of the grain added (default: 30)
  58462. */
  58463. intensity: number;
  58464. /**
  58465. * If the grain should be randomized on every frame
  58466. */
  58467. animated: boolean;
  58468. /**
  58469. * Creates a new instance of @see GrainPostProcess
  58470. * @param name The name of the effect.
  58471. * @param options The required width/height ratio to downsize to before computing the render pass.
  58472. * @param camera The camera to apply the render pass to.
  58473. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58474. * @param engine The engine which the post process will be applied. (default: current engine)
  58475. * @param reusable If the post process can be reused on the same frame. (default: false)
  58476. * @param textureType Type of textures used when performing the post process. (default: 0)
  58477. * @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)
  58478. */
  58479. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58480. }
  58481. }
  58482. declare module "babylonjs/Shaders/highlights.fragment" {
  58483. /** @hidden */
  58484. export var highlightsPixelShader: {
  58485. name: string;
  58486. shader: string;
  58487. };
  58488. }
  58489. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  58490. import { Nullable } from "babylonjs/types";
  58491. import { Camera } from "babylonjs/Cameras/camera";
  58492. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58493. import { Engine } from "babylonjs/Engines/engine";
  58494. import "babylonjs/Shaders/highlights.fragment";
  58495. /**
  58496. * Extracts highlights from the image
  58497. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58498. */
  58499. export class HighlightsPostProcess extends PostProcess {
  58500. /**
  58501. * Extracts highlights from the image
  58502. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  58503. * @param name The name of the effect.
  58504. * @param options The required width/height ratio to downsize to before computing the render pass.
  58505. * @param camera The camera to apply the render pass to.
  58506. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58507. * @param engine The engine which the post process will be applied. (default: current engine)
  58508. * @param reusable If the post process can be reused on the same frame. (default: false)
  58509. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  58510. */
  58511. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  58512. }
  58513. }
  58514. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  58515. /** @hidden */
  58516. export var mrtFragmentDeclaration: {
  58517. name: string;
  58518. shader: string;
  58519. };
  58520. }
  58521. declare module "babylonjs/Shaders/geometry.fragment" {
  58522. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  58523. /** @hidden */
  58524. export var geometryPixelShader: {
  58525. name: string;
  58526. shader: string;
  58527. };
  58528. }
  58529. declare module "babylonjs/Shaders/geometry.vertex" {
  58530. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58531. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  58532. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  58533. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  58534. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  58535. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  58536. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  58537. /** @hidden */
  58538. export var geometryVertexShader: {
  58539. name: string;
  58540. shader: string;
  58541. };
  58542. }
  58543. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  58544. import { Matrix } from "babylonjs/Maths/math";
  58545. import { SubMesh } from "babylonjs/Meshes/subMesh";
  58546. import { Mesh } from "babylonjs/Meshes/mesh";
  58547. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  58548. import { Effect } from "babylonjs/Materials/effect";
  58549. import { Scene } from "babylonjs/scene";
  58550. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58551. import "babylonjs/Shaders/geometry.fragment";
  58552. import "babylonjs/Shaders/geometry.vertex";
  58553. /** @hidden */
  58554. interface ISavedTransformationMatrix {
  58555. world: Matrix;
  58556. viewProjection: Matrix;
  58557. }
  58558. /**
  58559. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  58560. */
  58561. export class GeometryBufferRenderer {
  58562. /**
  58563. * Constant used to retrieve the position texture index in the G-Buffer textures array
  58564. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  58565. */
  58566. static readonly POSITION_TEXTURE_TYPE: number;
  58567. /**
  58568. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  58569. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  58570. */
  58571. static readonly VELOCITY_TEXTURE_TYPE: number;
  58572. /**
  58573. * Dictionary used to store the previous transformation matrices of each rendered mesh
  58574. * in order to compute objects velocities when enableVelocity is set to "true"
  58575. * @hidden
  58576. */
  58577. _previousTransformationMatrices: {
  58578. [index: number]: ISavedTransformationMatrix;
  58579. };
  58580. /**
  58581. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  58582. * in order to compute objects velocities when enableVelocity is set to "true"
  58583. * @hidden
  58584. */
  58585. _previousBonesTransformationMatrices: {
  58586. [index: number]: Float32Array;
  58587. };
  58588. /**
  58589. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  58590. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  58591. */
  58592. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  58593. private _scene;
  58594. private _multiRenderTarget;
  58595. private _ratio;
  58596. private _enablePosition;
  58597. private _enableVelocity;
  58598. private _positionIndex;
  58599. private _velocityIndex;
  58600. protected _effect: Effect;
  58601. protected _cachedDefines: string;
  58602. /**
  58603. * Set the render list (meshes to be rendered) used in the G buffer.
  58604. */
  58605. renderList: Mesh[];
  58606. /**
  58607. * Gets wether or not G buffer are supported by the running hardware.
  58608. * This requires draw buffer supports
  58609. */
  58610. readonly isSupported: boolean;
  58611. /**
  58612. * Returns the index of the given texture type in the G-Buffer textures array
  58613. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  58614. * @returns the index of the given texture type in the G-Buffer textures array
  58615. */
  58616. getTextureIndex(textureType: number): number;
  58617. /**
  58618. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  58619. */
  58620. /**
  58621. * Sets whether or not objects positions are enabled for the G buffer.
  58622. */
  58623. enablePosition: boolean;
  58624. /**
  58625. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  58626. */
  58627. /**
  58628. * Sets wether or not objects velocities are enabled for the G buffer.
  58629. */
  58630. enableVelocity: boolean;
  58631. /**
  58632. * Gets the scene associated with the buffer.
  58633. */
  58634. readonly scene: Scene;
  58635. /**
  58636. * Gets the ratio used by the buffer during its creation.
  58637. * How big is the buffer related to the main canvas.
  58638. */
  58639. readonly ratio: number;
  58640. /** @hidden */
  58641. static _SceneComponentInitialization: (scene: Scene) => void;
  58642. /**
  58643. * Creates a new G Buffer for the scene
  58644. * @param scene The scene the buffer belongs to
  58645. * @param ratio How big is the buffer related to the main canvas.
  58646. */
  58647. constructor(scene: Scene, ratio?: number);
  58648. /**
  58649. * Checks wether everything is ready to render a submesh to the G buffer.
  58650. * @param subMesh the submesh to check readiness for
  58651. * @param useInstances is the mesh drawn using instance or not
  58652. * @returns true if ready otherwise false
  58653. */
  58654. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58655. /**
  58656. * Gets the current underlying G Buffer.
  58657. * @returns the buffer
  58658. */
  58659. getGBuffer(): MultiRenderTarget;
  58660. /**
  58661. * Gets the number of samples used to render the buffer (anti aliasing).
  58662. */
  58663. /**
  58664. * Sets the number of samples used to render the buffer (anti aliasing).
  58665. */
  58666. samples: number;
  58667. /**
  58668. * Disposes the renderer and frees up associated resources.
  58669. */
  58670. dispose(): void;
  58671. protected _createRenderTargets(): void;
  58672. private _copyBonesTransformationMatrices;
  58673. }
  58674. }
  58675. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  58676. import { Nullable } from "babylonjs/types";
  58677. import { Scene } from "babylonjs/scene";
  58678. import { ISceneComponent } from "babylonjs/sceneComponent";
  58679. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  58680. module "babylonjs/scene" {
  58681. interface Scene {
  58682. /** @hidden (Backing field) */
  58683. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58684. /**
  58685. * Gets or Sets the current geometry buffer associated to the scene.
  58686. */
  58687. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  58688. /**
  58689. * Enables a GeometryBufferRender and associates it with the scene
  58690. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  58691. * @returns the GeometryBufferRenderer
  58692. */
  58693. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  58694. /**
  58695. * Disables the GeometryBufferRender associated with the scene
  58696. */
  58697. disableGeometryBufferRenderer(): void;
  58698. }
  58699. }
  58700. /**
  58701. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  58702. * in several rendering techniques.
  58703. */
  58704. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  58705. /**
  58706. * The component name helpful to identify the component in the list of scene components.
  58707. */
  58708. readonly name: string;
  58709. /**
  58710. * The scene the component belongs to.
  58711. */
  58712. scene: Scene;
  58713. /**
  58714. * Creates a new instance of the component for the given scene
  58715. * @param scene Defines the scene to register the component in
  58716. */
  58717. constructor(scene: Scene);
  58718. /**
  58719. * Registers the component in a given scene
  58720. */
  58721. register(): void;
  58722. /**
  58723. * Rebuilds the elements related to this component in case of
  58724. * context lost for instance.
  58725. */
  58726. rebuild(): void;
  58727. /**
  58728. * Disposes the component and the associated ressources
  58729. */
  58730. dispose(): void;
  58731. private _gatherRenderTargets;
  58732. }
  58733. }
  58734. declare module "babylonjs/Shaders/motionBlur.fragment" {
  58735. /** @hidden */
  58736. export var motionBlurPixelShader: {
  58737. name: string;
  58738. shader: string;
  58739. };
  58740. }
  58741. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  58742. import { Nullable } from "babylonjs/types";
  58743. import { Camera } from "babylonjs/Cameras/camera";
  58744. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58745. import { Scene } from "babylonjs/scene";
  58746. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58747. import "babylonjs/Animations/animatable";
  58748. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  58749. import "babylonjs/Shaders/motionBlur.fragment";
  58750. import { Engine } from "babylonjs/Engines/engine";
  58751. /**
  58752. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  58753. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  58754. * As an example, all you have to do is to create the post-process:
  58755. * var mb = new BABYLON.MotionBlurPostProcess(
  58756. * 'mb', // The name of the effect.
  58757. * scene, // The scene containing the objects to blur according to their velocity.
  58758. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  58759. * camera // The camera to apply the render pass to.
  58760. * );
  58761. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  58762. */
  58763. export class MotionBlurPostProcess extends PostProcess {
  58764. /**
  58765. * Defines how much the image is blurred by the movement. Default value is equal to 1
  58766. */
  58767. motionStrength: number;
  58768. /**
  58769. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  58770. */
  58771. /**
  58772. * Sets the number of iterations to be used for motion blur quality
  58773. */
  58774. motionBlurSamples: number;
  58775. private _motionBlurSamples;
  58776. private _geometryBufferRenderer;
  58777. /**
  58778. * Creates a new instance MotionBlurPostProcess
  58779. * @param name The name of the effect.
  58780. * @param scene The scene containing the objects to blur according to their velocity.
  58781. * @param options The required width/height ratio to downsize to before computing the render pass.
  58782. * @param camera The camera to apply the render pass to.
  58783. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58784. * @param engine The engine which the post process will be applied. (default: current engine)
  58785. * @param reusable If the post process can be reused on the same frame. (default: false)
  58786. * @param textureType Type of textures used when performing the post process. (default: 0)
  58787. * @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)
  58788. */
  58789. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58790. /**
  58791. * Excludes the given skinned mesh from computing bones velocities.
  58792. * 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.
  58793. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  58794. */
  58795. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58796. /**
  58797. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  58798. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  58799. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  58800. */
  58801. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  58802. /**
  58803. * Disposes the post process.
  58804. * @param camera The camera to dispose the post process on.
  58805. */
  58806. dispose(camera?: Camera): void;
  58807. }
  58808. }
  58809. declare module "babylonjs/Shaders/refraction.fragment" {
  58810. /** @hidden */
  58811. export var refractionPixelShader: {
  58812. name: string;
  58813. shader: string;
  58814. };
  58815. }
  58816. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  58817. import { Color3 } from "babylonjs/Maths/math";
  58818. import { Camera } from "babylonjs/Cameras/camera";
  58819. import { Texture } from "babylonjs/Materials/Textures/texture";
  58820. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58821. import { Engine } from "babylonjs/Engines/engine";
  58822. import "babylonjs/Shaders/refraction.fragment";
  58823. /**
  58824. * Post process which applies a refractin texture
  58825. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58826. */
  58827. export class RefractionPostProcess extends PostProcess {
  58828. /** the base color of the refraction (used to taint the rendering) */
  58829. color: Color3;
  58830. /** simulated refraction depth */
  58831. depth: number;
  58832. /** the coefficient of the base color (0 to remove base color tainting) */
  58833. colorLevel: number;
  58834. private _refTexture;
  58835. private _ownRefractionTexture;
  58836. /**
  58837. * Gets or sets the refraction texture
  58838. * Please note that you are responsible for disposing the texture if you set it manually
  58839. */
  58840. refractionTexture: Texture;
  58841. /**
  58842. * Initializes the RefractionPostProcess
  58843. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  58844. * @param name The name of the effect.
  58845. * @param refractionTextureUrl Url of the refraction texture to use
  58846. * @param color the base color of the refraction (used to taint the rendering)
  58847. * @param depth simulated refraction depth
  58848. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  58849. * @param camera The camera to apply the render pass to.
  58850. * @param options The required width/height ratio to downsize to before computing the render pass.
  58851. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58852. * @param engine The engine which the post process will be applied. (default: current engine)
  58853. * @param reusable If the post process can be reused on the same frame. (default: false)
  58854. */
  58855. constructor(name: string, refractionTextureUrl: string,
  58856. /** the base color of the refraction (used to taint the rendering) */
  58857. color: Color3,
  58858. /** simulated refraction depth */
  58859. depth: number,
  58860. /** the coefficient of the base color (0 to remove base color tainting) */
  58861. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  58862. /**
  58863. * Disposes of the post process
  58864. * @param camera Camera to dispose post process on
  58865. */
  58866. dispose(camera: Camera): void;
  58867. }
  58868. }
  58869. declare module "babylonjs/Shaders/sharpen.fragment" {
  58870. /** @hidden */
  58871. export var sharpenPixelShader: {
  58872. name: string;
  58873. shader: string;
  58874. };
  58875. }
  58876. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  58877. import { Nullable } from "babylonjs/types";
  58878. import { Camera } from "babylonjs/Cameras/camera";
  58879. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  58880. import "babylonjs/Shaders/sharpen.fragment";
  58881. import { Engine } from "babylonjs/Engines/engine";
  58882. /**
  58883. * The SharpenPostProcess applies a sharpen kernel to every pixel
  58884. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58885. */
  58886. export class SharpenPostProcess extends PostProcess {
  58887. /**
  58888. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  58889. */
  58890. colorAmount: number;
  58891. /**
  58892. * How much sharpness should be applied (default: 0.3)
  58893. */
  58894. edgeAmount: number;
  58895. /**
  58896. * Creates a new instance ConvolutionPostProcess
  58897. * @param name The name of the effect.
  58898. * @param options The required width/height ratio to downsize to before computing the render pass.
  58899. * @param camera The camera to apply the render pass to.
  58900. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58901. * @param engine The engine which the post process will be applied. (default: current engine)
  58902. * @param reusable If the post process can be reused on the same frame. (default: false)
  58903. * @param textureType Type of textures used when performing the post process. (default: 0)
  58904. * @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)
  58905. */
  58906. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58907. }
  58908. }
  58909. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  58910. import { Nullable } from "babylonjs/types";
  58911. import { Camera } from "babylonjs/Cameras/camera";
  58912. import { Engine } from "babylonjs/Engines/engine";
  58913. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  58914. import { IInspectable } from "babylonjs/Misc/iInspectable";
  58915. /**
  58916. * PostProcessRenderPipeline
  58917. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58918. */
  58919. export class PostProcessRenderPipeline {
  58920. private engine;
  58921. private _renderEffects;
  58922. private _renderEffectsForIsolatedPass;
  58923. /**
  58924. * List of inspectable custom properties (used by the Inspector)
  58925. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  58926. */
  58927. inspectableCustomProperties: IInspectable[];
  58928. /**
  58929. * @hidden
  58930. */
  58931. protected _cameras: Camera[];
  58932. /** @hidden */
  58933. _name: string;
  58934. /**
  58935. * Gets pipeline name
  58936. */
  58937. readonly name: string;
  58938. /**
  58939. * Initializes a PostProcessRenderPipeline
  58940. * @param engine engine to add the pipeline to
  58941. * @param name name of the pipeline
  58942. */
  58943. constructor(engine: Engine, name: string);
  58944. /**
  58945. * Gets the class name
  58946. * @returns "PostProcessRenderPipeline"
  58947. */
  58948. getClassName(): string;
  58949. /**
  58950. * If all the render effects in the pipeline are supported
  58951. */
  58952. readonly isSupported: boolean;
  58953. /**
  58954. * Adds an effect to the pipeline
  58955. * @param renderEffect the effect to add
  58956. */
  58957. addEffect(renderEffect: PostProcessRenderEffect): void;
  58958. /** @hidden */
  58959. _rebuild(): void;
  58960. /** @hidden */
  58961. _enableEffect(renderEffectName: string, cameras: Camera): void;
  58962. /** @hidden */
  58963. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  58964. /** @hidden */
  58965. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58966. /** @hidden */
  58967. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58968. /** @hidden */
  58969. _attachCameras(cameras: Camera, unique: boolean): void;
  58970. /** @hidden */
  58971. _attachCameras(cameras: Camera[], unique: boolean): void;
  58972. /** @hidden */
  58973. _detachCameras(cameras: Camera): void;
  58974. /** @hidden */
  58975. _detachCameras(cameras: Nullable<Camera[]>): void;
  58976. /** @hidden */
  58977. _update(): void;
  58978. /** @hidden */
  58979. _reset(): void;
  58980. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  58981. /**
  58982. * Disposes of the pipeline
  58983. */
  58984. dispose(): void;
  58985. }
  58986. }
  58987. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  58988. import { Camera } from "babylonjs/Cameras/camera";
  58989. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  58990. /**
  58991. * PostProcessRenderPipelineManager class
  58992. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58993. */
  58994. export class PostProcessRenderPipelineManager {
  58995. private _renderPipelines;
  58996. /**
  58997. * Initializes a PostProcessRenderPipelineManager
  58998. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58999. */
  59000. constructor();
  59001. /**
  59002. * Gets the list of supported render pipelines
  59003. */
  59004. readonly supportedPipelines: PostProcessRenderPipeline[];
  59005. /**
  59006. * Adds a pipeline to the manager
  59007. * @param renderPipeline The pipeline to add
  59008. */
  59009. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  59010. /**
  59011. * Attaches a camera to the pipeline
  59012. * @param renderPipelineName The name of the pipeline to attach to
  59013. * @param cameras the camera to attach
  59014. * @param unique if the camera can be attached multiple times to the pipeline
  59015. */
  59016. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  59017. /**
  59018. * Detaches a camera from the pipeline
  59019. * @param renderPipelineName The name of the pipeline to detach from
  59020. * @param cameras the camera to detach
  59021. */
  59022. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  59023. /**
  59024. * Enables an effect by name on a pipeline
  59025. * @param renderPipelineName the name of the pipeline to enable the effect in
  59026. * @param renderEffectName the name of the effect to enable
  59027. * @param cameras the cameras that the effect should be enabled on
  59028. */
  59029. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59030. /**
  59031. * Disables an effect by name on a pipeline
  59032. * @param renderPipelineName the name of the pipeline to disable the effect in
  59033. * @param renderEffectName the name of the effect to disable
  59034. * @param cameras the cameras that the effect should be disabled on
  59035. */
  59036. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  59037. /**
  59038. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  59039. */
  59040. update(): void;
  59041. /** @hidden */
  59042. _rebuild(): void;
  59043. /**
  59044. * Disposes of the manager and pipelines
  59045. */
  59046. dispose(): void;
  59047. }
  59048. }
  59049. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  59050. import { ISceneComponent } from "babylonjs/sceneComponent";
  59051. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  59052. import { Scene } from "babylonjs/scene";
  59053. module "babylonjs/scene" {
  59054. interface Scene {
  59055. /** @hidden (Backing field) */
  59056. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59057. /**
  59058. * Gets the postprocess render pipeline manager
  59059. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  59060. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59061. */
  59062. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  59063. }
  59064. }
  59065. /**
  59066. * Defines the Render Pipeline scene component responsible to rendering pipelines
  59067. */
  59068. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  59069. /**
  59070. * The component name helpfull to identify the component in the list of scene components.
  59071. */
  59072. readonly name: string;
  59073. /**
  59074. * The scene the component belongs to.
  59075. */
  59076. scene: Scene;
  59077. /**
  59078. * Creates a new instance of the component for the given scene
  59079. * @param scene Defines the scene to register the component in
  59080. */
  59081. constructor(scene: Scene);
  59082. /**
  59083. * Registers the component in a given scene
  59084. */
  59085. register(): void;
  59086. /**
  59087. * Rebuilds the elements related to this component in case of
  59088. * context lost for instance.
  59089. */
  59090. rebuild(): void;
  59091. /**
  59092. * Disposes the component and the associated ressources
  59093. */
  59094. dispose(): void;
  59095. private _gatherRenderTargets;
  59096. }
  59097. }
  59098. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  59099. import { Nullable } from "babylonjs/types";
  59100. import { IAnimatable } from "babylonjs/Misc/tools";
  59101. import { Camera } from "babylonjs/Cameras/camera";
  59102. import { IDisposable } from "babylonjs/scene";
  59103. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  59104. import { Scene } from "babylonjs/scene";
  59105. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  59106. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  59107. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  59108. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  59109. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  59110. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59111. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  59112. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  59113. import { Animation } from "babylonjs/Animations/animation";
  59114. /**
  59115. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  59116. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  59117. */
  59118. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59119. private _scene;
  59120. private _camerasToBeAttached;
  59121. /**
  59122. * ID of the sharpen post process,
  59123. */
  59124. private readonly SharpenPostProcessId;
  59125. /**
  59126. * @ignore
  59127. * ID of the image processing post process;
  59128. */
  59129. readonly ImageProcessingPostProcessId: string;
  59130. /**
  59131. * @ignore
  59132. * ID of the Fast Approximate Anti-Aliasing post process;
  59133. */
  59134. readonly FxaaPostProcessId: string;
  59135. /**
  59136. * ID of the chromatic aberration post process,
  59137. */
  59138. private readonly ChromaticAberrationPostProcessId;
  59139. /**
  59140. * ID of the grain post process
  59141. */
  59142. private readonly GrainPostProcessId;
  59143. /**
  59144. * Sharpen post process which will apply a sharpen convolution to enhance edges
  59145. */
  59146. sharpen: SharpenPostProcess;
  59147. private _sharpenEffect;
  59148. private bloom;
  59149. /**
  59150. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  59151. */
  59152. depthOfField: DepthOfFieldEffect;
  59153. /**
  59154. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59155. */
  59156. fxaa: FxaaPostProcess;
  59157. /**
  59158. * Image post processing pass used to perform operations such as tone mapping or color grading.
  59159. */
  59160. imageProcessing: ImageProcessingPostProcess;
  59161. /**
  59162. * Chromatic aberration post process which will shift rgb colors in the image
  59163. */
  59164. chromaticAberration: ChromaticAberrationPostProcess;
  59165. private _chromaticAberrationEffect;
  59166. /**
  59167. * Grain post process which add noise to the image
  59168. */
  59169. grain: GrainPostProcess;
  59170. private _grainEffect;
  59171. /**
  59172. * Glow post process which adds a glow to emissive areas of the image
  59173. */
  59174. private _glowLayer;
  59175. /**
  59176. * Animations which can be used to tweak settings over a period of time
  59177. */
  59178. animations: Animation[];
  59179. private _imageProcessingConfigurationObserver;
  59180. private _sharpenEnabled;
  59181. private _bloomEnabled;
  59182. private _depthOfFieldEnabled;
  59183. private _depthOfFieldBlurLevel;
  59184. private _fxaaEnabled;
  59185. private _imageProcessingEnabled;
  59186. private _defaultPipelineTextureType;
  59187. private _bloomScale;
  59188. private _chromaticAberrationEnabled;
  59189. private _grainEnabled;
  59190. private _buildAllowed;
  59191. /**
  59192. * Gets active scene
  59193. */
  59194. readonly scene: Scene;
  59195. /**
  59196. * Enable or disable the sharpen process from the pipeline
  59197. */
  59198. sharpenEnabled: boolean;
  59199. private _resizeObserver;
  59200. private _hardwareScaleLevel;
  59201. private _bloomKernel;
  59202. /**
  59203. * Specifies the size of the bloom blur kernel, relative to the final output size
  59204. */
  59205. bloomKernel: number;
  59206. /**
  59207. * Specifies the weight of the bloom in the final rendering
  59208. */
  59209. private _bloomWeight;
  59210. /**
  59211. * Specifies the luma threshold for the area that will be blurred by the bloom
  59212. */
  59213. private _bloomThreshold;
  59214. private _hdr;
  59215. /**
  59216. * The strength of the bloom.
  59217. */
  59218. bloomWeight: number;
  59219. /**
  59220. * The strength of the bloom.
  59221. */
  59222. bloomThreshold: number;
  59223. /**
  59224. * The scale of the bloom, lower value will provide better performance.
  59225. */
  59226. bloomScale: number;
  59227. /**
  59228. * Enable or disable the bloom from the pipeline
  59229. */
  59230. bloomEnabled: boolean;
  59231. private _rebuildBloom;
  59232. /**
  59233. * If the depth of field is enabled.
  59234. */
  59235. depthOfFieldEnabled: boolean;
  59236. /**
  59237. * Blur level of the depth of field effect. (Higher blur will effect performance)
  59238. */
  59239. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  59240. /**
  59241. * If the anti aliasing is enabled.
  59242. */
  59243. fxaaEnabled: boolean;
  59244. private _samples;
  59245. /**
  59246. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59247. */
  59248. samples: number;
  59249. /**
  59250. * If image processing is enabled.
  59251. */
  59252. imageProcessingEnabled: boolean;
  59253. /**
  59254. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  59255. */
  59256. glowLayerEnabled: boolean;
  59257. /**
  59258. * Gets the glow layer (or null if not defined)
  59259. */
  59260. readonly glowLayer: Nullable<GlowLayer>;
  59261. /**
  59262. * Enable or disable the chromaticAberration process from the pipeline
  59263. */
  59264. chromaticAberrationEnabled: boolean;
  59265. /**
  59266. * Enable or disable the grain process from the pipeline
  59267. */
  59268. grainEnabled: boolean;
  59269. /**
  59270. * @constructor
  59271. * @param name - The rendering pipeline name (default: "")
  59272. * @param hdr - If high dynamic range textures should be used (default: true)
  59273. * @param scene - The scene linked to this pipeline (default: the last created scene)
  59274. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  59275. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  59276. */
  59277. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  59278. /**
  59279. * Get the class name
  59280. * @returns "DefaultRenderingPipeline"
  59281. */
  59282. getClassName(): string;
  59283. /**
  59284. * Force the compilation of the entire pipeline.
  59285. */
  59286. prepare(): void;
  59287. private _hasCleared;
  59288. private _prevPostProcess;
  59289. private _prevPrevPostProcess;
  59290. private _setAutoClearAndTextureSharing;
  59291. private _depthOfFieldSceneObserver;
  59292. private _buildPipeline;
  59293. private _disposePostProcesses;
  59294. /**
  59295. * Adds a camera to the pipeline
  59296. * @param camera the camera to be added
  59297. */
  59298. addCamera(camera: Camera): void;
  59299. /**
  59300. * Removes a camera from the pipeline
  59301. * @param camera the camera to remove
  59302. */
  59303. removeCamera(camera: Camera): void;
  59304. /**
  59305. * Dispose of the pipeline and stop all post processes
  59306. */
  59307. dispose(): void;
  59308. /**
  59309. * Serialize the rendering pipeline (Used when exporting)
  59310. * @returns the serialized object
  59311. */
  59312. serialize(): any;
  59313. /**
  59314. * Parse the serialized pipeline
  59315. * @param source Source pipeline.
  59316. * @param scene The scene to load the pipeline to.
  59317. * @param rootUrl The URL of the serialized pipeline.
  59318. * @returns An instantiated pipeline from the serialized object.
  59319. */
  59320. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  59321. }
  59322. }
  59323. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  59324. /** @hidden */
  59325. export var lensHighlightsPixelShader: {
  59326. name: string;
  59327. shader: string;
  59328. };
  59329. }
  59330. declare module "babylonjs/Shaders/depthOfField.fragment" {
  59331. /** @hidden */
  59332. export var depthOfFieldPixelShader: {
  59333. name: string;
  59334. shader: string;
  59335. };
  59336. }
  59337. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  59338. import { Camera } from "babylonjs/Cameras/camera";
  59339. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59340. import { Scene } from "babylonjs/scene";
  59341. import "babylonjs/Shaders/chromaticAberration.fragment";
  59342. import "babylonjs/Shaders/lensHighlights.fragment";
  59343. import "babylonjs/Shaders/depthOfField.fragment";
  59344. /**
  59345. * BABYLON.JS Chromatic Aberration GLSL Shader
  59346. * Author: Olivier Guyot
  59347. * Separates very slightly R, G and B colors on the edges of the screen
  59348. * Inspired by Francois Tarlier & Martins Upitis
  59349. */
  59350. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  59351. /**
  59352. * @ignore
  59353. * The chromatic aberration PostProcess id in the pipeline
  59354. */
  59355. LensChromaticAberrationEffect: string;
  59356. /**
  59357. * @ignore
  59358. * The highlights enhancing PostProcess id in the pipeline
  59359. */
  59360. HighlightsEnhancingEffect: string;
  59361. /**
  59362. * @ignore
  59363. * The depth-of-field PostProcess id in the pipeline
  59364. */
  59365. LensDepthOfFieldEffect: string;
  59366. private _scene;
  59367. private _depthTexture;
  59368. private _grainTexture;
  59369. private _chromaticAberrationPostProcess;
  59370. private _highlightsPostProcess;
  59371. private _depthOfFieldPostProcess;
  59372. private _edgeBlur;
  59373. private _grainAmount;
  59374. private _chromaticAberration;
  59375. private _distortion;
  59376. private _highlightsGain;
  59377. private _highlightsThreshold;
  59378. private _dofDistance;
  59379. private _dofAperture;
  59380. private _dofDarken;
  59381. private _dofPentagon;
  59382. private _blurNoise;
  59383. /**
  59384. * @constructor
  59385. *
  59386. * Effect parameters are as follow:
  59387. * {
  59388. * chromatic_aberration: number; // from 0 to x (1 for realism)
  59389. * edge_blur: number; // from 0 to x (1 for realism)
  59390. * distortion: number; // from 0 to x (1 for realism)
  59391. * grain_amount: number; // from 0 to 1
  59392. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  59393. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  59394. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  59395. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  59396. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  59397. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  59398. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  59399. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  59400. * }
  59401. * Note: if an effect parameter is unset, effect is disabled
  59402. *
  59403. * @param name The rendering pipeline name
  59404. * @param parameters - An object containing all parameters (see above)
  59405. * @param scene The scene linked to this pipeline
  59406. * @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)
  59407. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59408. */
  59409. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  59410. /**
  59411. * Get the class name
  59412. * @returns "LensRenderingPipeline"
  59413. */
  59414. getClassName(): string;
  59415. /**
  59416. * Gets associated scene
  59417. */
  59418. readonly scene: Scene;
  59419. /**
  59420. * Gets or sets the edge blur
  59421. */
  59422. edgeBlur: number;
  59423. /**
  59424. * Gets or sets the grain amount
  59425. */
  59426. grainAmount: number;
  59427. /**
  59428. * Gets or sets the chromatic aberration amount
  59429. */
  59430. chromaticAberration: number;
  59431. /**
  59432. * Gets or sets the depth of field aperture
  59433. */
  59434. dofAperture: number;
  59435. /**
  59436. * Gets or sets the edge distortion
  59437. */
  59438. edgeDistortion: number;
  59439. /**
  59440. * Gets or sets the depth of field distortion
  59441. */
  59442. dofDistortion: number;
  59443. /**
  59444. * Gets or sets the darken out of focus amount
  59445. */
  59446. darkenOutOfFocus: number;
  59447. /**
  59448. * Gets or sets a boolean indicating if blur noise is enabled
  59449. */
  59450. blurNoise: boolean;
  59451. /**
  59452. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  59453. */
  59454. pentagonBokeh: boolean;
  59455. /**
  59456. * Gets or sets the highlight grain amount
  59457. */
  59458. highlightsGain: number;
  59459. /**
  59460. * Gets or sets the highlight threshold
  59461. */
  59462. highlightsThreshold: number;
  59463. /**
  59464. * Sets the amount of blur at the edges
  59465. * @param amount blur amount
  59466. */
  59467. setEdgeBlur(amount: number): void;
  59468. /**
  59469. * Sets edge blur to 0
  59470. */
  59471. disableEdgeBlur(): void;
  59472. /**
  59473. * Sets the amout of grain
  59474. * @param amount Amount of grain
  59475. */
  59476. setGrainAmount(amount: number): void;
  59477. /**
  59478. * Set grain amount to 0
  59479. */
  59480. disableGrain(): void;
  59481. /**
  59482. * Sets the chromatic aberration amount
  59483. * @param amount amount of chromatic aberration
  59484. */
  59485. setChromaticAberration(amount: number): void;
  59486. /**
  59487. * Sets chromatic aberration amount to 0
  59488. */
  59489. disableChromaticAberration(): void;
  59490. /**
  59491. * Sets the EdgeDistortion amount
  59492. * @param amount amount of EdgeDistortion
  59493. */
  59494. setEdgeDistortion(amount: number): void;
  59495. /**
  59496. * Sets edge distortion to 0
  59497. */
  59498. disableEdgeDistortion(): void;
  59499. /**
  59500. * Sets the FocusDistance amount
  59501. * @param amount amount of FocusDistance
  59502. */
  59503. setFocusDistance(amount: number): void;
  59504. /**
  59505. * Disables depth of field
  59506. */
  59507. disableDepthOfField(): void;
  59508. /**
  59509. * Sets the Aperture amount
  59510. * @param amount amount of Aperture
  59511. */
  59512. setAperture(amount: number): void;
  59513. /**
  59514. * Sets the DarkenOutOfFocus amount
  59515. * @param amount amount of DarkenOutOfFocus
  59516. */
  59517. setDarkenOutOfFocus(amount: number): void;
  59518. private _pentagonBokehIsEnabled;
  59519. /**
  59520. * Creates a pentagon bokeh effect
  59521. */
  59522. enablePentagonBokeh(): void;
  59523. /**
  59524. * Disables the pentagon bokeh effect
  59525. */
  59526. disablePentagonBokeh(): void;
  59527. /**
  59528. * Enables noise blur
  59529. */
  59530. enableNoiseBlur(): void;
  59531. /**
  59532. * Disables noise blur
  59533. */
  59534. disableNoiseBlur(): void;
  59535. /**
  59536. * Sets the HighlightsGain amount
  59537. * @param amount amount of HighlightsGain
  59538. */
  59539. setHighlightsGain(amount: number): void;
  59540. /**
  59541. * Sets the HighlightsThreshold amount
  59542. * @param amount amount of HighlightsThreshold
  59543. */
  59544. setHighlightsThreshold(amount: number): void;
  59545. /**
  59546. * Disables highlights
  59547. */
  59548. disableHighlights(): void;
  59549. /**
  59550. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  59551. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  59552. */
  59553. dispose(disableDepthRender?: boolean): void;
  59554. private _createChromaticAberrationPostProcess;
  59555. private _createHighlightsPostProcess;
  59556. private _createDepthOfFieldPostProcess;
  59557. private _createGrainTexture;
  59558. }
  59559. }
  59560. declare module "babylonjs/Shaders/ssao2.fragment" {
  59561. /** @hidden */
  59562. export var ssao2PixelShader: {
  59563. name: string;
  59564. shader: string;
  59565. };
  59566. }
  59567. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  59568. /** @hidden */
  59569. export var ssaoCombinePixelShader: {
  59570. name: string;
  59571. shader: string;
  59572. };
  59573. }
  59574. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  59575. import { Camera } from "babylonjs/Cameras/camera";
  59576. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59577. import { Scene } from "babylonjs/scene";
  59578. import "babylonjs/Shaders/ssao2.fragment";
  59579. import "babylonjs/Shaders/ssaoCombine.fragment";
  59580. /**
  59581. * Render pipeline to produce ssao effect
  59582. */
  59583. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  59584. /**
  59585. * @ignore
  59586. * The PassPostProcess id in the pipeline that contains the original scene color
  59587. */
  59588. SSAOOriginalSceneColorEffect: string;
  59589. /**
  59590. * @ignore
  59591. * The SSAO PostProcess id in the pipeline
  59592. */
  59593. SSAORenderEffect: string;
  59594. /**
  59595. * @ignore
  59596. * The horizontal blur PostProcess id in the pipeline
  59597. */
  59598. SSAOBlurHRenderEffect: string;
  59599. /**
  59600. * @ignore
  59601. * The vertical blur PostProcess id in the pipeline
  59602. */
  59603. SSAOBlurVRenderEffect: string;
  59604. /**
  59605. * @ignore
  59606. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59607. */
  59608. SSAOCombineRenderEffect: string;
  59609. /**
  59610. * The output strength of the SSAO post-process. Default value is 1.0.
  59611. */
  59612. totalStrength: number;
  59613. /**
  59614. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  59615. */
  59616. maxZ: number;
  59617. /**
  59618. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  59619. */
  59620. minZAspect: number;
  59621. private _samples;
  59622. /**
  59623. * Number of samples used for the SSAO calculations. Default value is 8
  59624. */
  59625. samples: number;
  59626. private _textureSamples;
  59627. /**
  59628. * Number of samples to use for antialiasing
  59629. */
  59630. textureSamples: number;
  59631. /**
  59632. * Ratio object used for SSAO ratio and blur ratio
  59633. */
  59634. private _ratio;
  59635. /**
  59636. * Dynamically generated sphere sampler.
  59637. */
  59638. private _sampleSphere;
  59639. /**
  59640. * Blur filter offsets
  59641. */
  59642. private _samplerOffsets;
  59643. private _expensiveBlur;
  59644. /**
  59645. * If bilateral blur should be used
  59646. */
  59647. expensiveBlur: boolean;
  59648. /**
  59649. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  59650. */
  59651. radius: number;
  59652. /**
  59653. * The base color of the SSAO post-process
  59654. * The final result is "base + ssao" between [0, 1]
  59655. */
  59656. base: number;
  59657. /**
  59658. * Support test.
  59659. */
  59660. static readonly IsSupported: boolean;
  59661. private _scene;
  59662. private _depthTexture;
  59663. private _normalTexture;
  59664. private _randomTexture;
  59665. private _originalColorPostProcess;
  59666. private _ssaoPostProcess;
  59667. private _blurHPostProcess;
  59668. private _blurVPostProcess;
  59669. private _ssaoCombinePostProcess;
  59670. private _firstUpdate;
  59671. /**
  59672. * Gets active scene
  59673. */
  59674. readonly scene: Scene;
  59675. /**
  59676. * @constructor
  59677. * @param name The rendering pipeline name
  59678. * @param scene The scene linked to this pipeline
  59679. * @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 }
  59680. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59681. */
  59682. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59683. /**
  59684. * Get the class name
  59685. * @returns "SSAO2RenderingPipeline"
  59686. */
  59687. getClassName(): string;
  59688. /**
  59689. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59690. */
  59691. dispose(disableGeometryBufferRenderer?: boolean): void;
  59692. private _createBlurPostProcess;
  59693. /** @hidden */
  59694. _rebuild(): void;
  59695. private _bits;
  59696. private _radicalInverse_VdC;
  59697. private _hammersley;
  59698. private _hemisphereSample_uniform;
  59699. private _generateHemisphere;
  59700. private _createSSAOPostProcess;
  59701. private _createSSAOCombinePostProcess;
  59702. private _createRandomTexture;
  59703. /**
  59704. * Serialize the rendering pipeline (Used when exporting)
  59705. * @returns the serialized object
  59706. */
  59707. serialize(): any;
  59708. /**
  59709. * Parse the serialized pipeline
  59710. * @param source Source pipeline.
  59711. * @param scene The scene to load the pipeline to.
  59712. * @param rootUrl The URL of the serialized pipeline.
  59713. * @returns An instantiated pipeline from the serialized object.
  59714. */
  59715. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  59716. }
  59717. }
  59718. declare module "babylonjs/Shaders/ssao.fragment" {
  59719. /** @hidden */
  59720. export var ssaoPixelShader: {
  59721. name: string;
  59722. shader: string;
  59723. };
  59724. }
  59725. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  59726. import { Camera } from "babylonjs/Cameras/camera";
  59727. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59728. import { Scene } from "babylonjs/scene";
  59729. import "babylonjs/Shaders/ssao.fragment";
  59730. import "babylonjs/Shaders/ssaoCombine.fragment";
  59731. /**
  59732. * Render pipeline to produce ssao effect
  59733. */
  59734. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  59735. /**
  59736. * @ignore
  59737. * The PassPostProcess id in the pipeline that contains the original scene color
  59738. */
  59739. SSAOOriginalSceneColorEffect: string;
  59740. /**
  59741. * @ignore
  59742. * The SSAO PostProcess id in the pipeline
  59743. */
  59744. SSAORenderEffect: string;
  59745. /**
  59746. * @ignore
  59747. * The horizontal blur PostProcess id in the pipeline
  59748. */
  59749. SSAOBlurHRenderEffect: string;
  59750. /**
  59751. * @ignore
  59752. * The vertical blur PostProcess id in the pipeline
  59753. */
  59754. SSAOBlurVRenderEffect: string;
  59755. /**
  59756. * @ignore
  59757. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  59758. */
  59759. SSAOCombineRenderEffect: string;
  59760. /**
  59761. * The output strength of the SSAO post-process. Default value is 1.0.
  59762. */
  59763. totalStrength: number;
  59764. /**
  59765. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  59766. */
  59767. radius: number;
  59768. /**
  59769. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  59770. * Must not be equal to fallOff and superior to fallOff.
  59771. * Default value is 0.0075
  59772. */
  59773. area: number;
  59774. /**
  59775. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  59776. * Must not be equal to area and inferior to area.
  59777. * Default value is 0.000001
  59778. */
  59779. fallOff: number;
  59780. /**
  59781. * The base color of the SSAO post-process
  59782. * The final result is "base + ssao" between [0, 1]
  59783. */
  59784. base: number;
  59785. private _scene;
  59786. private _depthTexture;
  59787. private _randomTexture;
  59788. private _originalColorPostProcess;
  59789. private _ssaoPostProcess;
  59790. private _blurHPostProcess;
  59791. private _blurVPostProcess;
  59792. private _ssaoCombinePostProcess;
  59793. private _firstUpdate;
  59794. /**
  59795. * Gets active scene
  59796. */
  59797. readonly scene: Scene;
  59798. /**
  59799. * @constructor
  59800. * @param name - The rendering pipeline name
  59801. * @param scene - The scene linked to this pipeline
  59802. * @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 }
  59803. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  59804. */
  59805. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  59806. /**
  59807. * Get the class name
  59808. * @returns "SSAORenderingPipeline"
  59809. */
  59810. getClassName(): string;
  59811. /**
  59812. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  59813. */
  59814. dispose(disableDepthRender?: boolean): void;
  59815. private _createBlurPostProcess;
  59816. /** @hidden */
  59817. _rebuild(): void;
  59818. private _createSSAOPostProcess;
  59819. private _createSSAOCombinePostProcess;
  59820. private _createRandomTexture;
  59821. }
  59822. }
  59823. declare module "babylonjs/Shaders/standard.fragment" {
  59824. /** @hidden */
  59825. export var standardPixelShader: {
  59826. name: string;
  59827. shader: string;
  59828. };
  59829. }
  59830. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  59831. import { Nullable } from "babylonjs/types";
  59832. import { IAnimatable } from "babylonjs/Misc/tools";
  59833. import { Camera } from "babylonjs/Cameras/camera";
  59834. import { Texture } from "babylonjs/Materials/Textures/texture";
  59835. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59836. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59837. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  59838. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  59839. import { IDisposable } from "babylonjs/scene";
  59840. import { SpotLight } from "babylonjs/Lights/spotLight";
  59841. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  59842. import { Scene } from "babylonjs/scene";
  59843. import { Animation } from "babylonjs/Animations/animation";
  59844. import "babylonjs/Shaders/standard.fragment";
  59845. /**
  59846. * Standard rendering pipeline
  59847. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59848. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  59849. */
  59850. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  59851. /**
  59852. * Public members
  59853. */
  59854. /**
  59855. * Post-process which contains the original scene color before the pipeline applies all the effects
  59856. */
  59857. originalPostProcess: Nullable<PostProcess>;
  59858. /**
  59859. * Post-process used to down scale an image x4
  59860. */
  59861. downSampleX4PostProcess: Nullable<PostProcess>;
  59862. /**
  59863. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  59864. */
  59865. brightPassPostProcess: Nullable<PostProcess>;
  59866. /**
  59867. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  59868. */
  59869. blurHPostProcesses: PostProcess[];
  59870. /**
  59871. * Post-process array storing all the vertical blur post-processes used by the pipeline
  59872. */
  59873. blurVPostProcesses: PostProcess[];
  59874. /**
  59875. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  59876. */
  59877. textureAdderPostProcess: Nullable<PostProcess>;
  59878. /**
  59879. * Post-process used to create volumetric lighting effect
  59880. */
  59881. volumetricLightPostProcess: Nullable<PostProcess>;
  59882. /**
  59883. * Post-process used to smooth the previous volumetric light post-process on the X axis
  59884. */
  59885. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  59886. /**
  59887. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  59888. */
  59889. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  59890. /**
  59891. * Post-process used to merge the volumetric light effect and the real scene color
  59892. */
  59893. volumetricLightMergePostProces: Nullable<PostProcess>;
  59894. /**
  59895. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  59896. */
  59897. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  59898. /**
  59899. * Base post-process used to calculate the average luminance of the final image for HDR
  59900. */
  59901. luminancePostProcess: Nullable<PostProcess>;
  59902. /**
  59903. * Post-processes used to create down sample post-processes in order to get
  59904. * the average luminance of the final image for HDR
  59905. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  59906. */
  59907. luminanceDownSamplePostProcesses: PostProcess[];
  59908. /**
  59909. * Post-process used to create a HDR effect (light adaptation)
  59910. */
  59911. hdrPostProcess: Nullable<PostProcess>;
  59912. /**
  59913. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  59914. */
  59915. textureAdderFinalPostProcess: Nullable<PostProcess>;
  59916. /**
  59917. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  59918. */
  59919. lensFlareFinalPostProcess: Nullable<PostProcess>;
  59920. /**
  59921. * Post-process used to merge the final HDR post-process and the real scene color
  59922. */
  59923. hdrFinalPostProcess: Nullable<PostProcess>;
  59924. /**
  59925. * Post-process used to create a lens flare effect
  59926. */
  59927. lensFlarePostProcess: Nullable<PostProcess>;
  59928. /**
  59929. * Post-process that merges the result of the lens flare post-process and the real scene color
  59930. */
  59931. lensFlareComposePostProcess: Nullable<PostProcess>;
  59932. /**
  59933. * Post-process used to create a motion blur effect
  59934. */
  59935. motionBlurPostProcess: Nullable<PostProcess>;
  59936. /**
  59937. * Post-process used to create a depth of field effect
  59938. */
  59939. depthOfFieldPostProcess: Nullable<PostProcess>;
  59940. /**
  59941. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59942. */
  59943. fxaaPostProcess: Nullable<FxaaPostProcess>;
  59944. /**
  59945. * Represents the brightness threshold in order to configure the illuminated surfaces
  59946. */
  59947. brightThreshold: number;
  59948. /**
  59949. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  59950. */
  59951. blurWidth: number;
  59952. /**
  59953. * Sets if the blur for highlighted surfaces must be only horizontal
  59954. */
  59955. horizontalBlur: boolean;
  59956. /**
  59957. * Gets the overall exposure used by the pipeline
  59958. */
  59959. /**
  59960. * Sets the overall exposure used by the pipeline
  59961. */
  59962. exposure: number;
  59963. /**
  59964. * Texture used typically to simulate "dirty" on camera lens
  59965. */
  59966. lensTexture: Nullable<Texture>;
  59967. /**
  59968. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  59969. */
  59970. volumetricLightCoefficient: number;
  59971. /**
  59972. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  59973. */
  59974. volumetricLightPower: number;
  59975. /**
  59976. * Used the set the blur intensity to smooth the volumetric lights
  59977. */
  59978. volumetricLightBlurScale: number;
  59979. /**
  59980. * Light (spot or directional) used to generate the volumetric lights rays
  59981. * The source light must have a shadow generate so the pipeline can get its
  59982. * depth map
  59983. */
  59984. sourceLight: Nullable<SpotLight | DirectionalLight>;
  59985. /**
  59986. * For eye adaptation, represents the minimum luminance the eye can see
  59987. */
  59988. hdrMinimumLuminance: number;
  59989. /**
  59990. * For eye adaptation, represents the decrease luminance speed
  59991. */
  59992. hdrDecreaseRate: number;
  59993. /**
  59994. * For eye adaptation, represents the increase luminance speed
  59995. */
  59996. hdrIncreaseRate: number;
  59997. /**
  59998. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59999. */
  60000. /**
  60001. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  60002. */
  60003. hdrAutoExposure: boolean;
  60004. /**
  60005. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  60006. */
  60007. lensColorTexture: Nullable<Texture>;
  60008. /**
  60009. * The overall strengh for the lens flare effect
  60010. */
  60011. lensFlareStrength: number;
  60012. /**
  60013. * Dispersion coefficient for lens flare ghosts
  60014. */
  60015. lensFlareGhostDispersal: number;
  60016. /**
  60017. * Main lens flare halo width
  60018. */
  60019. lensFlareHaloWidth: number;
  60020. /**
  60021. * Based on the lens distortion effect, defines how much the lens flare result
  60022. * is distorted
  60023. */
  60024. lensFlareDistortionStrength: number;
  60025. /**
  60026. * Lens star texture must be used to simulate rays on the flares and is available
  60027. * in the documentation
  60028. */
  60029. lensStarTexture: Nullable<Texture>;
  60030. /**
  60031. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  60032. * flare effect by taking account of the dirt texture
  60033. */
  60034. lensFlareDirtTexture: Nullable<Texture>;
  60035. /**
  60036. * Represents the focal length for the depth of field effect
  60037. */
  60038. depthOfFieldDistance: number;
  60039. /**
  60040. * Represents the blur intensity for the blurred part of the depth of field effect
  60041. */
  60042. depthOfFieldBlurWidth: number;
  60043. /**
  60044. * Gets how much the image is blurred by the movement while using the motion blur post-process
  60045. */
  60046. /**
  60047. * Sets how much the image is blurred by the movement while using the motion blur post-process
  60048. */
  60049. motionStrength: number;
  60050. /**
  60051. * Gets wether or not the motion blur post-process is object based or screen based.
  60052. */
  60053. /**
  60054. * Sets wether or not the motion blur post-process should be object based or screen based
  60055. */
  60056. objectBasedMotionBlur: boolean;
  60057. /**
  60058. * List of animations for the pipeline (IAnimatable implementation)
  60059. */
  60060. animations: Animation[];
  60061. /**
  60062. * Private members
  60063. */
  60064. private _scene;
  60065. private _currentDepthOfFieldSource;
  60066. private _basePostProcess;
  60067. private _fixedExposure;
  60068. private _currentExposure;
  60069. private _hdrAutoExposure;
  60070. private _hdrCurrentLuminance;
  60071. private _motionStrength;
  60072. private _isObjectBasedMotionBlur;
  60073. private _floatTextureType;
  60074. private _ratio;
  60075. private _bloomEnabled;
  60076. private _depthOfFieldEnabled;
  60077. private _vlsEnabled;
  60078. private _lensFlareEnabled;
  60079. private _hdrEnabled;
  60080. private _motionBlurEnabled;
  60081. private _fxaaEnabled;
  60082. private _motionBlurSamples;
  60083. private _volumetricLightStepsCount;
  60084. private _samples;
  60085. /**
  60086. * @ignore
  60087. * Specifies if the bloom pipeline is enabled
  60088. */
  60089. BloomEnabled: boolean;
  60090. /**
  60091. * @ignore
  60092. * Specifies if the depth of field pipeline is enabed
  60093. */
  60094. DepthOfFieldEnabled: boolean;
  60095. /**
  60096. * @ignore
  60097. * Specifies if the lens flare pipeline is enabed
  60098. */
  60099. LensFlareEnabled: boolean;
  60100. /**
  60101. * @ignore
  60102. * Specifies if the HDR pipeline is enabled
  60103. */
  60104. HDREnabled: boolean;
  60105. /**
  60106. * @ignore
  60107. * Specifies if the volumetric lights scattering effect is enabled
  60108. */
  60109. VLSEnabled: boolean;
  60110. /**
  60111. * @ignore
  60112. * Specifies if the motion blur effect is enabled
  60113. */
  60114. MotionBlurEnabled: boolean;
  60115. /**
  60116. * Specifies if anti-aliasing is enabled
  60117. */
  60118. fxaaEnabled: boolean;
  60119. /**
  60120. * Specifies the number of steps used to calculate the volumetric lights
  60121. * Typically in interval [50, 200]
  60122. */
  60123. volumetricLightStepsCount: number;
  60124. /**
  60125. * Specifies the number of samples used for the motion blur effect
  60126. * Typically in interval [16, 64]
  60127. */
  60128. motionBlurSamples: number;
  60129. /**
  60130. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  60131. */
  60132. samples: number;
  60133. /**
  60134. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  60135. * @constructor
  60136. * @param name The rendering pipeline name
  60137. * @param scene The scene linked to this pipeline
  60138. * @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)
  60139. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  60140. * @param cameras The array of cameras that the rendering pipeline will be attached to
  60141. */
  60142. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  60143. private _buildPipeline;
  60144. private _createDownSampleX4PostProcess;
  60145. private _createBrightPassPostProcess;
  60146. private _createBlurPostProcesses;
  60147. private _createTextureAdderPostProcess;
  60148. private _createVolumetricLightPostProcess;
  60149. private _createLuminancePostProcesses;
  60150. private _createHdrPostProcess;
  60151. private _createLensFlarePostProcess;
  60152. private _createDepthOfFieldPostProcess;
  60153. private _createMotionBlurPostProcess;
  60154. private _getDepthTexture;
  60155. private _disposePostProcesses;
  60156. /**
  60157. * Dispose of the pipeline and stop all post processes
  60158. */
  60159. dispose(): void;
  60160. /**
  60161. * Serialize the rendering pipeline (Used when exporting)
  60162. * @returns the serialized object
  60163. */
  60164. serialize(): any;
  60165. /**
  60166. * Parse the serialized pipeline
  60167. * @param source Source pipeline.
  60168. * @param scene The scene to load the pipeline to.
  60169. * @param rootUrl The URL of the serialized pipeline.
  60170. * @returns An instantiated pipeline from the serialized object.
  60171. */
  60172. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  60173. /**
  60174. * Luminance steps
  60175. */
  60176. static LuminanceSteps: number;
  60177. }
  60178. }
  60179. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  60180. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  60181. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  60182. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  60183. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  60184. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  60185. }
  60186. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  60187. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  60188. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  60189. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  60190. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  60191. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  60192. }
  60193. declare module "babylonjs/Shaders/tonemap.fragment" {
  60194. /** @hidden */
  60195. export var tonemapPixelShader: {
  60196. name: string;
  60197. shader: string;
  60198. };
  60199. }
  60200. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  60201. import { Camera } from "babylonjs/Cameras/camera";
  60202. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60203. import "babylonjs/Shaders/tonemap.fragment";
  60204. import { Engine } from "babylonjs/Engines/engine";
  60205. /** Defines operator used for tonemapping */
  60206. export enum TonemappingOperator {
  60207. /** Hable */
  60208. Hable = 0,
  60209. /** Reinhard */
  60210. Reinhard = 1,
  60211. /** HejiDawson */
  60212. HejiDawson = 2,
  60213. /** Photographic */
  60214. Photographic = 3
  60215. }
  60216. /**
  60217. * Defines a post process to apply tone mapping
  60218. */
  60219. export class TonemapPostProcess extends PostProcess {
  60220. private _operator;
  60221. /** Defines the required exposure adjustement */
  60222. exposureAdjustment: number;
  60223. /**
  60224. * Creates a new TonemapPostProcess
  60225. * @param name defines the name of the postprocess
  60226. * @param _operator defines the operator to use
  60227. * @param exposureAdjustment defines the required exposure adjustement
  60228. * @param camera defines the camera to use (can be null)
  60229. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  60230. * @param engine defines the hosting engine (can be ignore if camera is set)
  60231. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  60232. */
  60233. constructor(name: string, _operator: TonemappingOperator,
  60234. /** Defines the required exposure adjustement */
  60235. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  60236. }
  60237. }
  60238. declare module "babylonjs/Shaders/depth.vertex" {
  60239. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60240. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60241. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60242. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60243. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60244. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60245. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60246. /** @hidden */
  60247. export var depthVertexShader: {
  60248. name: string;
  60249. shader: string;
  60250. };
  60251. }
  60252. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  60253. /** @hidden */
  60254. export var volumetricLightScatteringPixelShader: {
  60255. name: string;
  60256. shader: string;
  60257. };
  60258. }
  60259. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  60260. /** @hidden */
  60261. export var volumetricLightScatteringPassPixelShader: {
  60262. name: string;
  60263. shader: string;
  60264. };
  60265. }
  60266. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  60267. import { Vector3 } from "babylonjs/Maths/math";
  60268. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60269. import { Mesh } from "babylonjs/Meshes/mesh";
  60270. import { Camera } from "babylonjs/Cameras/camera";
  60271. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60272. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60273. import { Scene } from "babylonjs/scene";
  60274. import "babylonjs/Meshes/Builders/planeBuilder";
  60275. import "babylonjs/Shaders/depth.vertex";
  60276. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  60277. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  60278. import { Engine } from "babylonjs/Engines/engine";
  60279. /**
  60280. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  60281. */
  60282. export class VolumetricLightScatteringPostProcess extends PostProcess {
  60283. private _volumetricLightScatteringPass;
  60284. private _volumetricLightScatteringRTT;
  60285. private _viewPort;
  60286. private _screenCoordinates;
  60287. private _cachedDefines;
  60288. /**
  60289. * If not undefined, the mesh position is computed from the attached node position
  60290. */
  60291. attachedNode: {
  60292. position: Vector3;
  60293. };
  60294. /**
  60295. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  60296. */
  60297. customMeshPosition: Vector3;
  60298. /**
  60299. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  60300. */
  60301. useCustomMeshPosition: boolean;
  60302. /**
  60303. * If the post-process should inverse the light scattering direction
  60304. */
  60305. invert: boolean;
  60306. /**
  60307. * The internal mesh used by the post-process
  60308. */
  60309. mesh: Mesh;
  60310. /**
  60311. * @hidden
  60312. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  60313. */
  60314. useDiffuseColor: boolean;
  60315. /**
  60316. * Array containing the excluded meshes not rendered in the internal pass
  60317. */
  60318. excludedMeshes: AbstractMesh[];
  60319. /**
  60320. * Controls the overall intensity of the post-process
  60321. */
  60322. exposure: number;
  60323. /**
  60324. * Dissipates each sample's contribution in range [0, 1]
  60325. */
  60326. decay: number;
  60327. /**
  60328. * Controls the overall intensity of each sample
  60329. */
  60330. weight: number;
  60331. /**
  60332. * Controls the density of each sample
  60333. */
  60334. density: number;
  60335. /**
  60336. * @constructor
  60337. * @param name The post-process name
  60338. * @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)
  60339. * @param camera The camera that the post-process will be attached to
  60340. * @param mesh The mesh used to create the light scattering
  60341. * @param samples The post-process quality, default 100
  60342. * @param samplingModeThe post-process filtering mode
  60343. * @param engine The babylon engine
  60344. * @param reusable If the post-process is reusable
  60345. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  60346. */
  60347. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  60348. /**
  60349. * Returns the string "VolumetricLightScatteringPostProcess"
  60350. * @returns "VolumetricLightScatteringPostProcess"
  60351. */
  60352. getClassName(): string;
  60353. private _isReady;
  60354. /**
  60355. * Sets the new light position for light scattering effect
  60356. * @param position The new custom light position
  60357. */
  60358. setCustomMeshPosition(position: Vector3): void;
  60359. /**
  60360. * Returns the light position for light scattering effect
  60361. * @return Vector3 The custom light position
  60362. */
  60363. getCustomMeshPosition(): Vector3;
  60364. /**
  60365. * Disposes the internal assets and detaches the post-process from the camera
  60366. */
  60367. dispose(camera: Camera): void;
  60368. /**
  60369. * Returns the render target texture used by the post-process
  60370. * @return the render target texture used by the post-process
  60371. */
  60372. getPass(): RenderTargetTexture;
  60373. private _meshExcluded;
  60374. private _createPass;
  60375. private _updateMeshScreenCoordinates;
  60376. /**
  60377. * Creates a default mesh for the Volumeric Light Scattering post-process
  60378. * @param name The mesh name
  60379. * @param scene The scene where to create the mesh
  60380. * @return the default mesh
  60381. */
  60382. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  60383. }
  60384. }
  60385. declare module "babylonjs/PostProcesses/index" {
  60386. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  60387. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  60388. export * from "babylonjs/PostProcesses/bloomEffect";
  60389. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  60390. export * from "babylonjs/PostProcesses/blurPostProcess";
  60391. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  60392. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  60393. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  60394. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  60395. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  60396. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  60397. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  60398. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  60399. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  60400. export * from "babylonjs/PostProcesses/filterPostProcess";
  60401. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  60402. export * from "babylonjs/PostProcesses/grainPostProcess";
  60403. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  60404. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  60405. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  60406. export * from "babylonjs/PostProcesses/passPostProcess";
  60407. export * from "babylonjs/PostProcesses/postProcess";
  60408. export * from "babylonjs/PostProcesses/postProcessManager";
  60409. export * from "babylonjs/PostProcesses/refractionPostProcess";
  60410. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  60411. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  60412. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  60413. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  60414. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  60415. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  60416. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  60417. }
  60418. declare module "babylonjs/Probes/index" {
  60419. export * from "babylonjs/Probes/reflectionProbe";
  60420. }
  60421. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  60422. import { Scene } from "babylonjs/scene";
  60423. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60424. import { Color3 } from "babylonjs/Maths/math";
  60425. import { SmartArray } from "babylonjs/Misc/smartArray";
  60426. import { ISceneComponent } from "babylonjs/sceneComponent";
  60427. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  60428. import "babylonjs/Meshes/Builders/boxBuilder";
  60429. import "babylonjs/Shaders/color.fragment";
  60430. import "babylonjs/Shaders/color.vertex";
  60431. module "babylonjs/scene" {
  60432. interface Scene {
  60433. /** @hidden (Backing field) */
  60434. _boundingBoxRenderer: BoundingBoxRenderer;
  60435. /** @hidden (Backing field) */
  60436. _forceShowBoundingBoxes: boolean;
  60437. /**
  60438. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  60439. */
  60440. forceShowBoundingBoxes: boolean;
  60441. /**
  60442. * Gets the bounding box renderer associated with the scene
  60443. * @returns a BoundingBoxRenderer
  60444. */
  60445. getBoundingBoxRenderer(): BoundingBoxRenderer;
  60446. }
  60447. }
  60448. module "babylonjs/Meshes/abstractMesh" {
  60449. interface AbstractMesh {
  60450. /** @hidden (Backing field) */
  60451. _showBoundingBox: boolean;
  60452. /**
  60453. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  60454. */
  60455. showBoundingBox: boolean;
  60456. }
  60457. }
  60458. /**
  60459. * Component responsible of rendering the bounding box of the meshes in a scene.
  60460. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  60461. */
  60462. export class BoundingBoxRenderer implements ISceneComponent {
  60463. /**
  60464. * The component name helpfull to identify the component in the list of scene components.
  60465. */
  60466. readonly name: string;
  60467. /**
  60468. * The scene the component belongs to.
  60469. */
  60470. scene: Scene;
  60471. /**
  60472. * Color of the bounding box lines placed in front of an object
  60473. */
  60474. frontColor: Color3;
  60475. /**
  60476. * Color of the bounding box lines placed behind an object
  60477. */
  60478. backColor: Color3;
  60479. /**
  60480. * Defines if the renderer should show the back lines or not
  60481. */
  60482. showBackLines: boolean;
  60483. /**
  60484. * @hidden
  60485. */
  60486. renderList: SmartArray<BoundingBox>;
  60487. private _colorShader;
  60488. private _vertexBuffers;
  60489. private _indexBuffer;
  60490. private _fillIndexBuffer;
  60491. private _fillIndexData;
  60492. /**
  60493. * Instantiates a new bounding box renderer in a scene.
  60494. * @param scene the scene the renderer renders in
  60495. */
  60496. constructor(scene: Scene);
  60497. /**
  60498. * Registers the component in a given scene
  60499. */
  60500. register(): void;
  60501. private _evaluateSubMesh;
  60502. private _activeMesh;
  60503. private _prepareRessources;
  60504. private _createIndexBuffer;
  60505. /**
  60506. * Rebuilds the elements related to this component in case of
  60507. * context lost for instance.
  60508. */
  60509. rebuild(): void;
  60510. /**
  60511. * @hidden
  60512. */
  60513. reset(): void;
  60514. /**
  60515. * Render the bounding boxes of a specific rendering group
  60516. * @param renderingGroupId defines the rendering group to render
  60517. */
  60518. render(renderingGroupId: number): void;
  60519. /**
  60520. * In case of occlusion queries, we can render the occlusion bounding box through this method
  60521. * @param mesh Define the mesh to render the occlusion bounding box for
  60522. */
  60523. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  60524. /**
  60525. * Dispose and release the resources attached to this renderer.
  60526. */
  60527. dispose(): void;
  60528. }
  60529. }
  60530. declare module "babylonjs/Shaders/depth.fragment" {
  60531. /** @hidden */
  60532. export var depthPixelShader: {
  60533. name: string;
  60534. shader: string;
  60535. };
  60536. }
  60537. declare module "babylonjs/Rendering/depthRenderer" {
  60538. import { Nullable } from "babylonjs/types";
  60539. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60540. import { Scene } from "babylonjs/scene";
  60541. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60542. import { Camera } from "babylonjs/Cameras/camera";
  60543. import "babylonjs/Shaders/depth.fragment";
  60544. import "babylonjs/Shaders/depth.vertex";
  60545. /**
  60546. * This represents a depth renderer in Babylon.
  60547. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60548. */
  60549. export class DepthRenderer {
  60550. private _scene;
  60551. private _depthMap;
  60552. private _effect;
  60553. private _cachedDefines;
  60554. private _camera;
  60555. /**
  60556. * Specifiess that the depth renderer will only be used within
  60557. * the camera it is created for.
  60558. * This can help forcing its rendering during the camera processing.
  60559. */
  60560. useOnlyInActiveCamera: boolean;
  60561. /** @hidden */
  60562. static _SceneComponentInitialization: (scene: Scene) => void;
  60563. /**
  60564. * Instantiates a depth renderer
  60565. * @param scene The scene the renderer belongs to
  60566. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60567. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60568. */
  60569. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  60570. /**
  60571. * Creates the depth rendering effect and checks if the effect is ready.
  60572. * @param subMesh The submesh to be used to render the depth map of
  60573. * @param useInstances If multiple world instances should be used
  60574. * @returns if the depth renderer is ready to render the depth map
  60575. */
  60576. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60577. /**
  60578. * Gets the texture which the depth map will be written to.
  60579. * @returns The depth map texture
  60580. */
  60581. getDepthMap(): RenderTargetTexture;
  60582. /**
  60583. * Disposes of the depth renderer.
  60584. */
  60585. dispose(): void;
  60586. }
  60587. }
  60588. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  60589. import { Nullable } from "babylonjs/types";
  60590. import { Scene } from "babylonjs/scene";
  60591. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  60592. import { Camera } from "babylonjs/Cameras/camera";
  60593. import { ISceneComponent } from "babylonjs/sceneComponent";
  60594. module "babylonjs/scene" {
  60595. interface Scene {
  60596. /** @hidden (Backing field) */
  60597. _depthRenderer: {
  60598. [id: string]: DepthRenderer;
  60599. };
  60600. /**
  60601. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  60602. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  60603. * @returns the created depth renderer
  60604. */
  60605. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  60606. /**
  60607. * Disables a depth renderer for a given camera
  60608. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  60609. */
  60610. disableDepthRenderer(camera?: Nullable<Camera>): void;
  60611. }
  60612. }
  60613. /**
  60614. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  60615. * in several rendering techniques.
  60616. */
  60617. export class DepthRendererSceneComponent implements ISceneComponent {
  60618. /**
  60619. * The component name helpfull to identify the component in the list of scene components.
  60620. */
  60621. readonly name: string;
  60622. /**
  60623. * The scene the component belongs to.
  60624. */
  60625. scene: Scene;
  60626. /**
  60627. * Creates a new instance of the component for the given scene
  60628. * @param scene Defines the scene to register the component in
  60629. */
  60630. constructor(scene: Scene);
  60631. /**
  60632. * Registers the component in a given scene
  60633. */
  60634. register(): void;
  60635. /**
  60636. * Rebuilds the elements related to this component in case of
  60637. * context lost for instance.
  60638. */
  60639. rebuild(): void;
  60640. /**
  60641. * Disposes the component and the associated ressources
  60642. */
  60643. dispose(): void;
  60644. private _gatherRenderTargets;
  60645. private _gatherActiveCameraRenderTargets;
  60646. }
  60647. }
  60648. declare module "babylonjs/Shaders/outline.fragment" {
  60649. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  60650. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  60651. /** @hidden */
  60652. export var outlinePixelShader: {
  60653. name: string;
  60654. shader: string;
  60655. };
  60656. }
  60657. declare module "babylonjs/Shaders/outline.vertex" {
  60658. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60659. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60660. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60661. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60662. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  60663. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60664. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60665. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60666. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  60667. /** @hidden */
  60668. export var outlineVertexShader: {
  60669. name: string;
  60670. shader: string;
  60671. };
  60672. }
  60673. declare module "babylonjs/Rendering/outlineRenderer" {
  60674. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60675. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  60676. import { Scene } from "babylonjs/scene";
  60677. import { ISceneComponent } from "babylonjs/sceneComponent";
  60678. import "babylonjs/Shaders/outline.fragment";
  60679. import "babylonjs/Shaders/outline.vertex";
  60680. module "babylonjs/scene" {
  60681. interface Scene {
  60682. /** @hidden */
  60683. _outlineRenderer: OutlineRenderer;
  60684. /**
  60685. * Gets the outline renderer associated with the scene
  60686. * @returns a OutlineRenderer
  60687. */
  60688. getOutlineRenderer(): OutlineRenderer;
  60689. }
  60690. }
  60691. module "babylonjs/Meshes/abstractMesh" {
  60692. interface AbstractMesh {
  60693. /** @hidden (Backing field) */
  60694. _renderOutline: boolean;
  60695. /**
  60696. * Gets or sets a boolean indicating if the outline must be rendered as well
  60697. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  60698. */
  60699. renderOutline: boolean;
  60700. /** @hidden (Backing field) */
  60701. _renderOverlay: boolean;
  60702. /**
  60703. * Gets or sets a boolean indicating if the overlay must be rendered as well
  60704. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  60705. */
  60706. renderOverlay: boolean;
  60707. }
  60708. }
  60709. /**
  60710. * This class is responsible to draw bothe outline/overlay of meshes.
  60711. * It should not be used directly but through the available method on mesh.
  60712. */
  60713. export class OutlineRenderer implements ISceneComponent {
  60714. /**
  60715. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  60716. */
  60717. private static _StencilReference;
  60718. /**
  60719. * The name of the component. Each component must have a unique name.
  60720. */
  60721. name: string;
  60722. /**
  60723. * The scene the component belongs to.
  60724. */
  60725. scene: Scene;
  60726. /**
  60727. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  60728. */
  60729. zOffset: number;
  60730. private _engine;
  60731. private _effect;
  60732. private _cachedDefines;
  60733. private _savedDepthWrite;
  60734. /**
  60735. * Instantiates a new outline renderer. (There could be only one per scene).
  60736. * @param scene Defines the scene it belongs to
  60737. */
  60738. constructor(scene: Scene);
  60739. /**
  60740. * Register the component to one instance of a scene.
  60741. */
  60742. register(): void;
  60743. /**
  60744. * Rebuilds the elements related to this component in case of
  60745. * context lost for instance.
  60746. */
  60747. rebuild(): void;
  60748. /**
  60749. * Disposes the component and the associated ressources.
  60750. */
  60751. dispose(): void;
  60752. /**
  60753. * Renders the outline in the canvas.
  60754. * @param subMesh Defines the sumesh to render
  60755. * @param batch Defines the batch of meshes in case of instances
  60756. * @param useOverlay Defines if the rendering is for the overlay or the outline
  60757. */
  60758. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  60759. /**
  60760. * Returns whether or not the outline renderer is ready for a given submesh.
  60761. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  60762. * @param subMesh Defines the submesh to check readyness for
  60763. * @param useInstances Defines wheter wee are trying to render instances or not
  60764. * @returns true if ready otherwise false
  60765. */
  60766. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60767. private _beforeRenderingMesh;
  60768. private _afterRenderingMesh;
  60769. }
  60770. }
  60771. declare module "babylonjs/Rendering/index" {
  60772. export * from "babylonjs/Rendering/boundingBoxRenderer";
  60773. export * from "babylonjs/Rendering/depthRenderer";
  60774. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  60775. export * from "babylonjs/Rendering/edgesRenderer";
  60776. export * from "babylonjs/Rendering/geometryBufferRenderer";
  60777. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  60778. export * from "babylonjs/Rendering/outlineRenderer";
  60779. export * from "babylonjs/Rendering/renderingGroup";
  60780. export * from "babylonjs/Rendering/renderingManager";
  60781. export * from "babylonjs/Rendering/utilityLayerRenderer";
  60782. }
  60783. declare module "babylonjs/Sprites/index" {
  60784. export * from "babylonjs/Sprites/sprite";
  60785. export * from "babylonjs/Sprites/spriteManager";
  60786. export * from "babylonjs/Sprites/spriteSceneComponent";
  60787. }
  60788. declare module "babylonjs/Misc/assetsManager" {
  60789. import { Scene } from "babylonjs/scene";
  60790. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60791. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60792. import { Skeleton } from "babylonjs/Bones/skeleton";
  60793. import { Observable } from "babylonjs/Misc/observable";
  60794. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60795. import { Texture } from "babylonjs/Materials/Textures/texture";
  60796. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  60797. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  60798. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  60799. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  60800. /**
  60801. * Defines the list of states available for a task inside a AssetsManager
  60802. */
  60803. export enum AssetTaskState {
  60804. /**
  60805. * Initialization
  60806. */
  60807. INIT = 0,
  60808. /**
  60809. * Running
  60810. */
  60811. RUNNING = 1,
  60812. /**
  60813. * Done
  60814. */
  60815. DONE = 2,
  60816. /**
  60817. * Error
  60818. */
  60819. ERROR = 3
  60820. }
  60821. /**
  60822. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  60823. */
  60824. export abstract class AbstractAssetTask {
  60825. /**
  60826. * Task name
  60827. */ name: string;
  60828. /**
  60829. * Callback called when the task is successful
  60830. */
  60831. onSuccess: (task: any) => void;
  60832. /**
  60833. * Callback called when the task is not successful
  60834. */
  60835. onError: (task: any, message?: string, exception?: any) => void;
  60836. /**
  60837. * Creates a new AssetsManager
  60838. * @param name defines the name of the task
  60839. */
  60840. constructor(
  60841. /**
  60842. * Task name
  60843. */ name: string);
  60844. private _isCompleted;
  60845. private _taskState;
  60846. private _errorObject;
  60847. /**
  60848. * Get if the task is completed
  60849. */
  60850. readonly isCompleted: boolean;
  60851. /**
  60852. * Gets the current state of the task
  60853. */
  60854. readonly taskState: AssetTaskState;
  60855. /**
  60856. * Gets the current error object (if task is in error)
  60857. */
  60858. readonly errorObject: {
  60859. message?: string;
  60860. exception?: any;
  60861. };
  60862. /**
  60863. * Internal only
  60864. * @hidden
  60865. */
  60866. _setErrorObject(message?: string, exception?: any): void;
  60867. /**
  60868. * Execute the current task
  60869. * @param scene defines the scene where you want your assets to be loaded
  60870. * @param onSuccess is a callback called when the task is successfully executed
  60871. * @param onError is a callback called if an error occurs
  60872. */
  60873. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60874. /**
  60875. * Execute the current task
  60876. * @param scene defines the scene where you want your assets to be loaded
  60877. * @param onSuccess is a callback called when the task is successfully executed
  60878. * @param onError is a callback called if an error occurs
  60879. */
  60880. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60881. /**
  60882. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  60883. * This can be used with failed tasks that have the reason for failure fixed.
  60884. */
  60885. reset(): void;
  60886. private onErrorCallback;
  60887. private onDoneCallback;
  60888. }
  60889. /**
  60890. * Define the interface used by progress events raised during assets loading
  60891. */
  60892. export interface IAssetsProgressEvent {
  60893. /**
  60894. * Defines the number of remaining tasks to process
  60895. */
  60896. remainingCount: number;
  60897. /**
  60898. * Defines the total number of tasks
  60899. */
  60900. totalCount: number;
  60901. /**
  60902. * Defines the task that was just processed
  60903. */
  60904. task: AbstractAssetTask;
  60905. }
  60906. /**
  60907. * Class used to share progress information about assets loading
  60908. */
  60909. export class AssetsProgressEvent implements IAssetsProgressEvent {
  60910. /**
  60911. * Defines the number of remaining tasks to process
  60912. */
  60913. remainingCount: number;
  60914. /**
  60915. * Defines the total number of tasks
  60916. */
  60917. totalCount: number;
  60918. /**
  60919. * Defines the task that was just processed
  60920. */
  60921. task: AbstractAssetTask;
  60922. /**
  60923. * Creates a AssetsProgressEvent
  60924. * @param remainingCount defines the number of remaining tasks to process
  60925. * @param totalCount defines the total number of tasks
  60926. * @param task defines the task that was just processed
  60927. */
  60928. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  60929. }
  60930. /**
  60931. * Define a task used by AssetsManager to load meshes
  60932. */
  60933. export class MeshAssetTask extends AbstractAssetTask {
  60934. /**
  60935. * Defines the name of the task
  60936. */
  60937. name: string;
  60938. /**
  60939. * Defines the list of mesh's names you want to load
  60940. */
  60941. meshesNames: any;
  60942. /**
  60943. * Defines the root url to use as a base to load your meshes and associated resources
  60944. */
  60945. rootUrl: string;
  60946. /**
  60947. * Defines the filename of the scene to load from
  60948. */
  60949. sceneFilename: string;
  60950. /**
  60951. * Gets the list of loaded meshes
  60952. */
  60953. loadedMeshes: Array<AbstractMesh>;
  60954. /**
  60955. * Gets the list of loaded particle systems
  60956. */
  60957. loadedParticleSystems: Array<IParticleSystem>;
  60958. /**
  60959. * Gets the list of loaded skeletons
  60960. */
  60961. loadedSkeletons: Array<Skeleton>;
  60962. /**
  60963. * Gets the list of loaded animation groups
  60964. */
  60965. loadedAnimationGroups: Array<AnimationGroup>;
  60966. /**
  60967. * Callback called when the task is successful
  60968. */
  60969. onSuccess: (task: MeshAssetTask) => void;
  60970. /**
  60971. * Callback called when the task is successful
  60972. */
  60973. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  60974. /**
  60975. * Creates a new MeshAssetTask
  60976. * @param name defines the name of the task
  60977. * @param meshesNames defines the list of mesh's names you want to load
  60978. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  60979. * @param sceneFilename defines the filename of the scene to load from
  60980. */
  60981. constructor(
  60982. /**
  60983. * Defines the name of the task
  60984. */
  60985. name: string,
  60986. /**
  60987. * Defines the list of mesh's names you want to load
  60988. */
  60989. meshesNames: any,
  60990. /**
  60991. * Defines the root url to use as a base to load your meshes and associated resources
  60992. */
  60993. rootUrl: string,
  60994. /**
  60995. * Defines the filename of the scene to load from
  60996. */
  60997. sceneFilename: string);
  60998. /**
  60999. * Execute the current task
  61000. * @param scene defines the scene where you want your assets to be loaded
  61001. * @param onSuccess is a callback called when the task is successfully executed
  61002. * @param onError is a callback called if an error occurs
  61003. */
  61004. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61005. }
  61006. /**
  61007. * Define a task used by AssetsManager to load text content
  61008. */
  61009. export class TextFileAssetTask extends AbstractAssetTask {
  61010. /**
  61011. * Defines the name of the task
  61012. */
  61013. name: string;
  61014. /**
  61015. * Defines the location of the file to load
  61016. */
  61017. url: string;
  61018. /**
  61019. * Gets the loaded text string
  61020. */
  61021. text: string;
  61022. /**
  61023. * Callback called when the task is successful
  61024. */
  61025. onSuccess: (task: TextFileAssetTask) => void;
  61026. /**
  61027. * Callback called when the task is successful
  61028. */
  61029. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  61030. /**
  61031. * Creates a new TextFileAssetTask object
  61032. * @param name defines the name of the task
  61033. * @param url defines the location of the file to load
  61034. */
  61035. constructor(
  61036. /**
  61037. * Defines the name of the task
  61038. */
  61039. name: string,
  61040. /**
  61041. * Defines the location of the file to load
  61042. */
  61043. url: string);
  61044. /**
  61045. * Execute the current task
  61046. * @param scene defines the scene where you want your assets to be loaded
  61047. * @param onSuccess is a callback called when the task is successfully executed
  61048. * @param onError is a callback called if an error occurs
  61049. */
  61050. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61051. }
  61052. /**
  61053. * Define a task used by AssetsManager to load binary data
  61054. */
  61055. export class BinaryFileAssetTask extends AbstractAssetTask {
  61056. /**
  61057. * Defines the name of the task
  61058. */
  61059. name: string;
  61060. /**
  61061. * Defines the location of the file to load
  61062. */
  61063. url: string;
  61064. /**
  61065. * Gets the lodaded data (as an array buffer)
  61066. */
  61067. data: ArrayBuffer;
  61068. /**
  61069. * Callback called when the task is successful
  61070. */
  61071. onSuccess: (task: BinaryFileAssetTask) => void;
  61072. /**
  61073. * Callback called when the task is successful
  61074. */
  61075. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  61076. /**
  61077. * Creates a new BinaryFileAssetTask object
  61078. * @param name defines the name of the new task
  61079. * @param url defines the location of the file to load
  61080. */
  61081. constructor(
  61082. /**
  61083. * Defines the name of the task
  61084. */
  61085. name: string,
  61086. /**
  61087. * Defines the location of the file to load
  61088. */
  61089. url: string);
  61090. /**
  61091. * Execute the current task
  61092. * @param scene defines the scene where you want your assets to be loaded
  61093. * @param onSuccess is a callback called when the task is successfully executed
  61094. * @param onError is a callback called if an error occurs
  61095. */
  61096. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61097. }
  61098. /**
  61099. * Define a task used by AssetsManager to load images
  61100. */
  61101. export class ImageAssetTask extends AbstractAssetTask {
  61102. /**
  61103. * Defines the name of the task
  61104. */
  61105. name: string;
  61106. /**
  61107. * Defines the location of the image to load
  61108. */
  61109. url: string;
  61110. /**
  61111. * Gets the loaded images
  61112. */
  61113. image: HTMLImageElement;
  61114. /**
  61115. * Callback called when the task is successful
  61116. */
  61117. onSuccess: (task: ImageAssetTask) => void;
  61118. /**
  61119. * Callback called when the task is successful
  61120. */
  61121. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  61122. /**
  61123. * Creates a new ImageAssetTask
  61124. * @param name defines the name of the task
  61125. * @param url defines the location of the image to load
  61126. */
  61127. constructor(
  61128. /**
  61129. * Defines the name of the task
  61130. */
  61131. name: string,
  61132. /**
  61133. * Defines the location of the image to load
  61134. */
  61135. url: string);
  61136. /**
  61137. * Execute the current task
  61138. * @param scene defines the scene where you want your assets to be loaded
  61139. * @param onSuccess is a callback called when the task is successfully executed
  61140. * @param onError is a callback called if an error occurs
  61141. */
  61142. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61143. }
  61144. /**
  61145. * Defines the interface used by texture loading tasks
  61146. */
  61147. export interface ITextureAssetTask<TEX extends BaseTexture> {
  61148. /**
  61149. * Gets the loaded texture
  61150. */
  61151. texture: TEX;
  61152. }
  61153. /**
  61154. * Define a task used by AssetsManager to load 2D textures
  61155. */
  61156. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  61157. /**
  61158. * Defines the name of the task
  61159. */
  61160. name: string;
  61161. /**
  61162. * Defines the location of the file to load
  61163. */
  61164. url: string;
  61165. /**
  61166. * Defines if mipmap should not be generated (default is false)
  61167. */
  61168. noMipmap?: boolean | undefined;
  61169. /**
  61170. * Defines if texture must be inverted on Y axis (default is false)
  61171. */
  61172. invertY?: boolean | undefined;
  61173. /**
  61174. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61175. */
  61176. samplingMode: number;
  61177. /**
  61178. * Gets the loaded texture
  61179. */
  61180. texture: Texture;
  61181. /**
  61182. * Callback called when the task is successful
  61183. */
  61184. onSuccess: (task: TextureAssetTask) => void;
  61185. /**
  61186. * Callback called when the task is successful
  61187. */
  61188. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  61189. /**
  61190. * Creates a new TextureAssetTask object
  61191. * @param name defines the name of the task
  61192. * @param url defines the location of the file to load
  61193. * @param noMipmap defines if mipmap should not be generated (default is false)
  61194. * @param invertY defines if texture must be inverted on Y axis (default is false)
  61195. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61196. */
  61197. constructor(
  61198. /**
  61199. * Defines the name of the task
  61200. */
  61201. name: string,
  61202. /**
  61203. * Defines the location of the file to load
  61204. */
  61205. url: string,
  61206. /**
  61207. * Defines if mipmap should not be generated (default is false)
  61208. */
  61209. noMipmap?: boolean | undefined,
  61210. /**
  61211. * Defines if texture must be inverted on Y axis (default is false)
  61212. */
  61213. invertY?: boolean | undefined,
  61214. /**
  61215. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  61216. */
  61217. samplingMode?: number);
  61218. /**
  61219. * Execute the current task
  61220. * @param scene defines the scene where you want your assets to be loaded
  61221. * @param onSuccess is a callback called when the task is successfully executed
  61222. * @param onError is a callback called if an error occurs
  61223. */
  61224. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61225. }
  61226. /**
  61227. * Define a task used by AssetsManager to load cube textures
  61228. */
  61229. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  61230. /**
  61231. * Defines the name of the task
  61232. */
  61233. name: string;
  61234. /**
  61235. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61236. */
  61237. url: string;
  61238. /**
  61239. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61240. */
  61241. extensions?: string[] | undefined;
  61242. /**
  61243. * Defines if mipmaps should not be generated (default is false)
  61244. */
  61245. noMipmap?: boolean | undefined;
  61246. /**
  61247. * Defines the explicit list of files (undefined by default)
  61248. */
  61249. files?: string[] | undefined;
  61250. /**
  61251. * Gets the loaded texture
  61252. */
  61253. texture: CubeTexture;
  61254. /**
  61255. * Callback called when the task is successful
  61256. */
  61257. onSuccess: (task: CubeTextureAssetTask) => void;
  61258. /**
  61259. * Callback called when the task is successful
  61260. */
  61261. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  61262. /**
  61263. * Creates a new CubeTextureAssetTask
  61264. * @param name defines the name of the task
  61265. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61266. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61267. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61268. * @param files defines the explicit list of files (undefined by default)
  61269. */
  61270. constructor(
  61271. /**
  61272. * Defines the name of the task
  61273. */
  61274. name: string,
  61275. /**
  61276. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  61277. */
  61278. url: string,
  61279. /**
  61280. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  61281. */
  61282. extensions?: string[] | undefined,
  61283. /**
  61284. * Defines if mipmaps should not be generated (default is false)
  61285. */
  61286. noMipmap?: boolean | undefined,
  61287. /**
  61288. * Defines the explicit list of files (undefined by default)
  61289. */
  61290. files?: string[] | undefined);
  61291. /**
  61292. * Execute the current task
  61293. * @param scene defines the scene where you want your assets to be loaded
  61294. * @param onSuccess is a callback called when the task is successfully executed
  61295. * @param onError is a callback called if an error occurs
  61296. */
  61297. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61298. }
  61299. /**
  61300. * Define a task used by AssetsManager to load HDR cube textures
  61301. */
  61302. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  61303. /**
  61304. * Defines the name of the task
  61305. */
  61306. name: string;
  61307. /**
  61308. * Defines the location of the file to load
  61309. */
  61310. url: string;
  61311. /**
  61312. * Defines the desired size (the more it increases the longer the generation will be)
  61313. */
  61314. size: number;
  61315. /**
  61316. * Defines if mipmaps should not be generated (default is false)
  61317. */
  61318. noMipmap: boolean;
  61319. /**
  61320. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61321. */
  61322. generateHarmonics: boolean;
  61323. /**
  61324. * 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)
  61325. */
  61326. gammaSpace: boolean;
  61327. /**
  61328. * Internal Use Only
  61329. */
  61330. reserved: boolean;
  61331. /**
  61332. * Gets the loaded texture
  61333. */
  61334. texture: HDRCubeTexture;
  61335. /**
  61336. * Callback called when the task is successful
  61337. */
  61338. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  61339. /**
  61340. * Callback called when the task is successful
  61341. */
  61342. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  61343. /**
  61344. * Creates a new HDRCubeTextureAssetTask object
  61345. * @param name defines the name of the task
  61346. * @param url defines the location of the file to load
  61347. * @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.
  61348. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61349. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61350. * @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)
  61351. * @param reserved Internal use only
  61352. */
  61353. constructor(
  61354. /**
  61355. * Defines the name of the task
  61356. */
  61357. name: string,
  61358. /**
  61359. * Defines the location of the file to load
  61360. */
  61361. url: string,
  61362. /**
  61363. * Defines the desired size (the more it increases the longer the generation will be)
  61364. */
  61365. size: number,
  61366. /**
  61367. * Defines if mipmaps should not be generated (default is false)
  61368. */
  61369. noMipmap?: boolean,
  61370. /**
  61371. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  61372. */
  61373. generateHarmonics?: boolean,
  61374. /**
  61375. * 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)
  61376. */
  61377. gammaSpace?: boolean,
  61378. /**
  61379. * Internal Use Only
  61380. */
  61381. reserved?: boolean);
  61382. /**
  61383. * Execute the current task
  61384. * @param scene defines the scene where you want your assets to be loaded
  61385. * @param onSuccess is a callback called when the task is successfully executed
  61386. * @param onError is a callback called if an error occurs
  61387. */
  61388. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61389. }
  61390. /**
  61391. * Define a task used by AssetsManager to load Equirectangular cube textures
  61392. */
  61393. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  61394. /**
  61395. * Defines the name of the task
  61396. */
  61397. name: string;
  61398. /**
  61399. * Defines the location of the file to load
  61400. */
  61401. url: string;
  61402. /**
  61403. * Defines the desired size (the more it increases the longer the generation will be)
  61404. */
  61405. size: number;
  61406. /**
  61407. * Defines if mipmaps should not be generated (default is false)
  61408. */
  61409. noMipmap: boolean;
  61410. /**
  61411. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61412. * but the standard material would require them in Gamma space) (default is true)
  61413. */
  61414. gammaSpace: boolean;
  61415. /**
  61416. * Gets the loaded texture
  61417. */
  61418. texture: EquiRectangularCubeTexture;
  61419. /**
  61420. * Callback called when the task is successful
  61421. */
  61422. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  61423. /**
  61424. * Callback called when the task is successful
  61425. */
  61426. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  61427. /**
  61428. * Creates a new EquiRectangularCubeTextureAssetTask object
  61429. * @param name defines the name of the task
  61430. * @param url defines the location of the file to load
  61431. * @param size defines the desired size (the more it increases the longer the generation will be)
  61432. * If the size is omitted this implies you are using a preprocessed cubemap.
  61433. * @param noMipmap defines if mipmaps should not be generated (default is false)
  61434. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  61435. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  61436. * (default is true)
  61437. */
  61438. constructor(
  61439. /**
  61440. * Defines the name of the task
  61441. */
  61442. name: string,
  61443. /**
  61444. * Defines the location of the file to load
  61445. */
  61446. url: string,
  61447. /**
  61448. * Defines the desired size (the more it increases the longer the generation will be)
  61449. */
  61450. size: number,
  61451. /**
  61452. * Defines if mipmaps should not be generated (default is false)
  61453. */
  61454. noMipmap?: boolean,
  61455. /**
  61456. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  61457. * but the standard material would require them in Gamma space) (default is true)
  61458. */
  61459. gammaSpace?: boolean);
  61460. /**
  61461. * Execute the current task
  61462. * @param scene defines the scene where you want your assets to be loaded
  61463. * @param onSuccess is a callback called when the task is successfully executed
  61464. * @param onError is a callback called if an error occurs
  61465. */
  61466. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  61467. }
  61468. /**
  61469. * This class can be used to easily import assets into a scene
  61470. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  61471. */
  61472. export class AssetsManager {
  61473. private _scene;
  61474. private _isLoading;
  61475. protected _tasks: AbstractAssetTask[];
  61476. protected _waitingTasksCount: number;
  61477. protected _totalTasksCount: number;
  61478. /**
  61479. * Callback called when all tasks are processed
  61480. */
  61481. onFinish: (tasks: AbstractAssetTask[]) => void;
  61482. /**
  61483. * Callback called when a task is successful
  61484. */
  61485. onTaskSuccess: (task: AbstractAssetTask) => void;
  61486. /**
  61487. * Callback called when a task had an error
  61488. */
  61489. onTaskError: (task: AbstractAssetTask) => void;
  61490. /**
  61491. * Callback called when a task is done (whatever the result is)
  61492. */
  61493. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  61494. /**
  61495. * Observable called when all tasks are processed
  61496. */
  61497. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  61498. /**
  61499. * Observable called when a task had an error
  61500. */
  61501. onTaskErrorObservable: Observable<AbstractAssetTask>;
  61502. /**
  61503. * Observable called when all tasks were executed
  61504. */
  61505. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  61506. /**
  61507. * Observable called when a task is done (whatever the result is)
  61508. */
  61509. onProgressObservable: Observable<IAssetsProgressEvent>;
  61510. /**
  61511. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  61512. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  61513. */
  61514. useDefaultLoadingScreen: boolean;
  61515. /**
  61516. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  61517. * when all assets have been downloaded.
  61518. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  61519. */
  61520. autoHideLoadingUI: boolean;
  61521. /**
  61522. * Creates a new AssetsManager
  61523. * @param scene defines the scene to work on
  61524. */
  61525. constructor(scene: Scene);
  61526. /**
  61527. * Add a MeshAssetTask to the list of active tasks
  61528. * @param taskName defines the name of the new task
  61529. * @param meshesNames defines the name of meshes to load
  61530. * @param rootUrl defines the root url to use to locate files
  61531. * @param sceneFilename defines the filename of the scene file
  61532. * @returns a new MeshAssetTask object
  61533. */
  61534. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  61535. /**
  61536. * Add a TextFileAssetTask to the list of active tasks
  61537. * @param taskName defines the name of the new task
  61538. * @param url defines the url of the file to load
  61539. * @returns a new TextFileAssetTask object
  61540. */
  61541. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  61542. /**
  61543. * Add a BinaryFileAssetTask to the list of active tasks
  61544. * @param taskName defines the name of the new task
  61545. * @param url defines the url of the file to load
  61546. * @returns a new BinaryFileAssetTask object
  61547. */
  61548. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  61549. /**
  61550. * Add a ImageAssetTask to the list of active tasks
  61551. * @param taskName defines the name of the new task
  61552. * @param url defines the url of the file to load
  61553. * @returns a new ImageAssetTask object
  61554. */
  61555. addImageTask(taskName: string, url: string): ImageAssetTask;
  61556. /**
  61557. * Add a TextureAssetTask to the list of active tasks
  61558. * @param taskName defines the name of the new task
  61559. * @param url defines the url of the file to load
  61560. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61561. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  61562. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61563. * @returns a new TextureAssetTask object
  61564. */
  61565. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  61566. /**
  61567. * Add a CubeTextureAssetTask to the list of active tasks
  61568. * @param taskName defines the name of the new task
  61569. * @param url defines the url of the file to load
  61570. * @param extensions defines the extension to use to load the cube map (can be null)
  61571. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61572. * @param files defines the list of files to load (can be null)
  61573. * @returns a new CubeTextureAssetTask object
  61574. */
  61575. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  61576. /**
  61577. *
  61578. * Add a HDRCubeTextureAssetTask to the list of active tasks
  61579. * @param taskName defines the name of the new task
  61580. * @param url defines the url of the file to load
  61581. * @param size defines the size you want for the cubemap (can be null)
  61582. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61583. * @param generateHarmonics defines if you want to automatically generate (true by default)
  61584. * @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)
  61585. * @param reserved Internal use only
  61586. * @returns a new HDRCubeTextureAssetTask object
  61587. */
  61588. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  61589. /**
  61590. *
  61591. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  61592. * @param taskName defines the name of the new task
  61593. * @param url defines the url of the file to load
  61594. * @param size defines the size you want for the cubemap (can be null)
  61595. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  61596. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61597. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61598. * @returns a new EquiRectangularCubeTextureAssetTask object
  61599. */
  61600. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  61601. /**
  61602. * Remove a task from the assets manager.
  61603. * @param task the task to remove
  61604. */
  61605. removeTask(task: AbstractAssetTask): void;
  61606. private _decreaseWaitingTasksCount;
  61607. private _runTask;
  61608. /**
  61609. * Reset the AssetsManager and remove all tasks
  61610. * @return the current instance of the AssetsManager
  61611. */
  61612. reset(): AssetsManager;
  61613. /**
  61614. * Start the loading process
  61615. * @return the current instance of the AssetsManager
  61616. */
  61617. load(): AssetsManager;
  61618. /**
  61619. * Start the loading process as an async operation
  61620. * @return a promise returning the list of failed tasks
  61621. */
  61622. loadAsync(): Promise<void>;
  61623. }
  61624. }
  61625. declare module "babylonjs/Misc/deferred" {
  61626. /**
  61627. * Wrapper class for promise with external resolve and reject.
  61628. */
  61629. export class Deferred<T> {
  61630. /**
  61631. * The promise associated with this deferred object.
  61632. */
  61633. readonly promise: Promise<T>;
  61634. private _resolve;
  61635. private _reject;
  61636. /**
  61637. * The resolve method of the promise associated with this deferred object.
  61638. */
  61639. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  61640. /**
  61641. * The reject method of the promise associated with this deferred object.
  61642. */
  61643. readonly reject: (reason?: any) => void;
  61644. /**
  61645. * Constructor for this deferred object.
  61646. */
  61647. constructor();
  61648. }
  61649. }
  61650. declare module "babylonjs/Misc/meshExploder" {
  61651. import { Mesh } from "babylonjs/Meshes/mesh";
  61652. /**
  61653. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  61654. */
  61655. export class MeshExploder {
  61656. private _centerMesh;
  61657. private _meshes;
  61658. private _meshesOrigins;
  61659. private _toCenterVectors;
  61660. private _scaledDirection;
  61661. private _newPosition;
  61662. private _centerPosition;
  61663. /**
  61664. * Explodes meshes from a center mesh.
  61665. * @param meshes The meshes to explode.
  61666. * @param centerMesh The mesh to be center of explosion.
  61667. */
  61668. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  61669. private _setCenterMesh;
  61670. /**
  61671. * Get class name
  61672. * @returns "MeshExploder"
  61673. */
  61674. getClassName(): string;
  61675. /**
  61676. * "Exploded meshes"
  61677. * @returns Array of meshes with the centerMesh at index 0.
  61678. */
  61679. getMeshes(): Array<Mesh>;
  61680. /**
  61681. * Explodes meshes giving a specific direction
  61682. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  61683. */
  61684. explode(direction?: number): void;
  61685. }
  61686. }
  61687. declare module "babylonjs/Misc/filesInput" {
  61688. import { Engine } from "babylonjs/Engines/engine";
  61689. import { Scene } from "babylonjs/scene";
  61690. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  61691. /**
  61692. * Class used to help managing file picking and drag'n'drop
  61693. */
  61694. export class FilesInput {
  61695. /**
  61696. * List of files ready to be loaded
  61697. */
  61698. static readonly FilesToLoad: {
  61699. [key: string]: File;
  61700. };
  61701. /**
  61702. * Callback called when a file is processed
  61703. */
  61704. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  61705. private _engine;
  61706. private _currentScene;
  61707. private _sceneLoadedCallback;
  61708. private _progressCallback;
  61709. private _additionalRenderLoopLogicCallback;
  61710. private _textureLoadingCallback;
  61711. private _startingProcessingFilesCallback;
  61712. private _onReloadCallback;
  61713. private _errorCallback;
  61714. private _elementToMonitor;
  61715. private _sceneFileToLoad;
  61716. private _filesToLoad;
  61717. /**
  61718. * Creates a new FilesInput
  61719. * @param engine defines the rendering engine
  61720. * @param scene defines the hosting scene
  61721. * @param sceneLoadedCallback callback called when scene is loaded
  61722. * @param progressCallback callback called to track progress
  61723. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  61724. * @param textureLoadingCallback callback called when a texture is loading
  61725. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  61726. * @param onReloadCallback callback called when a reload is requested
  61727. * @param errorCallback callback call if an error occurs
  61728. */
  61729. 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);
  61730. private _dragEnterHandler;
  61731. private _dragOverHandler;
  61732. private _dropHandler;
  61733. /**
  61734. * Calls this function to listen to drag'n'drop events on a specific DOM element
  61735. * @param elementToMonitor defines the DOM element to track
  61736. */
  61737. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  61738. /**
  61739. * Release all associated resources
  61740. */
  61741. dispose(): void;
  61742. private renderFunction;
  61743. private drag;
  61744. private drop;
  61745. private _traverseFolder;
  61746. private _processFiles;
  61747. /**
  61748. * Load files from a drop event
  61749. * @param event defines the drop event to use as source
  61750. */
  61751. loadFiles(event: any): void;
  61752. private _processReload;
  61753. /**
  61754. * Reload the current scene from the loaded files
  61755. */
  61756. reload(): void;
  61757. }
  61758. }
  61759. declare module "babylonjs/Misc/HighDynamicRange/index" {
  61760. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  61761. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  61762. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  61763. }
  61764. declare module "babylonjs/Misc/sceneOptimizer" {
  61765. import { Scene, IDisposable } from "babylonjs/scene";
  61766. import { Observable } from "babylonjs/Misc/observable";
  61767. /**
  61768. * Defines the root class used to create scene optimization to use with SceneOptimizer
  61769. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61770. */
  61771. export class SceneOptimization {
  61772. /**
  61773. * Defines the priority of this optimization (0 by default which means first in the list)
  61774. */
  61775. priority: number;
  61776. /**
  61777. * Gets a string describing the action executed by the current optimization
  61778. * @returns description string
  61779. */
  61780. getDescription(): string;
  61781. /**
  61782. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61783. * @param scene defines the current scene where to apply this optimization
  61784. * @param optimizer defines the current optimizer
  61785. * @returns true if everything that can be done was applied
  61786. */
  61787. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61788. /**
  61789. * Creates the SceneOptimization object
  61790. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61791. * @param desc defines the description associated with the optimization
  61792. */
  61793. constructor(
  61794. /**
  61795. * Defines the priority of this optimization (0 by default which means first in the list)
  61796. */
  61797. priority?: number);
  61798. }
  61799. /**
  61800. * Defines an optimization used to reduce the size of render target textures
  61801. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61802. */
  61803. export class TextureOptimization extends SceneOptimization {
  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 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
  61810. */
  61811. maximumSize: number;
  61812. /**
  61813. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61814. */
  61815. step: number;
  61816. /**
  61817. * Gets a string describing the action executed by the current optimization
  61818. * @returns description string
  61819. */
  61820. getDescription(): string;
  61821. /**
  61822. * Creates the TextureOptimization object
  61823. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61824. * @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
  61825. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61826. */
  61827. constructor(
  61828. /**
  61829. * Defines the priority of this optimization (0 by default which means first in the list)
  61830. */
  61831. priority?: number,
  61832. /**
  61833. * 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
  61834. */
  61835. maximumSize?: number,
  61836. /**
  61837. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  61838. */
  61839. step?: number);
  61840. /**
  61841. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61842. * @param scene defines the current scene where to apply this optimization
  61843. * @param optimizer defines the current optimizer
  61844. * @returns true if everything that can be done was applied
  61845. */
  61846. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61847. }
  61848. /**
  61849. * Defines an optimization used to increase or decrease the rendering resolution
  61850. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61851. */
  61852. export class HardwareScalingOptimization extends SceneOptimization {
  61853. /**
  61854. * Defines the priority of this optimization (0 by default which means first in the list)
  61855. */
  61856. priority: number;
  61857. /**
  61858. * Defines the maximum scale to use (2 by default)
  61859. */
  61860. maximumScale: number;
  61861. /**
  61862. * Defines the step to use between two passes (0.5 by default)
  61863. */
  61864. step: number;
  61865. private _currentScale;
  61866. private _directionOffset;
  61867. /**
  61868. * Gets a string describing the action executed by the current optimization
  61869. * @return description string
  61870. */
  61871. getDescription(): string;
  61872. /**
  61873. * Creates the HardwareScalingOptimization object
  61874. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61875. * @param maximumScale defines the maximum scale to use (2 by default)
  61876. * @param step defines the step to use between two passes (0.5 by default)
  61877. */
  61878. constructor(
  61879. /**
  61880. * Defines the priority of this optimization (0 by default which means first in the list)
  61881. */
  61882. priority?: number,
  61883. /**
  61884. * Defines the maximum scale to use (2 by default)
  61885. */
  61886. maximumScale?: number,
  61887. /**
  61888. * Defines the step to use between two passes (0.5 by default)
  61889. */
  61890. step?: number);
  61891. /**
  61892. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61893. * @param scene defines the current scene where to apply this optimization
  61894. * @param optimizer defines the current optimizer
  61895. * @returns true if everything that can be done was applied
  61896. */
  61897. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61898. }
  61899. /**
  61900. * Defines an optimization used to remove shadows
  61901. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61902. */
  61903. export class ShadowsOptimization extends SceneOptimization {
  61904. /**
  61905. * Gets a string describing the action executed by the current optimization
  61906. * @return description string
  61907. */
  61908. getDescription(): string;
  61909. /**
  61910. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61911. * @param scene defines the current scene where to apply this optimization
  61912. * @param optimizer defines the current optimizer
  61913. * @returns true if everything that can be done was applied
  61914. */
  61915. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61916. }
  61917. /**
  61918. * Defines an optimization used to turn post-processes off
  61919. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61920. */
  61921. export class PostProcessesOptimization extends SceneOptimization {
  61922. /**
  61923. * Gets a string describing the action executed by the current optimization
  61924. * @return description string
  61925. */
  61926. getDescription(): string;
  61927. /**
  61928. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61929. * @param scene defines the current scene where to apply this optimization
  61930. * @param optimizer defines the current optimizer
  61931. * @returns true if everything that can be done was applied
  61932. */
  61933. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61934. }
  61935. /**
  61936. * Defines an optimization used to turn lens flares off
  61937. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61938. */
  61939. export class LensFlaresOptimization extends SceneOptimization {
  61940. /**
  61941. * Gets a string describing the action executed by the current optimization
  61942. * @return description string
  61943. */
  61944. getDescription(): string;
  61945. /**
  61946. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61947. * @param scene defines the current scene where to apply this optimization
  61948. * @param optimizer defines the current optimizer
  61949. * @returns true if everything that can be done was applied
  61950. */
  61951. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61952. }
  61953. /**
  61954. * Defines an optimization based on user defined callback.
  61955. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61956. */
  61957. export class CustomOptimization extends SceneOptimization {
  61958. /**
  61959. * Callback called to apply the custom optimization.
  61960. */
  61961. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  61962. /**
  61963. * Callback called to get custom description
  61964. */
  61965. onGetDescription: () => string;
  61966. /**
  61967. * Gets a string describing the action executed by the current optimization
  61968. * @returns description string
  61969. */
  61970. getDescription(): string;
  61971. /**
  61972. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61973. * @param scene defines the current scene where to apply this optimization
  61974. * @param optimizer defines the current optimizer
  61975. * @returns true if everything that can be done was applied
  61976. */
  61977. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61978. }
  61979. /**
  61980. * Defines an optimization used to turn particles off
  61981. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61982. */
  61983. export class ParticlesOptimization extends SceneOptimization {
  61984. /**
  61985. * Gets a string describing the action executed by the current optimization
  61986. * @return description string
  61987. */
  61988. getDescription(): string;
  61989. /**
  61990. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61991. * @param scene defines the current scene where to apply this optimization
  61992. * @param optimizer defines the current optimizer
  61993. * @returns true if everything that can be done was applied
  61994. */
  61995. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61996. }
  61997. /**
  61998. * Defines an optimization used to turn render targets off
  61999. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62000. */
  62001. export class RenderTargetsOptimization extends SceneOptimization {
  62002. /**
  62003. * Gets a string describing the action executed by the current optimization
  62004. * @return description string
  62005. */
  62006. getDescription(): string;
  62007. /**
  62008. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62009. * @param scene defines the current scene where to apply this optimization
  62010. * @param optimizer defines the current optimizer
  62011. * @returns true if everything that can be done was applied
  62012. */
  62013. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  62014. }
  62015. /**
  62016. * Defines an optimization used to merge meshes with compatible materials
  62017. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62018. */
  62019. export class MergeMeshesOptimization extends SceneOptimization {
  62020. private static _UpdateSelectionTree;
  62021. /**
  62022. * Gets or sets a boolean which defines if optimization octree has to be updated
  62023. */
  62024. /**
  62025. * Gets or sets a boolean which defines if optimization octree has to be updated
  62026. */
  62027. static UpdateSelectionTree: boolean;
  62028. /**
  62029. * Gets a string describing the action executed by the current optimization
  62030. * @return description string
  62031. */
  62032. getDescription(): string;
  62033. private _canBeMerged;
  62034. /**
  62035. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  62036. * @param scene defines the current scene where to apply this optimization
  62037. * @param optimizer defines the current optimizer
  62038. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  62039. * @returns true if everything that can be done was applied
  62040. */
  62041. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  62042. }
  62043. /**
  62044. * Defines a list of options used by SceneOptimizer
  62045. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62046. */
  62047. export class SceneOptimizerOptions {
  62048. /**
  62049. * Defines the target frame rate to reach (60 by default)
  62050. */
  62051. targetFrameRate: number;
  62052. /**
  62053. * Defines the interval between two checkes (2000ms by default)
  62054. */
  62055. trackerDuration: number;
  62056. /**
  62057. * Gets the list of optimizations to apply
  62058. */
  62059. optimizations: SceneOptimization[];
  62060. /**
  62061. * Creates a new list of options used by SceneOptimizer
  62062. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  62063. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  62064. */
  62065. constructor(
  62066. /**
  62067. * Defines the target frame rate to reach (60 by default)
  62068. */
  62069. targetFrameRate?: number,
  62070. /**
  62071. * Defines the interval between two checkes (2000ms by default)
  62072. */
  62073. trackerDuration?: number);
  62074. /**
  62075. * Add a new optimization
  62076. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  62077. * @returns the current SceneOptimizerOptions
  62078. */
  62079. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  62080. /**
  62081. * Add a new custom optimization
  62082. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  62083. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  62084. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  62085. * @returns the current SceneOptimizerOptions
  62086. */
  62087. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  62088. /**
  62089. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  62090. * @param targetFrameRate defines the target frame rate (60 by default)
  62091. * @returns a SceneOptimizerOptions object
  62092. */
  62093. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62094. /**
  62095. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  62096. * @param targetFrameRate defines the target frame rate (60 by default)
  62097. * @returns a SceneOptimizerOptions object
  62098. */
  62099. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62100. /**
  62101. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  62102. * @param targetFrameRate defines the target frame rate (60 by default)
  62103. * @returns a SceneOptimizerOptions object
  62104. */
  62105. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  62106. }
  62107. /**
  62108. * Class used to run optimizations in order to reach a target frame rate
  62109. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  62110. */
  62111. export class SceneOptimizer implements IDisposable {
  62112. private _isRunning;
  62113. private _options;
  62114. private _scene;
  62115. private _currentPriorityLevel;
  62116. private _targetFrameRate;
  62117. private _trackerDuration;
  62118. private _currentFrameRate;
  62119. private _sceneDisposeObserver;
  62120. private _improvementMode;
  62121. /**
  62122. * Defines an observable called when the optimizer reaches the target frame rate
  62123. */
  62124. onSuccessObservable: Observable<SceneOptimizer>;
  62125. /**
  62126. * Defines an observable called when the optimizer enables an optimization
  62127. */
  62128. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  62129. /**
  62130. * Defines an observable called when the optimizer is not able to reach the target frame rate
  62131. */
  62132. onFailureObservable: Observable<SceneOptimizer>;
  62133. /**
  62134. * Gets a boolean indicating if the optimizer is in improvement mode
  62135. */
  62136. readonly isInImprovementMode: boolean;
  62137. /**
  62138. * Gets the current priority level (0 at start)
  62139. */
  62140. readonly currentPriorityLevel: number;
  62141. /**
  62142. * Gets the current frame rate checked by the SceneOptimizer
  62143. */
  62144. readonly currentFrameRate: number;
  62145. /**
  62146. * Gets or sets the current target frame rate (60 by default)
  62147. */
  62148. /**
  62149. * Gets or sets the current target frame rate (60 by default)
  62150. */
  62151. targetFrameRate: number;
  62152. /**
  62153. * Gets or sets the current interval between two checks (every 2000ms by default)
  62154. */
  62155. /**
  62156. * Gets or sets the current interval between two checks (every 2000ms by default)
  62157. */
  62158. trackerDuration: number;
  62159. /**
  62160. * Gets the list of active optimizations
  62161. */
  62162. readonly optimizations: SceneOptimization[];
  62163. /**
  62164. * Creates a new SceneOptimizer
  62165. * @param scene defines the scene to work on
  62166. * @param options defines the options to use with the SceneOptimizer
  62167. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  62168. * @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)
  62169. */
  62170. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  62171. /**
  62172. * Stops the current optimizer
  62173. */
  62174. stop(): void;
  62175. /**
  62176. * Reset the optimizer to initial step (current priority level = 0)
  62177. */
  62178. reset(): void;
  62179. /**
  62180. * Start the optimizer. By default it will try to reach a specific framerate
  62181. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  62182. */
  62183. start(): void;
  62184. private _checkCurrentState;
  62185. /**
  62186. * Release all resources
  62187. */
  62188. dispose(): void;
  62189. /**
  62190. * Helper function to create a SceneOptimizer with one single line of code
  62191. * @param scene defines the scene to work on
  62192. * @param options defines the options to use with the SceneOptimizer
  62193. * @param onSuccess defines a callback to call on success
  62194. * @param onFailure defines a callback to call on failure
  62195. * @returns the new SceneOptimizer object
  62196. */
  62197. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  62198. }
  62199. }
  62200. declare module "babylonjs/Misc/sceneSerializer" {
  62201. import { Scene } from "babylonjs/scene";
  62202. /**
  62203. * Class used to serialize a scene into a string
  62204. */
  62205. export class SceneSerializer {
  62206. /**
  62207. * Clear cache used by a previous serialization
  62208. */
  62209. static ClearCache(): void;
  62210. /**
  62211. * Serialize a scene into a JSON compatible object
  62212. * @param scene defines the scene to serialize
  62213. * @returns a JSON compatible object
  62214. */
  62215. static Serialize(scene: Scene): any;
  62216. /**
  62217. * Serialize a mesh into a JSON compatible object
  62218. * @param toSerialize defines the mesh to serialize
  62219. * @param withParents defines if parents must be serialized as well
  62220. * @param withChildren defines if children must be serialized as well
  62221. * @returns a JSON compatible object
  62222. */
  62223. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  62224. }
  62225. }
  62226. declare module "babylonjs/Misc/textureTools" {
  62227. import { Texture } from "babylonjs/Materials/Textures/texture";
  62228. /**
  62229. * Class used to host texture specific utilities
  62230. */
  62231. export class TextureTools {
  62232. /**
  62233. * Uses the GPU to create a copy texture rescaled at a given size
  62234. * @param texture Texture to copy from
  62235. * @param width defines the desired width
  62236. * @param height defines the desired height
  62237. * @param useBilinearMode defines if bilinear mode has to be used
  62238. * @return the generated texture
  62239. */
  62240. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  62241. }
  62242. }
  62243. declare module "babylonjs/Misc/videoRecorder" {
  62244. import { Nullable } from "babylonjs/types";
  62245. import { Engine } from "babylonjs/Engines/engine";
  62246. /**
  62247. * This represents the different options available for the video capture.
  62248. */
  62249. export interface VideoRecorderOptions {
  62250. /** Defines the mime type of the video. */
  62251. mimeType: string;
  62252. /** Defines the FPS the video should be recorded at. */
  62253. fps: number;
  62254. /** Defines the chunk size for the recording data. */
  62255. recordChunckSize: number;
  62256. /** The audio tracks to attach to the recording. */
  62257. audioTracks?: MediaStreamTrack[];
  62258. }
  62259. /**
  62260. * This can help with recording videos from BabylonJS.
  62261. * This is based on the available WebRTC functionalities of the browser.
  62262. *
  62263. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  62264. */
  62265. export class VideoRecorder {
  62266. private static readonly _defaultOptions;
  62267. /**
  62268. * Returns whether or not the VideoRecorder is available in your browser.
  62269. * @param engine Defines the Babylon Engine.
  62270. * @returns true if supported otherwise false.
  62271. */
  62272. static IsSupported(engine: Engine): boolean;
  62273. private readonly _options;
  62274. private _canvas;
  62275. private _mediaRecorder;
  62276. private _recordedChunks;
  62277. private _fileName;
  62278. private _resolve;
  62279. private _reject;
  62280. /**
  62281. * True when a recording is already in progress.
  62282. */
  62283. readonly isRecording: boolean;
  62284. /**
  62285. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  62286. * @param engine Defines the BabylonJS Engine you wish to record.
  62287. * @param options Defines options that can be used to customize the capture.
  62288. */
  62289. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  62290. /**
  62291. * Stops the current recording before the default capture timeout passed in the startRecording function.
  62292. */
  62293. stopRecording(): void;
  62294. /**
  62295. * Starts recording the canvas for a max duration specified in parameters.
  62296. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  62297. * If null no automatic download will start and you can rely on the promise to get the data back.
  62298. * @param maxDuration Defines the maximum recording time in seconds.
  62299. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  62300. * @return A promise callback at the end of the recording with the video data in Blob.
  62301. */
  62302. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  62303. /**
  62304. * Releases internal resources used during the recording.
  62305. */
  62306. dispose(): void;
  62307. private _handleDataAvailable;
  62308. private _handleError;
  62309. private _handleStop;
  62310. }
  62311. }
  62312. declare module "babylonjs/Misc/screenshotTools" {
  62313. import { Camera } from "babylonjs/Cameras/camera";
  62314. import { Engine } from "babylonjs/Engines/engine";
  62315. /**
  62316. * Class containing a set of static utilities functions for screenshots
  62317. */
  62318. export class ScreenshotTools {
  62319. /**
  62320. * Captures a screenshot of the current rendering
  62321. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62322. * @param engine defines the rendering engine
  62323. * @param camera defines the source camera
  62324. * @param size This parameter can be set to a single number or to an object with the
  62325. * following (optional) properties: precision, width, height. If a single number is passed,
  62326. * it will be used for both width and height. If an object is passed, the screenshot size
  62327. * will be derived from the parameters. The precision property is a multiplier allowing
  62328. * rendering at a higher or lower resolution
  62329. * @param successCallback defines the callback receives a single parameter which contains the
  62330. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62331. * src parameter of an <img> to display it
  62332. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  62333. * Check your browser for supported MIME types
  62334. */
  62335. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  62336. /**
  62337. * Generates an image screenshot from the specified camera.
  62338. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  62339. * @param engine The engine to use for rendering
  62340. * @param camera The camera to use for rendering
  62341. * @param size This parameter can be set to a single number or to an object with the
  62342. * following (optional) properties: precision, width, height. If a single number is passed,
  62343. * it will be used for both width and height. If an object is passed, the screenshot size
  62344. * will be derived from the parameters. The precision property is a multiplier allowing
  62345. * rendering at a higher or lower resolution
  62346. * @param successCallback The callback receives a single parameter which contains the
  62347. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  62348. * src parameter of an <img> to display it
  62349. * @param mimeType The MIME type of the screenshot image (default: image/png).
  62350. * Check your browser for supported MIME types
  62351. * @param samples Texture samples (default: 1)
  62352. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  62353. * @param fileName A name for for the downloaded file.
  62354. */
  62355. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  62356. }
  62357. }
  62358. declare module "babylonjs/Misc/index" {
  62359. export * from "babylonjs/Misc/andOrNotEvaluator";
  62360. export * from "babylonjs/Misc/assetsManager";
  62361. export * from "babylonjs/Misc/dds";
  62362. export * from "babylonjs/Misc/decorators";
  62363. export * from "babylonjs/Misc/deferred";
  62364. export * from "babylonjs/Misc/environmentTextureTools";
  62365. export * from "babylonjs/Misc/meshExploder";
  62366. export * from "babylonjs/Misc/filesInput";
  62367. export * from "babylonjs/Misc/HighDynamicRange/index";
  62368. export * from "babylonjs/Misc/khronosTextureContainer";
  62369. export * from "babylonjs/Misc/observable";
  62370. export * from "babylonjs/Misc/performanceMonitor";
  62371. export * from "babylonjs/Misc/promise";
  62372. export * from "babylonjs/Misc/sceneOptimizer";
  62373. export * from "babylonjs/Misc/sceneSerializer";
  62374. export * from "babylonjs/Misc/smartArray";
  62375. export * from "babylonjs/Misc/stringDictionary";
  62376. export * from "babylonjs/Misc/tags";
  62377. export * from "babylonjs/Misc/textureTools";
  62378. export * from "babylonjs/Misc/tga";
  62379. export * from "babylonjs/Misc/tools";
  62380. export * from "babylonjs/Misc/videoRecorder";
  62381. export * from "babylonjs/Misc/virtualJoystick";
  62382. export * from "babylonjs/Misc/workerPool";
  62383. export * from "babylonjs/Misc/logger";
  62384. export * from "babylonjs/Misc/typeStore";
  62385. export * from "babylonjs/Misc/filesInputStore";
  62386. export * from "babylonjs/Misc/deepCopier";
  62387. export * from "babylonjs/Misc/pivotTools";
  62388. export * from "babylonjs/Misc/precisionDate";
  62389. export * from "babylonjs/Misc/screenshotTools";
  62390. export * from "babylonjs/Misc/typeStore";
  62391. export * from "babylonjs/Misc/webRequest";
  62392. export * from "babylonjs/Misc/iInspectable";
  62393. export * from "babylonjs/Misc/brdfTextureTools";
  62394. }
  62395. declare module "babylonjs/index" {
  62396. export * from "babylonjs/abstractScene";
  62397. export * from "babylonjs/Actions/index";
  62398. export * from "babylonjs/Animations/index";
  62399. export * from "babylonjs/assetContainer";
  62400. export * from "babylonjs/Audio/index";
  62401. export * from "babylonjs/Behaviors/index";
  62402. export * from "babylonjs/Bones/index";
  62403. export * from "babylonjs/Cameras/index";
  62404. export * from "babylonjs/Collisions/index";
  62405. export * from "babylonjs/Culling/index";
  62406. export * from "babylonjs/Debug/index";
  62407. export * from "babylonjs/Engines/index";
  62408. export * from "babylonjs/Events/index";
  62409. export * from "babylonjs/Gamepads/index";
  62410. export * from "babylonjs/Gizmos/index";
  62411. export * from "babylonjs/Helpers/index";
  62412. export * from "babylonjs/Instrumentation/index";
  62413. export * from "babylonjs/Layers/index";
  62414. export * from "babylonjs/LensFlares/index";
  62415. export * from "babylonjs/Lights/index";
  62416. export * from "babylonjs/Loading/index";
  62417. export * from "babylonjs/Materials/index";
  62418. export * from "babylonjs/Maths/index";
  62419. export * from "babylonjs/Meshes/index";
  62420. export * from "babylonjs/Morph/index";
  62421. export * from "babylonjs/node";
  62422. export * from "babylonjs/Offline/index";
  62423. export * from "babylonjs/Particles/index";
  62424. export * from "babylonjs/Physics/index";
  62425. export * from "babylonjs/PostProcesses/index";
  62426. export * from "babylonjs/Probes/index";
  62427. export * from "babylonjs/Rendering/index";
  62428. export * from "babylonjs/scene";
  62429. export * from "babylonjs/sceneComponent";
  62430. export * from "babylonjs/Sprites/index";
  62431. export * from "babylonjs/States/index";
  62432. export * from "babylonjs/Misc/index";
  62433. export * from "babylonjs/types";
  62434. }
  62435. declare module "babylonjs/Animations/pathCursor" {
  62436. import { Path2, Vector3 } from "babylonjs/Maths/math";
  62437. /**
  62438. * A cursor which tracks a point on a path
  62439. */
  62440. export class PathCursor {
  62441. private path;
  62442. /**
  62443. * Stores path cursor callbacks for when an onchange event is triggered
  62444. */
  62445. private _onchange;
  62446. /**
  62447. * The value of the path cursor
  62448. */
  62449. value: number;
  62450. /**
  62451. * The animation array of the path cursor
  62452. */
  62453. animations: Animation[];
  62454. /**
  62455. * Initializes the path cursor
  62456. * @param path The path to track
  62457. */
  62458. constructor(path: Path2);
  62459. /**
  62460. * Gets the cursor point on the path
  62461. * @returns A point on the path cursor at the cursor location
  62462. */
  62463. getPoint(): Vector3;
  62464. /**
  62465. * Moves the cursor ahead by the step amount
  62466. * @param step The amount to move the cursor forward
  62467. * @returns This path cursor
  62468. */
  62469. moveAhead(step?: number): PathCursor;
  62470. /**
  62471. * Moves the cursor behind by the step amount
  62472. * @param step The amount to move the cursor back
  62473. * @returns This path cursor
  62474. */
  62475. moveBack(step?: number): PathCursor;
  62476. /**
  62477. * Moves the cursor by the step amount
  62478. * If the step amount is greater than one, an exception is thrown
  62479. * @param step The amount to move the cursor
  62480. * @returns This path cursor
  62481. */
  62482. move(step: number): PathCursor;
  62483. /**
  62484. * Ensures that the value is limited between zero and one
  62485. * @returns This path cursor
  62486. */
  62487. private ensureLimits;
  62488. /**
  62489. * Runs onchange callbacks on change (used by the animation engine)
  62490. * @returns This path cursor
  62491. */
  62492. private raiseOnChange;
  62493. /**
  62494. * Executes a function on change
  62495. * @param f A path cursor onchange callback
  62496. * @returns This path cursor
  62497. */
  62498. onchange(f: (cursor: PathCursor) => void): PathCursor;
  62499. }
  62500. }
  62501. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  62502. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  62503. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  62504. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  62505. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  62506. }
  62507. declare module "babylonjs/Engines/Processors/Expressions/index" {
  62508. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  62509. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  62510. }
  62511. declare module "babylonjs/Engines/Processors/index" {
  62512. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  62513. export * from "babylonjs/Engines/Processors/Expressions/index";
  62514. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  62515. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  62516. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  62517. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  62518. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  62519. export * from "babylonjs/Engines/Processors/shaderProcessor";
  62520. }
  62521. declare module "babylonjs/Legacy/legacy" {
  62522. import * as Babylon from "babylonjs/index";
  62523. export * from "babylonjs/index";
  62524. }
  62525. declare module "babylonjs/Shaders/blur.fragment" {
  62526. /** @hidden */
  62527. export var blurPixelShader: {
  62528. name: string;
  62529. shader: string;
  62530. };
  62531. }
  62532. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  62533. /** @hidden */
  62534. export var pointCloudVertexDeclaration: {
  62535. name: string;
  62536. shader: string;
  62537. };
  62538. }
  62539. declare module "babylonjs" {
  62540. export * from "babylonjs/Legacy/legacy";
  62541. }
  62542. declare module BABYLON {
  62543. /** Alias type for value that can be null */
  62544. export type Nullable<T> = T | null;
  62545. /**
  62546. * Alias type for number that are floats
  62547. * @ignorenaming
  62548. */
  62549. export type float = number;
  62550. /**
  62551. * Alias type for number that are doubles.
  62552. * @ignorenaming
  62553. */
  62554. export type double = number;
  62555. /**
  62556. * Alias type for number that are integer
  62557. * @ignorenaming
  62558. */
  62559. export type int = number;
  62560. /** Alias type for number array or Float32Array */
  62561. export type FloatArray = number[] | Float32Array;
  62562. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  62563. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  62564. /**
  62565. * Alias for types that can be used by a Buffer or VertexBuffer.
  62566. */
  62567. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  62568. /**
  62569. * Alias type for primitive types
  62570. * @ignorenaming
  62571. */
  62572. type Primitive = undefined | null | boolean | string | number | Function;
  62573. /**
  62574. * Type modifier to make all the properties of an object Readonly
  62575. */
  62576. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  62577. /**
  62578. * Type modifier to make all the properties of an object Readonly recursively
  62579. */
  62580. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  62581. /** @hidden */
  62582. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  62583. }
  62584. /** @hidden */
  62585. /** @hidden */
  62586. type DeepImmutableObject<T> = {
  62587. readonly [K in keyof T]: DeepImmutable<T[K]>;
  62588. };
  62589. }
  62590. declare module BABYLON {
  62591. /**
  62592. * Class containing a set of static utilities functions for arrays.
  62593. */
  62594. export class ArrayTools {
  62595. /**
  62596. * Returns an array of the given size filled with element built from the given constructor and the paramters
  62597. * @param size the number of element to construct and put in the array
  62598. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  62599. * @returns a new array filled with new objects
  62600. */
  62601. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  62602. }
  62603. }
  62604. declare module BABYLON {
  62605. /**
  62606. * Scalar computation library
  62607. */
  62608. export class Scalar {
  62609. /**
  62610. * Two pi constants convenient for computation.
  62611. */
  62612. static TwoPi: number;
  62613. /**
  62614. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  62615. * @param a number
  62616. * @param b number
  62617. * @param epsilon (default = 1.401298E-45)
  62618. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  62619. */
  62620. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  62621. /**
  62622. * Returns a string : the upper case translation of the number i to hexadecimal.
  62623. * @param i number
  62624. * @returns the upper case translation of the number i to hexadecimal.
  62625. */
  62626. static ToHex(i: number): string;
  62627. /**
  62628. * Returns -1 if value is negative and +1 is value is positive.
  62629. * @param value the value
  62630. * @returns the value itself if it's equal to zero.
  62631. */
  62632. static Sign(value: number): number;
  62633. /**
  62634. * Returns the value itself if it's between min and max.
  62635. * Returns min if the value is lower than min.
  62636. * Returns max if the value is greater than max.
  62637. * @param value the value to clmap
  62638. * @param min the min value to clamp to (default: 0)
  62639. * @param max the max value to clamp to (default: 1)
  62640. * @returns the clamped value
  62641. */
  62642. static Clamp(value: number, min?: number, max?: number): number;
  62643. /**
  62644. * the log2 of value.
  62645. * @param value the value to compute log2 of
  62646. * @returns the log2 of value.
  62647. */
  62648. static Log2(value: number): number;
  62649. /**
  62650. * Loops the value, so that it is never larger than length and never smaller than 0.
  62651. *
  62652. * This is similar to the modulo operator but it works with floating point numbers.
  62653. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  62654. * With t = 5 and length = 2.5, the result would be 0.0.
  62655. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  62656. * @param value the value
  62657. * @param length the length
  62658. * @returns the looped value
  62659. */
  62660. static Repeat(value: number, length: number): number;
  62661. /**
  62662. * Normalize the value between 0.0 and 1.0 using min and max values
  62663. * @param value value to normalize
  62664. * @param min max to normalize between
  62665. * @param max min to normalize between
  62666. * @returns the normalized value
  62667. */
  62668. static Normalize(value: number, min: number, max: number): number;
  62669. /**
  62670. * Denormalize the value from 0.0 and 1.0 using min and max values
  62671. * @param normalized value to denormalize
  62672. * @param min max to denormalize between
  62673. * @param max min to denormalize between
  62674. * @returns the denormalized value
  62675. */
  62676. static Denormalize(normalized: number, min: number, max: number): number;
  62677. /**
  62678. * Calculates the shortest difference between two given angles given in degrees.
  62679. * @param current current angle in degrees
  62680. * @param target target angle in degrees
  62681. * @returns the delta
  62682. */
  62683. static DeltaAngle(current: number, target: number): number;
  62684. /**
  62685. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  62686. * @param tx value
  62687. * @param length length
  62688. * @returns The returned value will move back and forth between 0 and length
  62689. */
  62690. static PingPong(tx: number, length: number): number;
  62691. /**
  62692. * Interpolates between min and max with smoothing at the limits.
  62693. *
  62694. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  62695. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  62696. * @param from from
  62697. * @param to to
  62698. * @param tx value
  62699. * @returns the smooth stepped value
  62700. */
  62701. static SmoothStep(from: number, to: number, tx: number): number;
  62702. /**
  62703. * Moves a value current towards target.
  62704. *
  62705. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  62706. * Negative values of maxDelta pushes the value away from target.
  62707. * @param current current value
  62708. * @param target target value
  62709. * @param maxDelta max distance to move
  62710. * @returns resulting value
  62711. */
  62712. static MoveTowards(current: number, target: number, maxDelta: number): number;
  62713. /**
  62714. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  62715. *
  62716. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  62717. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  62718. * @param current current value
  62719. * @param target target value
  62720. * @param maxDelta max distance to move
  62721. * @returns resulting angle
  62722. */
  62723. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  62724. /**
  62725. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  62726. * @param start start value
  62727. * @param end target value
  62728. * @param amount amount to lerp between
  62729. * @returns the lerped value
  62730. */
  62731. static Lerp(start: number, end: number, amount: number): number;
  62732. /**
  62733. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  62734. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  62735. * @param start start value
  62736. * @param end target value
  62737. * @param amount amount to lerp between
  62738. * @returns the lerped value
  62739. */
  62740. static LerpAngle(start: number, end: number, amount: number): number;
  62741. /**
  62742. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  62743. * @param a start value
  62744. * @param b target value
  62745. * @param value value between a and b
  62746. * @returns the inverseLerp value
  62747. */
  62748. static InverseLerp(a: number, b: number, value: number): number;
  62749. /**
  62750. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  62751. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  62752. * @param value1 spline value
  62753. * @param tangent1 spline value
  62754. * @param value2 spline value
  62755. * @param tangent2 spline value
  62756. * @param amount input value
  62757. * @returns hermite result
  62758. */
  62759. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  62760. /**
  62761. * Returns a random float number between and min and max values
  62762. * @param min min value of random
  62763. * @param max max value of random
  62764. * @returns random value
  62765. */
  62766. static RandomRange(min: number, max: number): number;
  62767. /**
  62768. * This function returns percentage of a number in a given range.
  62769. *
  62770. * RangeToPercent(40,20,60) will return 0.5 (50%)
  62771. * RangeToPercent(34,0,100) will return 0.34 (34%)
  62772. * @param number to convert to percentage
  62773. * @param min min range
  62774. * @param max max range
  62775. * @returns the percentage
  62776. */
  62777. static RangeToPercent(number: number, min: number, max: number): number;
  62778. /**
  62779. * This function returns number that corresponds to the percentage in a given range.
  62780. *
  62781. * PercentToRange(0.34,0,100) will return 34.
  62782. * @param percent to convert to number
  62783. * @param min min range
  62784. * @param max max range
  62785. * @returns the number
  62786. */
  62787. static PercentToRange(percent: number, min: number, max: number): number;
  62788. /**
  62789. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  62790. * @param angle The angle to normalize in radian.
  62791. * @return The converted angle.
  62792. */
  62793. static NormalizeRadians(angle: number): number;
  62794. }
  62795. }
  62796. declare module BABYLON {
  62797. /**
  62798. * Constant used to convert a value to gamma space
  62799. * @ignorenaming
  62800. */
  62801. export const ToGammaSpace: number;
  62802. /**
  62803. * Constant used to convert a value to linear space
  62804. * @ignorenaming
  62805. */
  62806. export const ToLinearSpace = 2.2;
  62807. /**
  62808. * Constant used to define the minimal number value in Babylon.js
  62809. * @ignorenaming
  62810. */
  62811. let Epsilon: number;
  62812. /**
  62813. * Class used to hold a RBG color
  62814. */
  62815. export class Color3 {
  62816. /**
  62817. * Defines the red component (between 0 and 1, default is 0)
  62818. */
  62819. r: number;
  62820. /**
  62821. * Defines the green component (between 0 and 1, default is 0)
  62822. */
  62823. g: number;
  62824. /**
  62825. * Defines the blue component (between 0 and 1, default is 0)
  62826. */
  62827. b: number;
  62828. /**
  62829. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  62830. * @param r defines the red component (between 0 and 1, default is 0)
  62831. * @param g defines the green component (between 0 and 1, default is 0)
  62832. * @param b defines the blue component (between 0 and 1, default is 0)
  62833. */
  62834. constructor(
  62835. /**
  62836. * Defines the red component (between 0 and 1, default is 0)
  62837. */
  62838. r?: number,
  62839. /**
  62840. * Defines the green component (between 0 and 1, default is 0)
  62841. */
  62842. g?: number,
  62843. /**
  62844. * Defines the blue component (between 0 and 1, default is 0)
  62845. */
  62846. b?: number);
  62847. /**
  62848. * Creates a string with the Color3 current values
  62849. * @returns the string representation of the Color3 object
  62850. */
  62851. toString(): string;
  62852. /**
  62853. * Returns the string "Color3"
  62854. * @returns "Color3"
  62855. */
  62856. getClassName(): string;
  62857. /**
  62858. * Compute the Color3 hash code
  62859. * @returns an unique number that can be used to hash Color3 objects
  62860. */
  62861. getHashCode(): number;
  62862. /**
  62863. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  62864. * @param array defines the array where to store the r,g,b components
  62865. * @param index defines an optional index in the target array to define where to start storing values
  62866. * @returns the current Color3 object
  62867. */
  62868. toArray(array: FloatArray, index?: number): Color3;
  62869. /**
  62870. * Returns a new Color4 object from the current Color3 and the given alpha
  62871. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  62872. * @returns a new Color4 object
  62873. */
  62874. toColor4(alpha?: number): Color4;
  62875. /**
  62876. * Returns a new array populated with 3 numeric elements : red, green and blue values
  62877. * @returns the new array
  62878. */
  62879. asArray(): number[];
  62880. /**
  62881. * Returns the luminance value
  62882. * @returns a float value
  62883. */
  62884. toLuminance(): number;
  62885. /**
  62886. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  62887. * @param otherColor defines the second operand
  62888. * @returns the new Color3 object
  62889. */
  62890. multiply(otherColor: DeepImmutable<Color3>): Color3;
  62891. /**
  62892. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  62893. * @param otherColor defines the second operand
  62894. * @param result defines the Color3 object where to store the result
  62895. * @returns the current Color3
  62896. */
  62897. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  62898. /**
  62899. * Determines equality between Color3 objects
  62900. * @param otherColor defines the second operand
  62901. * @returns true if the rgb values are equal to the given ones
  62902. */
  62903. equals(otherColor: DeepImmutable<Color3>): boolean;
  62904. /**
  62905. * Determines equality between the current Color3 object and a set of r,b,g values
  62906. * @param r defines the red component to check
  62907. * @param g defines the green component to check
  62908. * @param b defines the blue component to check
  62909. * @returns true if the rgb values are equal to the given ones
  62910. */
  62911. equalsFloats(r: number, g: number, b: number): boolean;
  62912. /**
  62913. * Multiplies in place each rgb value by scale
  62914. * @param scale defines the scaling factor
  62915. * @returns the updated Color3
  62916. */
  62917. scale(scale: number): Color3;
  62918. /**
  62919. * Multiplies the rgb values by scale and stores the result into "result"
  62920. * @param scale defines the scaling factor
  62921. * @param result defines the Color3 object where to store the result
  62922. * @returns the unmodified current Color3
  62923. */
  62924. scaleToRef(scale: number, result: Color3): Color3;
  62925. /**
  62926. * Scale the current Color3 values by a factor and add the result to a given Color3
  62927. * @param scale defines the scale factor
  62928. * @param result defines color to store the result into
  62929. * @returns the unmodified current Color3
  62930. */
  62931. scaleAndAddToRef(scale: number, result: Color3): Color3;
  62932. /**
  62933. * Clamps the rgb values by the min and max values and stores the result into "result"
  62934. * @param min defines minimum clamping value (default is 0)
  62935. * @param max defines maximum clamping value (default is 1)
  62936. * @param result defines color to store the result into
  62937. * @returns the original Color3
  62938. */
  62939. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  62940. /**
  62941. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  62942. * @param otherColor defines the second operand
  62943. * @returns the new Color3
  62944. */
  62945. add(otherColor: DeepImmutable<Color3>): Color3;
  62946. /**
  62947. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  62948. * @param otherColor defines the second operand
  62949. * @param result defines Color3 object to store the result into
  62950. * @returns the unmodified current Color3
  62951. */
  62952. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  62953. /**
  62954. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  62955. * @param otherColor defines the second operand
  62956. * @returns the new Color3
  62957. */
  62958. subtract(otherColor: DeepImmutable<Color3>): Color3;
  62959. /**
  62960. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  62961. * @param otherColor defines the second operand
  62962. * @param result defines Color3 object to store the result into
  62963. * @returns the unmodified current Color3
  62964. */
  62965. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  62966. /**
  62967. * Copy the current object
  62968. * @returns a new Color3 copied the current one
  62969. */
  62970. clone(): Color3;
  62971. /**
  62972. * Copies the rgb values from the source in the current Color3
  62973. * @param source defines the source Color3 object
  62974. * @returns the updated Color3 object
  62975. */
  62976. copyFrom(source: DeepImmutable<Color3>): Color3;
  62977. /**
  62978. * Updates the Color3 rgb values from the given floats
  62979. * @param r defines the red component to read from
  62980. * @param g defines the green component to read from
  62981. * @param b defines the blue component to read from
  62982. * @returns the current Color3 object
  62983. */
  62984. copyFromFloats(r: number, g: number, b: number): Color3;
  62985. /**
  62986. * Updates the Color3 rgb values from the given floats
  62987. * @param r defines the red component to read from
  62988. * @param g defines the green component to read from
  62989. * @param b defines the blue component to read from
  62990. * @returns the current Color3 object
  62991. */
  62992. set(r: number, g: number, b: number): Color3;
  62993. /**
  62994. * Compute the Color3 hexadecimal code as a string
  62995. * @returns a string containing the hexadecimal representation of the Color3 object
  62996. */
  62997. toHexString(): string;
  62998. /**
  62999. * Computes a new Color3 converted from the current one to linear space
  63000. * @returns a new Color3 object
  63001. */
  63002. toLinearSpace(): Color3;
  63003. /**
  63004. * Converts current color in rgb space to HSV values
  63005. * @returns a new color3 representing the HSV values
  63006. */
  63007. toHSV(): Color3;
  63008. /**
  63009. * Converts current color in rgb space to HSV values
  63010. * @param result defines the Color3 where to store the HSV values
  63011. */
  63012. toHSVToRef(result: Color3): void;
  63013. /**
  63014. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  63015. * @param convertedColor defines the Color3 object where to store the linear space version
  63016. * @returns the unmodified Color3
  63017. */
  63018. toLinearSpaceToRef(convertedColor: Color3): Color3;
  63019. /**
  63020. * Computes a new Color3 converted from the current one to gamma space
  63021. * @returns a new Color3 object
  63022. */
  63023. toGammaSpace(): Color3;
  63024. /**
  63025. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  63026. * @param convertedColor defines the Color3 object where to store the gamma space version
  63027. * @returns the unmodified Color3
  63028. */
  63029. toGammaSpaceToRef(convertedColor: Color3): Color3;
  63030. private static _BlackReadOnly;
  63031. /**
  63032. * Convert Hue, saturation and value to a Color3 (RGB)
  63033. * @param hue defines the hue
  63034. * @param saturation defines the saturation
  63035. * @param value defines the value
  63036. * @param result defines the Color3 where to store the RGB values
  63037. */
  63038. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  63039. /**
  63040. * Creates a new Color3 from the string containing valid hexadecimal values
  63041. * @param hex defines a string containing valid hexadecimal values
  63042. * @returns a new Color3 object
  63043. */
  63044. static FromHexString(hex: string): Color3;
  63045. /**
  63046. * Creates a new Color3 from the starting index of the given array
  63047. * @param array defines the source array
  63048. * @param offset defines an offset in the source array
  63049. * @returns a new Color3 object
  63050. */
  63051. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  63052. /**
  63053. * Creates a new Color3 from integer values (< 256)
  63054. * @param r defines the red component to read from (value between 0 and 255)
  63055. * @param g defines the green component to read from (value between 0 and 255)
  63056. * @param b defines the blue component to read from (value between 0 and 255)
  63057. * @returns a new Color3 object
  63058. */
  63059. static FromInts(r: number, g: number, b: number): Color3;
  63060. /**
  63061. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  63062. * @param start defines the start Color3 value
  63063. * @param end defines the end Color3 value
  63064. * @param amount defines the gradient value between start and end
  63065. * @returns a new Color3 object
  63066. */
  63067. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  63068. /**
  63069. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  63070. * @param left defines the start value
  63071. * @param right defines the end value
  63072. * @param amount defines the gradient factor
  63073. * @param result defines the Color3 object where to store the result
  63074. */
  63075. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  63076. /**
  63077. * Returns a Color3 value containing a red color
  63078. * @returns a new Color3 object
  63079. */
  63080. static Red(): Color3;
  63081. /**
  63082. * Returns a Color3 value containing a green color
  63083. * @returns a new Color3 object
  63084. */
  63085. static Green(): Color3;
  63086. /**
  63087. * Returns a Color3 value containing a blue color
  63088. * @returns a new Color3 object
  63089. */
  63090. static Blue(): Color3;
  63091. /**
  63092. * Returns a Color3 value containing a black color
  63093. * @returns a new Color3 object
  63094. */
  63095. static Black(): Color3;
  63096. /**
  63097. * Gets a Color3 value containing a black color that must not be updated
  63098. */
  63099. static readonly BlackReadOnly: DeepImmutable<Color3>;
  63100. /**
  63101. * Returns a Color3 value containing a white color
  63102. * @returns a new Color3 object
  63103. */
  63104. static White(): Color3;
  63105. /**
  63106. * Returns a Color3 value containing a purple color
  63107. * @returns a new Color3 object
  63108. */
  63109. static Purple(): Color3;
  63110. /**
  63111. * Returns a Color3 value containing a magenta color
  63112. * @returns a new Color3 object
  63113. */
  63114. static Magenta(): Color3;
  63115. /**
  63116. * Returns a Color3 value containing a yellow color
  63117. * @returns a new Color3 object
  63118. */
  63119. static Yellow(): Color3;
  63120. /**
  63121. * Returns a Color3 value containing a gray color
  63122. * @returns a new Color3 object
  63123. */
  63124. static Gray(): Color3;
  63125. /**
  63126. * Returns a Color3 value containing a teal color
  63127. * @returns a new Color3 object
  63128. */
  63129. static Teal(): Color3;
  63130. /**
  63131. * Returns a Color3 value containing a random color
  63132. * @returns a new Color3 object
  63133. */
  63134. static Random(): Color3;
  63135. }
  63136. /**
  63137. * Class used to hold a RBGA color
  63138. */
  63139. export class Color4 {
  63140. /**
  63141. * Defines the red component (between 0 and 1, default is 0)
  63142. */
  63143. r: number;
  63144. /**
  63145. * Defines the green component (between 0 and 1, default is 0)
  63146. */
  63147. g: number;
  63148. /**
  63149. * Defines the blue component (between 0 and 1, default is 0)
  63150. */
  63151. b: number;
  63152. /**
  63153. * Defines the alpha component (between 0 and 1, default is 1)
  63154. */
  63155. a: number;
  63156. /**
  63157. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  63158. * @param r defines the red component (between 0 and 1, default is 0)
  63159. * @param g defines the green component (between 0 and 1, default is 0)
  63160. * @param b defines the blue component (between 0 and 1, default is 0)
  63161. * @param a defines the alpha component (between 0 and 1, default is 1)
  63162. */
  63163. constructor(
  63164. /**
  63165. * Defines the red component (between 0 and 1, default is 0)
  63166. */
  63167. r?: number,
  63168. /**
  63169. * Defines the green component (between 0 and 1, default is 0)
  63170. */
  63171. g?: number,
  63172. /**
  63173. * Defines the blue component (between 0 and 1, default is 0)
  63174. */
  63175. b?: number,
  63176. /**
  63177. * Defines the alpha component (between 0 and 1, default is 1)
  63178. */
  63179. a?: number);
  63180. /**
  63181. * Adds in place the given Color4 values to the current Color4 object
  63182. * @param right defines the second operand
  63183. * @returns the current updated Color4 object
  63184. */
  63185. addInPlace(right: DeepImmutable<Color4>): Color4;
  63186. /**
  63187. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  63188. * @returns the new array
  63189. */
  63190. asArray(): number[];
  63191. /**
  63192. * Stores from the starting index in the given array the Color4 successive values
  63193. * @param array defines the array where to store the r,g,b components
  63194. * @param index defines an optional index in the target array to define where to start storing values
  63195. * @returns the current Color4 object
  63196. */
  63197. toArray(array: number[], index?: number): Color4;
  63198. /**
  63199. * Determines equality between Color4 objects
  63200. * @param otherColor defines the second operand
  63201. * @returns true if the rgba values are equal to the given ones
  63202. */
  63203. equals(otherColor: DeepImmutable<Color4>): boolean;
  63204. /**
  63205. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  63206. * @param right defines the second operand
  63207. * @returns a new Color4 object
  63208. */
  63209. add(right: DeepImmutable<Color4>): Color4;
  63210. /**
  63211. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  63212. * @param right defines the second operand
  63213. * @returns a new Color4 object
  63214. */
  63215. subtract(right: DeepImmutable<Color4>): Color4;
  63216. /**
  63217. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  63218. * @param right defines the second operand
  63219. * @param result defines the Color4 object where to store the result
  63220. * @returns the current Color4 object
  63221. */
  63222. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  63223. /**
  63224. * Creates a new Color4 with the current Color4 values multiplied by scale
  63225. * @param scale defines the scaling factor to apply
  63226. * @returns a new Color4 object
  63227. */
  63228. scale(scale: number): Color4;
  63229. /**
  63230. * Multiplies the current Color4 values by scale and stores the result in "result"
  63231. * @param scale defines the scaling factor to apply
  63232. * @param result defines the Color4 object where to store the result
  63233. * @returns the current unmodified Color4
  63234. */
  63235. scaleToRef(scale: number, result: Color4): Color4;
  63236. /**
  63237. * Scale the current Color4 values by a factor and add the result to a given Color4
  63238. * @param scale defines the scale factor
  63239. * @param result defines the Color4 object where to store the result
  63240. * @returns the unmodified current Color4
  63241. */
  63242. scaleAndAddToRef(scale: number, result: Color4): Color4;
  63243. /**
  63244. * Clamps the rgb values by the min and max values and stores the result into "result"
  63245. * @param min defines minimum clamping value (default is 0)
  63246. * @param max defines maximum clamping value (default is 1)
  63247. * @param result defines color to store the result into.
  63248. * @returns the cuurent Color4
  63249. */
  63250. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  63251. /**
  63252. * Multipy an Color4 value by another and return a new Color4 object
  63253. * @param color defines the Color4 value to multiply by
  63254. * @returns a new Color4 object
  63255. */
  63256. multiply(color: Color4): Color4;
  63257. /**
  63258. * Multipy a Color4 value by another and push the result in a reference value
  63259. * @param color defines the Color4 value to multiply by
  63260. * @param result defines the Color4 to fill the result in
  63261. * @returns the result Color4
  63262. */
  63263. multiplyToRef(color: Color4, result: Color4): Color4;
  63264. /**
  63265. * Creates a string with the Color4 current values
  63266. * @returns the string representation of the Color4 object
  63267. */
  63268. toString(): string;
  63269. /**
  63270. * Returns the string "Color4"
  63271. * @returns "Color4"
  63272. */
  63273. getClassName(): string;
  63274. /**
  63275. * Compute the Color4 hash code
  63276. * @returns an unique number that can be used to hash Color4 objects
  63277. */
  63278. getHashCode(): number;
  63279. /**
  63280. * Creates a new Color4 copied from the current one
  63281. * @returns a new Color4 object
  63282. */
  63283. clone(): Color4;
  63284. /**
  63285. * Copies the given Color4 values into the current one
  63286. * @param source defines the source Color4 object
  63287. * @returns the current updated Color4 object
  63288. */
  63289. copyFrom(source: Color4): Color4;
  63290. /**
  63291. * Copies the given float values into the current one
  63292. * @param r defines the red component to read from
  63293. * @param g defines the green component to read from
  63294. * @param b defines the blue component to read from
  63295. * @param a defines the alpha component to read from
  63296. * @returns the current updated Color4 object
  63297. */
  63298. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  63299. /**
  63300. * Copies the given float values into the current one
  63301. * @param r defines the red component to read from
  63302. * @param g defines the green component to read from
  63303. * @param b defines the blue component to read from
  63304. * @param a defines the alpha component to read from
  63305. * @returns the current updated Color4 object
  63306. */
  63307. set(r: number, g: number, b: number, a: number): Color4;
  63308. /**
  63309. * Compute the Color4 hexadecimal code as a string
  63310. * @returns a string containing the hexadecimal representation of the Color4 object
  63311. */
  63312. toHexString(): string;
  63313. /**
  63314. * Computes a new Color4 converted from the current one to linear space
  63315. * @returns a new Color4 object
  63316. */
  63317. toLinearSpace(): Color4;
  63318. /**
  63319. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  63320. * @param convertedColor defines the Color4 object where to store the linear space version
  63321. * @returns the unmodified Color4
  63322. */
  63323. toLinearSpaceToRef(convertedColor: Color4): Color4;
  63324. /**
  63325. * Computes a new Color4 converted from the current one to gamma space
  63326. * @returns a new Color4 object
  63327. */
  63328. toGammaSpace(): Color4;
  63329. /**
  63330. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  63331. * @param convertedColor defines the Color4 object where to store the gamma space version
  63332. * @returns the unmodified Color4
  63333. */
  63334. toGammaSpaceToRef(convertedColor: Color4): Color4;
  63335. /**
  63336. * Creates a new Color4 from the string containing valid hexadecimal values
  63337. * @param hex defines a string containing valid hexadecimal values
  63338. * @returns a new Color4 object
  63339. */
  63340. static FromHexString(hex: string): Color4;
  63341. /**
  63342. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  63343. * @param left defines the start value
  63344. * @param right defines the end value
  63345. * @param amount defines the gradient factor
  63346. * @returns a new Color4 object
  63347. */
  63348. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  63349. /**
  63350. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  63351. * @param left defines the start value
  63352. * @param right defines the end value
  63353. * @param amount defines the gradient factor
  63354. * @param result defines the Color4 object where to store data
  63355. */
  63356. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  63357. /**
  63358. * Creates a new Color4 from a Color3 and an alpha value
  63359. * @param color3 defines the source Color3 to read from
  63360. * @param alpha defines the alpha component (1.0 by default)
  63361. * @returns a new Color4 object
  63362. */
  63363. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  63364. /**
  63365. * Creates a new Color4 from the starting index element of the given array
  63366. * @param array defines the source array to read from
  63367. * @param offset defines the offset in the source array
  63368. * @returns a new Color4 object
  63369. */
  63370. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  63371. /**
  63372. * Creates a new Color3 from integer values (< 256)
  63373. * @param r defines the red component to read from (value between 0 and 255)
  63374. * @param g defines the green component to read from (value between 0 and 255)
  63375. * @param b defines the blue component to read from (value between 0 and 255)
  63376. * @param a defines the alpha component to read from (value between 0 and 255)
  63377. * @returns a new Color3 object
  63378. */
  63379. static FromInts(r: number, g: number, b: number, a: number): Color4;
  63380. /**
  63381. * Check the content of a given array and convert it to an array containing RGBA data
  63382. * If the original array was already containing count * 4 values then it is returned directly
  63383. * @param colors defines the array to check
  63384. * @param count defines the number of RGBA data to expect
  63385. * @returns an array containing count * 4 values (RGBA)
  63386. */
  63387. static CheckColors4(colors: number[], count: number): number[];
  63388. }
  63389. /**
  63390. * Class representing a vector containing 2 coordinates
  63391. */
  63392. export class Vector2 {
  63393. /** defines the first coordinate */
  63394. x: number;
  63395. /** defines the second coordinate */
  63396. y: number;
  63397. /**
  63398. * Creates a new Vector2 from the given x and y coordinates
  63399. * @param x defines the first coordinate
  63400. * @param y defines the second coordinate
  63401. */
  63402. constructor(
  63403. /** defines the first coordinate */
  63404. x?: number,
  63405. /** defines the second coordinate */
  63406. y?: number);
  63407. /**
  63408. * Gets a string with the Vector2 coordinates
  63409. * @returns a string with the Vector2 coordinates
  63410. */
  63411. toString(): string;
  63412. /**
  63413. * Gets class name
  63414. * @returns the string "Vector2"
  63415. */
  63416. getClassName(): string;
  63417. /**
  63418. * Gets current vector hash code
  63419. * @returns the Vector2 hash code as a number
  63420. */
  63421. getHashCode(): number;
  63422. /**
  63423. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  63424. * @param array defines the source array
  63425. * @param index defines the offset in source array
  63426. * @returns the current Vector2
  63427. */
  63428. toArray(array: FloatArray, index?: number): Vector2;
  63429. /**
  63430. * Copy the current vector to an array
  63431. * @returns a new array with 2 elements: the Vector2 coordinates.
  63432. */
  63433. asArray(): number[];
  63434. /**
  63435. * Sets the Vector2 coordinates with the given Vector2 coordinates
  63436. * @param source defines the source Vector2
  63437. * @returns the current updated Vector2
  63438. */
  63439. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  63440. /**
  63441. * Sets the Vector2 coordinates with the given floats
  63442. * @param x defines the first coordinate
  63443. * @param y defines the second coordinate
  63444. * @returns the current updated Vector2
  63445. */
  63446. copyFromFloats(x: number, y: number): Vector2;
  63447. /**
  63448. * Sets the Vector2 coordinates with the given floats
  63449. * @param x defines the first coordinate
  63450. * @param y defines the second coordinate
  63451. * @returns the current updated Vector2
  63452. */
  63453. set(x: number, y: number): Vector2;
  63454. /**
  63455. * Add another vector with the current one
  63456. * @param otherVector defines the other vector
  63457. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  63458. */
  63459. add(otherVector: DeepImmutable<Vector2>): Vector2;
  63460. /**
  63461. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  63462. * @param otherVector defines the other vector
  63463. * @param result defines the target vector
  63464. * @returns the unmodified current Vector2
  63465. */
  63466. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63467. /**
  63468. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  63469. * @param otherVector defines the other vector
  63470. * @returns the current updated Vector2
  63471. */
  63472. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63473. /**
  63474. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  63475. * @param otherVector defines the other vector
  63476. * @returns a new Vector2
  63477. */
  63478. addVector3(otherVector: Vector3): Vector2;
  63479. /**
  63480. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  63481. * @param otherVector defines the other vector
  63482. * @returns a new Vector2
  63483. */
  63484. subtract(otherVector: Vector2): Vector2;
  63485. /**
  63486. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  63487. * @param otherVector defines the other vector
  63488. * @param result defines the target vector
  63489. * @returns the unmodified current Vector2
  63490. */
  63491. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63492. /**
  63493. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  63494. * @param otherVector defines the other vector
  63495. * @returns the current updated Vector2
  63496. */
  63497. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63498. /**
  63499. * Multiplies in place the current Vector2 coordinates by the given ones
  63500. * @param otherVector defines the other vector
  63501. * @returns the current updated Vector2
  63502. */
  63503. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63504. /**
  63505. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  63506. * @param otherVector defines the other vector
  63507. * @returns a new Vector2
  63508. */
  63509. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  63510. /**
  63511. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  63512. * @param otherVector defines the other vector
  63513. * @param result defines the target vector
  63514. * @returns the unmodified current Vector2
  63515. */
  63516. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63517. /**
  63518. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  63519. * @param x defines the first coordinate
  63520. * @param y defines the second coordinate
  63521. * @returns a new Vector2
  63522. */
  63523. multiplyByFloats(x: number, y: number): Vector2;
  63524. /**
  63525. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  63526. * @param otherVector defines the other vector
  63527. * @returns a new Vector2
  63528. */
  63529. divide(otherVector: Vector2): Vector2;
  63530. /**
  63531. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  63532. * @param otherVector defines the other vector
  63533. * @param result defines the target vector
  63534. * @returns the unmodified current Vector2
  63535. */
  63536. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63537. /**
  63538. * Divides the current Vector2 coordinates by the given ones
  63539. * @param otherVector defines the other vector
  63540. * @returns the current updated Vector2
  63541. */
  63542. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63543. /**
  63544. * Gets a new Vector2 with current Vector2 negated coordinates
  63545. * @returns a new Vector2
  63546. */
  63547. negate(): Vector2;
  63548. /**
  63549. * Multiply the Vector2 coordinates by scale
  63550. * @param scale defines the scaling factor
  63551. * @returns the current updated Vector2
  63552. */
  63553. scaleInPlace(scale: number): Vector2;
  63554. /**
  63555. * Returns a new Vector2 scaled by "scale" from the current Vector2
  63556. * @param scale defines the scaling factor
  63557. * @returns a new Vector2
  63558. */
  63559. scale(scale: number): Vector2;
  63560. /**
  63561. * Scale the current Vector2 values by a factor to a given Vector2
  63562. * @param scale defines the scale factor
  63563. * @param result defines the Vector2 object where to store the result
  63564. * @returns the unmodified current Vector2
  63565. */
  63566. scaleToRef(scale: number, result: Vector2): Vector2;
  63567. /**
  63568. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  63569. * @param scale defines the scale factor
  63570. * @param result defines the Vector2 object where to store the result
  63571. * @returns the unmodified current Vector2
  63572. */
  63573. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  63574. /**
  63575. * Gets a boolean if two vectors are equals
  63576. * @param otherVector defines the other vector
  63577. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  63578. */
  63579. equals(otherVector: DeepImmutable<Vector2>): boolean;
  63580. /**
  63581. * Gets a boolean if two vectors are equals (using an epsilon value)
  63582. * @param otherVector defines the other vector
  63583. * @param epsilon defines the minimal distance to consider equality
  63584. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  63585. */
  63586. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  63587. /**
  63588. * Gets a new Vector2 from current Vector2 floored values
  63589. * @returns a new Vector2
  63590. */
  63591. floor(): Vector2;
  63592. /**
  63593. * Gets a new Vector2 from current Vector2 floored values
  63594. * @returns a new Vector2
  63595. */
  63596. fract(): Vector2;
  63597. /**
  63598. * Gets the length of the vector
  63599. * @returns the vector length (float)
  63600. */
  63601. length(): number;
  63602. /**
  63603. * Gets the vector squared length
  63604. * @returns the vector squared length (float)
  63605. */
  63606. lengthSquared(): number;
  63607. /**
  63608. * Normalize the vector
  63609. * @returns the current updated Vector2
  63610. */
  63611. normalize(): Vector2;
  63612. /**
  63613. * Gets a new Vector2 copied from the Vector2
  63614. * @returns a new Vector2
  63615. */
  63616. clone(): Vector2;
  63617. /**
  63618. * Gets a new Vector2(0, 0)
  63619. * @returns a new Vector2
  63620. */
  63621. static Zero(): Vector2;
  63622. /**
  63623. * Gets a new Vector2(1, 1)
  63624. * @returns a new Vector2
  63625. */
  63626. static One(): Vector2;
  63627. /**
  63628. * Gets a new Vector2 set from the given index element of the given array
  63629. * @param array defines the data source
  63630. * @param offset defines the offset in the data source
  63631. * @returns a new Vector2
  63632. */
  63633. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  63634. /**
  63635. * Sets "result" from the given index element of the given array
  63636. * @param array defines the data source
  63637. * @param offset defines the offset in the data source
  63638. * @param result defines the target vector
  63639. */
  63640. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  63641. /**
  63642. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  63643. * @param value1 defines 1st point of control
  63644. * @param value2 defines 2nd point of control
  63645. * @param value3 defines 3rd point of control
  63646. * @param value4 defines 4th point of control
  63647. * @param amount defines the interpolation factor
  63648. * @returns a new Vector2
  63649. */
  63650. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  63651. /**
  63652. * 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".
  63653. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  63654. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  63655. * @param value defines the value to clamp
  63656. * @param min defines the lower limit
  63657. * @param max defines the upper limit
  63658. * @returns a new Vector2
  63659. */
  63660. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  63661. /**
  63662. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  63663. * @param value1 defines the 1st control point
  63664. * @param tangent1 defines the outgoing tangent
  63665. * @param value2 defines the 2nd control point
  63666. * @param tangent2 defines the incoming tangent
  63667. * @param amount defines the interpolation factor
  63668. * @returns a new Vector2
  63669. */
  63670. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  63671. /**
  63672. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  63673. * @param start defines the start vector
  63674. * @param end defines the end vector
  63675. * @param amount defines the interpolation factor
  63676. * @returns a new Vector2
  63677. */
  63678. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  63679. /**
  63680. * Gets the dot product of the vector "left" and the vector "right"
  63681. * @param left defines first vector
  63682. * @param right defines second vector
  63683. * @returns the dot product (float)
  63684. */
  63685. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  63686. /**
  63687. * Returns a new Vector2 equal to the normalized given vector
  63688. * @param vector defines the vector to normalize
  63689. * @returns a new Vector2
  63690. */
  63691. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  63692. /**
  63693. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  63694. * @param left defines 1st vector
  63695. * @param right defines 2nd vector
  63696. * @returns a new Vector2
  63697. */
  63698. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  63699. /**
  63700. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  63701. * @param left defines 1st vector
  63702. * @param right defines 2nd vector
  63703. * @returns a new Vector2
  63704. */
  63705. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  63706. /**
  63707. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  63708. * @param vector defines the vector to transform
  63709. * @param transformation defines the matrix to apply
  63710. * @returns a new Vector2
  63711. */
  63712. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  63713. /**
  63714. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  63715. * @param vector defines the vector to transform
  63716. * @param transformation defines the matrix to apply
  63717. * @param result defines the target vector
  63718. */
  63719. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  63720. /**
  63721. * Determines if a given vector is included in a triangle
  63722. * @param p defines the vector to test
  63723. * @param p0 defines 1st triangle point
  63724. * @param p1 defines 2nd triangle point
  63725. * @param p2 defines 3rd triangle point
  63726. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  63727. */
  63728. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  63729. /**
  63730. * Gets the distance between the vectors "value1" and "value2"
  63731. * @param value1 defines first vector
  63732. * @param value2 defines second vector
  63733. * @returns the distance between vectors
  63734. */
  63735. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  63736. /**
  63737. * Returns the squared distance between the vectors "value1" and "value2"
  63738. * @param value1 defines first vector
  63739. * @param value2 defines second vector
  63740. * @returns the squared distance between vectors
  63741. */
  63742. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  63743. /**
  63744. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  63745. * @param value1 defines first vector
  63746. * @param value2 defines second vector
  63747. * @returns a new Vector2
  63748. */
  63749. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  63750. /**
  63751. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  63752. * @param p defines the middle point
  63753. * @param segA defines one point of the segment
  63754. * @param segB defines the other point of the segment
  63755. * @returns the shortest distance
  63756. */
  63757. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  63758. }
  63759. /**
  63760. * Classed used to store (x,y,z) vector representation
  63761. * A Vector3 is the main object used in 3D geometry
  63762. * It can represent etiher the coordinates of a point the space, either a direction
  63763. * Reminder: js uses a left handed forward facing system
  63764. */
  63765. export class Vector3 {
  63766. /**
  63767. * Defines the first coordinates (on X axis)
  63768. */
  63769. x: number;
  63770. /**
  63771. * Defines the second coordinates (on Y axis)
  63772. */
  63773. y: number;
  63774. /**
  63775. * Defines the third coordinates (on Z axis)
  63776. */
  63777. z: number;
  63778. private static _UpReadOnly;
  63779. private static _ZeroReadOnly;
  63780. /**
  63781. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  63782. * @param x defines the first coordinates (on X axis)
  63783. * @param y defines the second coordinates (on Y axis)
  63784. * @param z defines the third coordinates (on Z axis)
  63785. */
  63786. constructor(
  63787. /**
  63788. * Defines the first coordinates (on X axis)
  63789. */
  63790. x?: number,
  63791. /**
  63792. * Defines the second coordinates (on Y axis)
  63793. */
  63794. y?: number,
  63795. /**
  63796. * Defines the third coordinates (on Z axis)
  63797. */
  63798. z?: number);
  63799. /**
  63800. * Creates a string representation of the Vector3
  63801. * @returns a string with the Vector3 coordinates.
  63802. */
  63803. toString(): string;
  63804. /**
  63805. * Gets the class name
  63806. * @returns the string "Vector3"
  63807. */
  63808. getClassName(): string;
  63809. /**
  63810. * Creates the Vector3 hash code
  63811. * @returns a number which tends to be unique between Vector3 instances
  63812. */
  63813. getHashCode(): number;
  63814. /**
  63815. * Creates an array containing three elements : the coordinates of the Vector3
  63816. * @returns a new array of numbers
  63817. */
  63818. asArray(): number[];
  63819. /**
  63820. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  63821. * @param array defines the destination array
  63822. * @param index defines the offset in the destination array
  63823. * @returns the current Vector3
  63824. */
  63825. toArray(array: FloatArray, index?: number): Vector3;
  63826. /**
  63827. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  63828. * @returns a new Quaternion object, computed from the Vector3 coordinates
  63829. */
  63830. toQuaternion(): Quaternion;
  63831. /**
  63832. * Adds the given vector to the current Vector3
  63833. * @param otherVector defines the second operand
  63834. * @returns the current updated Vector3
  63835. */
  63836. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  63837. /**
  63838. * Adds the given coordinates to the current Vector3
  63839. * @param x defines the x coordinate of the operand
  63840. * @param y defines the y coordinate of the operand
  63841. * @param z defines the z coordinate of the operand
  63842. * @returns the current updated Vector3
  63843. */
  63844. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  63845. /**
  63846. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  63847. * @param otherVector defines the second operand
  63848. * @returns the resulting Vector3
  63849. */
  63850. add(otherVector: DeepImmutable<Vector3>): Vector3;
  63851. /**
  63852. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  63853. * @param otherVector defines the second operand
  63854. * @param result defines the Vector3 object where to store the result
  63855. * @returns the current Vector3
  63856. */
  63857. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  63858. /**
  63859. * Subtract the given vector from the current Vector3
  63860. * @param otherVector defines the second operand
  63861. * @returns the current updated Vector3
  63862. */
  63863. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  63864. /**
  63865. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  63866. * @param otherVector defines the second operand
  63867. * @returns the resulting Vector3
  63868. */
  63869. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  63870. /**
  63871. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  63872. * @param otherVector defines the second operand
  63873. * @param result defines the Vector3 object where to store the result
  63874. * @returns the current Vector3
  63875. */
  63876. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  63877. /**
  63878. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  63879. * @param x defines the x coordinate of the operand
  63880. * @param y defines the y coordinate of the operand
  63881. * @param z defines the z coordinate of the operand
  63882. * @returns the resulting Vector3
  63883. */
  63884. subtractFromFloats(x: number, y: number, z: number): Vector3;
  63885. /**
  63886. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  63887. * @param x defines the x coordinate of the operand
  63888. * @param y defines the y coordinate of the operand
  63889. * @param z defines the z coordinate of the operand
  63890. * @param result defines the Vector3 object where to store the result
  63891. * @returns the current Vector3
  63892. */
  63893. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  63894. /**
  63895. * Gets a new Vector3 set with the current Vector3 negated coordinates
  63896. * @returns a new Vector3
  63897. */
  63898. negate(): Vector3;
  63899. /**
  63900. * Multiplies the Vector3 coordinates by the float "scale"
  63901. * @param scale defines the multiplier factor
  63902. * @returns the current updated Vector3
  63903. */
  63904. scaleInPlace(scale: number): Vector3;
  63905. /**
  63906. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  63907. * @param scale defines the multiplier factor
  63908. * @returns a new Vector3
  63909. */
  63910. scale(scale: number): Vector3;
  63911. /**
  63912. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  63913. * @param scale defines the multiplier factor
  63914. * @param result defines the Vector3 object where to store the result
  63915. * @returns the current Vector3
  63916. */
  63917. scaleToRef(scale: number, result: Vector3): Vector3;
  63918. /**
  63919. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  63920. * @param scale defines the scale factor
  63921. * @param result defines the Vector3 object where to store the result
  63922. * @returns the unmodified current Vector3
  63923. */
  63924. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  63925. /**
  63926. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  63927. * @param otherVector defines the second operand
  63928. * @returns true if both vectors are equals
  63929. */
  63930. equals(otherVector: DeepImmutable<Vector3>): boolean;
  63931. /**
  63932. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  63933. * @param otherVector defines the second operand
  63934. * @param epsilon defines the minimal distance to define values as equals
  63935. * @returns true if both vectors are distant less than epsilon
  63936. */
  63937. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  63938. /**
  63939. * Returns true if the current Vector3 coordinates equals the given floats
  63940. * @param x defines the x coordinate of the operand
  63941. * @param y defines the y coordinate of the operand
  63942. * @param z defines the z coordinate of the operand
  63943. * @returns true if both vectors are equals
  63944. */
  63945. equalsToFloats(x: number, y: number, z: number): boolean;
  63946. /**
  63947. * Multiplies the current Vector3 coordinates by the given ones
  63948. * @param otherVector defines the second operand
  63949. * @returns the current updated Vector3
  63950. */
  63951. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  63952. /**
  63953. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  63954. * @param otherVector defines the second operand
  63955. * @returns the new Vector3
  63956. */
  63957. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  63958. /**
  63959. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  63960. * @param otherVector defines the second operand
  63961. * @param result defines the Vector3 object where to store the result
  63962. * @returns the current Vector3
  63963. */
  63964. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  63965. /**
  63966. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  63967. * @param x defines the x coordinate of the operand
  63968. * @param y defines the y coordinate of the operand
  63969. * @param z defines the z coordinate of the operand
  63970. * @returns the new Vector3
  63971. */
  63972. multiplyByFloats(x: number, y: number, z: number): Vector3;
  63973. /**
  63974. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  63975. * @param otherVector defines the second operand
  63976. * @returns the new Vector3
  63977. */
  63978. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  63979. /**
  63980. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  63981. * @param otherVector defines the second operand
  63982. * @param result defines the Vector3 object where to store the result
  63983. * @returns the current Vector3
  63984. */
  63985. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  63986. /**
  63987. * Divides the current Vector3 coordinates by the given ones.
  63988. * @param otherVector defines the second operand
  63989. * @returns the current updated Vector3
  63990. */
  63991. divideInPlace(otherVector: Vector3): Vector3;
  63992. /**
  63993. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  63994. * @param other defines the second operand
  63995. * @returns the current updated Vector3
  63996. */
  63997. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  63998. /**
  63999. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  64000. * @param other defines the second operand
  64001. * @returns the current updated Vector3
  64002. */
  64003. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  64004. /**
  64005. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  64006. * @param x defines the x coordinate of the operand
  64007. * @param y defines the y coordinate of the operand
  64008. * @param z defines the z coordinate of the operand
  64009. * @returns the current updated Vector3
  64010. */
  64011. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  64012. /**
  64013. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  64014. * @param x defines the x coordinate of the operand
  64015. * @param y defines the y coordinate of the operand
  64016. * @param z defines the z coordinate of the operand
  64017. * @returns the current updated Vector3
  64018. */
  64019. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  64020. /**
  64021. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  64022. * Check if is non uniform within a certain amount of decimal places to account for this
  64023. * @param epsilon the amount the values can differ
  64024. * @returns if the the vector is non uniform to a certain number of decimal places
  64025. */
  64026. isNonUniformWithinEpsilon(epsilon: number): boolean;
  64027. /**
  64028. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  64029. */
  64030. readonly isNonUniform: boolean;
  64031. /**
  64032. * Gets a new Vector3 from current Vector3 floored values
  64033. * @returns a new Vector3
  64034. */
  64035. floor(): Vector3;
  64036. /**
  64037. * Gets a new Vector3 from current Vector3 floored values
  64038. * @returns a new Vector3
  64039. */
  64040. fract(): Vector3;
  64041. /**
  64042. * Gets the length of the Vector3
  64043. * @returns the length of the Vector3
  64044. */
  64045. length(): number;
  64046. /**
  64047. * Gets the squared length of the Vector3
  64048. * @returns squared length of the Vector3
  64049. */
  64050. lengthSquared(): number;
  64051. /**
  64052. * Normalize the current Vector3.
  64053. * Please note that this is an in place operation.
  64054. * @returns the current updated Vector3
  64055. */
  64056. normalize(): Vector3;
  64057. /**
  64058. * Reorders the x y z properties of the vector in place
  64059. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  64060. * @returns the current updated vector
  64061. */
  64062. reorderInPlace(order: string): this;
  64063. /**
  64064. * Rotates the vector around 0,0,0 by a quaternion
  64065. * @param quaternion the rotation quaternion
  64066. * @param result vector to store the result
  64067. * @returns the resulting vector
  64068. */
  64069. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  64070. /**
  64071. * Rotates a vector around a given point
  64072. * @param quaternion the rotation quaternion
  64073. * @param point the point to rotate around
  64074. * @param result vector to store the result
  64075. * @returns the resulting vector
  64076. */
  64077. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  64078. /**
  64079. * Normalize the current Vector3 with the given input length.
  64080. * Please note that this is an in place operation.
  64081. * @param len the length of the vector
  64082. * @returns the current updated Vector3
  64083. */
  64084. normalizeFromLength(len: number): Vector3;
  64085. /**
  64086. * Normalize the current Vector3 to a new vector
  64087. * @returns the new Vector3
  64088. */
  64089. normalizeToNew(): Vector3;
  64090. /**
  64091. * Normalize the current Vector3 to the reference
  64092. * @param reference define the Vector3 to update
  64093. * @returns the updated Vector3
  64094. */
  64095. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  64096. /**
  64097. * Creates a new Vector3 copied from the current Vector3
  64098. * @returns the new Vector3
  64099. */
  64100. clone(): Vector3;
  64101. /**
  64102. * Copies the given vector coordinates to the current Vector3 ones
  64103. * @param source defines the source Vector3
  64104. * @returns the current updated Vector3
  64105. */
  64106. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  64107. /**
  64108. * Copies the given floats to the current Vector3 coordinates
  64109. * @param x defines the x coordinate of the operand
  64110. * @param y defines the y coordinate of the operand
  64111. * @param z defines the z coordinate of the operand
  64112. * @returns the current updated Vector3
  64113. */
  64114. copyFromFloats(x: number, y: number, z: number): Vector3;
  64115. /**
  64116. * Copies the given floats to the current Vector3 coordinates
  64117. * @param x defines the x coordinate of the operand
  64118. * @param y defines the y coordinate of the operand
  64119. * @param z defines the z coordinate of the operand
  64120. * @returns the current updated Vector3
  64121. */
  64122. set(x: number, y: number, z: number): Vector3;
  64123. /**
  64124. * Copies the given float to the current Vector3 coordinates
  64125. * @param v defines the x, y and z coordinates of the operand
  64126. * @returns the current updated Vector3
  64127. */
  64128. setAll(v: number): Vector3;
  64129. /**
  64130. * Get the clip factor between two vectors
  64131. * @param vector0 defines the first operand
  64132. * @param vector1 defines the second operand
  64133. * @param axis defines the axis to use
  64134. * @param size defines the size along the axis
  64135. * @returns the clip factor
  64136. */
  64137. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  64138. /**
  64139. * Get angle between two vectors
  64140. * @param vector0 angle between vector0 and vector1
  64141. * @param vector1 angle between vector0 and vector1
  64142. * @param normal direction of the normal
  64143. * @return the angle between vector0 and vector1
  64144. */
  64145. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  64146. /**
  64147. * Returns a new Vector3 set from the index "offset" of the given array
  64148. * @param array defines the source array
  64149. * @param offset defines the offset in the source array
  64150. * @returns the new Vector3
  64151. */
  64152. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  64153. /**
  64154. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  64155. * This function is deprecated. Use FromArray instead
  64156. * @param array defines the source array
  64157. * @param offset defines the offset in the source array
  64158. * @returns the new Vector3
  64159. */
  64160. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  64161. /**
  64162. * Sets the given vector "result" with the element values from the index "offset" of the given array
  64163. * @param array defines the source array
  64164. * @param offset defines the offset in the source array
  64165. * @param result defines the Vector3 where to store the result
  64166. */
  64167. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  64168. /**
  64169. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  64170. * This function is deprecated. Use FromArrayToRef instead.
  64171. * @param array defines the source array
  64172. * @param offset defines the offset in the source array
  64173. * @param result defines the Vector3 where to store the result
  64174. */
  64175. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  64176. /**
  64177. * Sets the given vector "result" with the given floats.
  64178. * @param x defines the x coordinate of the source
  64179. * @param y defines the y coordinate of the source
  64180. * @param z defines the z coordinate of the source
  64181. * @param result defines the Vector3 where to store the result
  64182. */
  64183. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  64184. /**
  64185. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  64186. * @returns a new empty Vector3
  64187. */
  64188. static Zero(): Vector3;
  64189. /**
  64190. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  64191. * @returns a new unit Vector3
  64192. */
  64193. static One(): Vector3;
  64194. /**
  64195. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  64196. * @returns a new up Vector3
  64197. */
  64198. static Up(): Vector3;
  64199. /**
  64200. * Gets a up Vector3 that must not be updated
  64201. */
  64202. static readonly UpReadOnly: DeepImmutable<Vector3>;
  64203. /**
  64204. * Gets a zero Vector3 that must not be updated
  64205. */
  64206. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  64207. /**
  64208. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  64209. * @returns a new down Vector3
  64210. */
  64211. static Down(): Vector3;
  64212. /**
  64213. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  64214. * @returns a new forward Vector3
  64215. */
  64216. static Forward(): Vector3;
  64217. /**
  64218. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  64219. * @returns a new forward Vector3
  64220. */
  64221. static Backward(): Vector3;
  64222. /**
  64223. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  64224. * @returns a new right Vector3
  64225. */
  64226. static Right(): Vector3;
  64227. /**
  64228. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  64229. * @returns a new left Vector3
  64230. */
  64231. static Left(): Vector3;
  64232. /**
  64233. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  64234. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  64235. * @param vector defines the Vector3 to transform
  64236. * @param transformation defines the transformation matrix
  64237. * @returns the transformed Vector3
  64238. */
  64239. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  64240. /**
  64241. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  64242. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  64243. * @param vector defines the Vector3 to transform
  64244. * @param transformation defines the transformation matrix
  64245. * @param result defines the Vector3 where to store the result
  64246. */
  64247. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64248. /**
  64249. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  64250. * This method computes tranformed coordinates only, not transformed direction vectors
  64251. * @param x define the x coordinate of the source vector
  64252. * @param y define the y coordinate of the source vector
  64253. * @param z define the z coordinate of the source vector
  64254. * @param transformation defines the transformation matrix
  64255. * @param result defines the Vector3 where to store the result
  64256. */
  64257. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64258. /**
  64259. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  64260. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64261. * @param vector defines the Vector3 to transform
  64262. * @param transformation defines the transformation matrix
  64263. * @returns the new Vector3
  64264. */
  64265. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  64266. /**
  64267. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  64268. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64269. * @param vector defines the Vector3 to transform
  64270. * @param transformation defines the transformation matrix
  64271. * @param result defines the Vector3 where to store the result
  64272. */
  64273. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64274. /**
  64275. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  64276. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  64277. * @param x define the x coordinate of the source vector
  64278. * @param y define the y coordinate of the source vector
  64279. * @param z define the z coordinate of the source vector
  64280. * @param transformation defines the transformation matrix
  64281. * @param result defines the Vector3 where to store the result
  64282. */
  64283. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  64284. /**
  64285. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  64286. * @param value1 defines the first control point
  64287. * @param value2 defines the second control point
  64288. * @param value3 defines the third control point
  64289. * @param value4 defines the fourth control point
  64290. * @param amount defines the amount on the spline to use
  64291. * @returns the new Vector3
  64292. */
  64293. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  64294. /**
  64295. * 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"
  64296. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  64297. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  64298. * @param value defines the current value
  64299. * @param min defines the lower range value
  64300. * @param max defines the upper range value
  64301. * @returns the new Vector3
  64302. */
  64303. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  64304. /**
  64305. * 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"
  64306. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  64307. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  64308. * @param value defines the current value
  64309. * @param min defines the lower range value
  64310. * @param max defines the upper range value
  64311. * @param result defines the Vector3 where to store the result
  64312. */
  64313. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  64314. /**
  64315. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  64316. * @param value1 defines the first control point
  64317. * @param tangent1 defines the first tangent vector
  64318. * @param value2 defines the second control point
  64319. * @param tangent2 defines the second tangent vector
  64320. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  64321. * @returns the new Vector3
  64322. */
  64323. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  64324. /**
  64325. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  64326. * @param start defines the start value
  64327. * @param end defines the end value
  64328. * @param amount max defines amount between both (between 0 and 1)
  64329. * @returns the new Vector3
  64330. */
  64331. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  64332. /**
  64333. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  64334. * @param start defines the start value
  64335. * @param end defines the end value
  64336. * @param amount max defines amount between both (between 0 and 1)
  64337. * @param result defines the Vector3 where to store the result
  64338. */
  64339. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  64340. /**
  64341. * Returns the dot product (float) between the vectors "left" and "right"
  64342. * @param left defines the left operand
  64343. * @param right defines the right operand
  64344. * @returns the dot product
  64345. */
  64346. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  64347. /**
  64348. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  64349. * The cross product is then orthogonal to both "left" and "right"
  64350. * @param left defines the left operand
  64351. * @param right defines the right operand
  64352. * @returns the cross product
  64353. */
  64354. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64355. /**
  64356. * Sets the given vector "result" with the cross product of "left" and "right"
  64357. * The cross product is then orthogonal to both "left" and "right"
  64358. * @param left defines the left operand
  64359. * @param right defines the right operand
  64360. * @param result defines the Vector3 where to store the result
  64361. */
  64362. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  64363. /**
  64364. * Returns a new Vector3 as the normalization of the given vector
  64365. * @param vector defines the Vector3 to normalize
  64366. * @returns the new Vector3
  64367. */
  64368. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  64369. /**
  64370. * Sets the given vector "result" with the normalization of the given first vector
  64371. * @param vector defines the Vector3 to normalize
  64372. * @param result defines the Vector3 where to store the result
  64373. */
  64374. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  64375. /**
  64376. * Project a Vector3 onto screen space
  64377. * @param vector defines the Vector3 to project
  64378. * @param world defines the world matrix to use
  64379. * @param transform defines the transform (view x projection) matrix to use
  64380. * @param viewport defines the screen viewport to use
  64381. * @returns the new Vector3
  64382. */
  64383. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  64384. /** @hidden */
  64385. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  64386. /**
  64387. * Unproject from screen space to object space
  64388. * @param source defines the screen space Vector3 to use
  64389. * @param viewportWidth defines the current width of the viewport
  64390. * @param viewportHeight defines the current height of the viewport
  64391. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64392. * @param transform defines the transform (view x projection) matrix to use
  64393. * @returns the new Vector3
  64394. */
  64395. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  64396. /**
  64397. * Unproject from screen space to object space
  64398. * @param source defines the screen space Vector3 to use
  64399. * @param viewportWidth defines the current width of the viewport
  64400. * @param viewportHeight defines the current height of the viewport
  64401. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64402. * @param view defines the view matrix to use
  64403. * @param projection defines the projection matrix to use
  64404. * @returns the new Vector3
  64405. */
  64406. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  64407. /**
  64408. * Unproject from screen space to object space
  64409. * @param source defines the screen space Vector3 to use
  64410. * @param viewportWidth defines the current width of the viewport
  64411. * @param viewportHeight defines the current height of the viewport
  64412. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64413. * @param view defines the view matrix to use
  64414. * @param projection defines the projection matrix to use
  64415. * @param result defines the Vector3 where to store the result
  64416. */
  64417. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  64418. /**
  64419. * Unproject from screen space to object space
  64420. * @param sourceX defines the screen space x coordinate to use
  64421. * @param sourceY defines the screen space y coordinate to use
  64422. * @param sourceZ defines the screen space z coordinate to use
  64423. * @param viewportWidth defines the current width of the viewport
  64424. * @param viewportHeight defines the current height of the viewport
  64425. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  64426. * @param view defines the view matrix to use
  64427. * @param projection defines the projection matrix to use
  64428. * @param result defines the Vector3 where to store the result
  64429. */
  64430. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  64431. /**
  64432. * Gets the minimal coordinate values between two Vector3
  64433. * @param left defines the first operand
  64434. * @param right defines the second operand
  64435. * @returns the new Vector3
  64436. */
  64437. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64438. /**
  64439. * Gets the maximal coordinate values between two Vector3
  64440. * @param left defines the first operand
  64441. * @param right defines the second operand
  64442. * @returns the new Vector3
  64443. */
  64444. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64445. /**
  64446. * Returns the distance between the vectors "value1" and "value2"
  64447. * @param value1 defines the first operand
  64448. * @param value2 defines the second operand
  64449. * @returns the distance
  64450. */
  64451. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  64452. /**
  64453. * Returns the squared distance between the vectors "value1" and "value2"
  64454. * @param value1 defines the first operand
  64455. * @param value2 defines the second operand
  64456. * @returns the squared distance
  64457. */
  64458. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  64459. /**
  64460. * Returns a new Vector3 located at the center between "value1" and "value2"
  64461. * @param value1 defines the first operand
  64462. * @param value2 defines the second operand
  64463. * @returns the new Vector3
  64464. */
  64465. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  64466. /**
  64467. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  64468. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  64469. * to something in order to rotate it from its local system to the given target system
  64470. * Note: axis1, axis2 and axis3 are normalized during this operation
  64471. * @param axis1 defines the first axis
  64472. * @param axis2 defines the second axis
  64473. * @param axis3 defines the third axis
  64474. * @returns a new Vector3
  64475. */
  64476. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  64477. /**
  64478. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  64479. * @param axis1 defines the first axis
  64480. * @param axis2 defines the second axis
  64481. * @param axis3 defines the third axis
  64482. * @param ref defines the Vector3 where to store the result
  64483. */
  64484. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  64485. }
  64486. /**
  64487. * Vector4 class created for EulerAngle class conversion to Quaternion
  64488. */
  64489. export class Vector4 {
  64490. /** x value of the vector */
  64491. x: number;
  64492. /** y value of the vector */
  64493. y: number;
  64494. /** z value of the vector */
  64495. z: number;
  64496. /** w value of the vector */
  64497. w: number;
  64498. /**
  64499. * Creates a Vector4 object from the given floats.
  64500. * @param x x value of the vector
  64501. * @param y y value of the vector
  64502. * @param z z value of the vector
  64503. * @param w w value of the vector
  64504. */
  64505. constructor(
  64506. /** x value of the vector */
  64507. x: number,
  64508. /** y value of the vector */
  64509. y: number,
  64510. /** z value of the vector */
  64511. z: number,
  64512. /** w value of the vector */
  64513. w: number);
  64514. /**
  64515. * Returns the string with the Vector4 coordinates.
  64516. * @returns a string containing all the vector values
  64517. */
  64518. toString(): string;
  64519. /**
  64520. * Returns the string "Vector4".
  64521. * @returns "Vector4"
  64522. */
  64523. getClassName(): string;
  64524. /**
  64525. * Returns the Vector4 hash code.
  64526. * @returns a unique hash code
  64527. */
  64528. getHashCode(): number;
  64529. /**
  64530. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  64531. * @returns the resulting array
  64532. */
  64533. asArray(): number[];
  64534. /**
  64535. * Populates the given array from the given index with the Vector4 coordinates.
  64536. * @param array array to populate
  64537. * @param index index of the array to start at (default: 0)
  64538. * @returns the Vector4.
  64539. */
  64540. toArray(array: FloatArray, index?: number): Vector4;
  64541. /**
  64542. * Adds the given vector to the current Vector4.
  64543. * @param otherVector the vector to add
  64544. * @returns the updated Vector4.
  64545. */
  64546. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64547. /**
  64548. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  64549. * @param otherVector the vector to add
  64550. * @returns the resulting vector
  64551. */
  64552. add(otherVector: DeepImmutable<Vector4>): Vector4;
  64553. /**
  64554. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  64555. * @param otherVector the vector to add
  64556. * @param result the vector to store the result
  64557. * @returns the current Vector4.
  64558. */
  64559. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64560. /**
  64561. * Subtract in place the given vector from the current Vector4.
  64562. * @param otherVector the vector to subtract
  64563. * @returns the updated Vector4.
  64564. */
  64565. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64566. /**
  64567. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  64568. * @param otherVector the vector to add
  64569. * @returns the new vector with the result
  64570. */
  64571. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  64572. /**
  64573. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  64574. * @param otherVector the vector to subtract
  64575. * @param result the vector to store the result
  64576. * @returns the current Vector4.
  64577. */
  64578. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64579. /**
  64580. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64581. */
  64582. /**
  64583. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64584. * @param x value to subtract
  64585. * @param y value to subtract
  64586. * @param z value to subtract
  64587. * @param w value to subtract
  64588. * @returns new vector containing the result
  64589. */
  64590. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  64591. /**
  64592. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64593. * @param x value to subtract
  64594. * @param y value to subtract
  64595. * @param z value to subtract
  64596. * @param w value to subtract
  64597. * @param result the vector to store the result in
  64598. * @returns the current Vector4.
  64599. */
  64600. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  64601. /**
  64602. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  64603. * @returns a new vector with the negated values
  64604. */
  64605. negate(): Vector4;
  64606. /**
  64607. * Multiplies the current Vector4 coordinates by scale (float).
  64608. * @param scale the number to scale with
  64609. * @returns the updated Vector4.
  64610. */
  64611. scaleInPlace(scale: number): Vector4;
  64612. /**
  64613. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  64614. * @param scale the number to scale with
  64615. * @returns a new vector with the result
  64616. */
  64617. scale(scale: number): Vector4;
  64618. /**
  64619. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  64620. * @param scale the number to scale with
  64621. * @param result a vector to store the result in
  64622. * @returns the current Vector4.
  64623. */
  64624. scaleToRef(scale: number, result: Vector4): Vector4;
  64625. /**
  64626. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  64627. * @param scale defines the scale factor
  64628. * @param result defines the Vector4 object where to store the result
  64629. * @returns the unmodified current Vector4
  64630. */
  64631. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  64632. /**
  64633. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  64634. * @param otherVector the vector to compare against
  64635. * @returns true if they are equal
  64636. */
  64637. equals(otherVector: DeepImmutable<Vector4>): boolean;
  64638. /**
  64639. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  64640. * @param otherVector vector to compare against
  64641. * @param epsilon (Default: very small number)
  64642. * @returns true if they are equal
  64643. */
  64644. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  64645. /**
  64646. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  64647. * @param x x value to compare against
  64648. * @param y y value to compare against
  64649. * @param z z value to compare against
  64650. * @param w w value to compare against
  64651. * @returns true if equal
  64652. */
  64653. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  64654. /**
  64655. * Multiplies in place the current Vector4 by the given one.
  64656. * @param otherVector vector to multiple with
  64657. * @returns the updated Vector4.
  64658. */
  64659. multiplyInPlace(otherVector: Vector4): Vector4;
  64660. /**
  64661. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  64662. * @param otherVector vector to multiple with
  64663. * @returns resulting new vector
  64664. */
  64665. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  64666. /**
  64667. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  64668. * @param otherVector vector to multiple with
  64669. * @param result vector to store the result
  64670. * @returns the current Vector4.
  64671. */
  64672. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64673. /**
  64674. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  64675. * @param x x value multiply with
  64676. * @param y y value multiply with
  64677. * @param z z value multiply with
  64678. * @param w w value multiply with
  64679. * @returns resulting new vector
  64680. */
  64681. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  64682. /**
  64683. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  64684. * @param otherVector vector to devide with
  64685. * @returns resulting new vector
  64686. */
  64687. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  64688. /**
  64689. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  64690. * @param otherVector vector to devide with
  64691. * @param result vector to store the result
  64692. * @returns the current Vector4.
  64693. */
  64694. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64695. /**
  64696. * Divides the current Vector3 coordinates by the given ones.
  64697. * @param otherVector vector to devide with
  64698. * @returns the updated Vector3.
  64699. */
  64700. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64701. /**
  64702. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  64703. * @param other defines the second operand
  64704. * @returns the current updated Vector4
  64705. */
  64706. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  64707. /**
  64708. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  64709. * @param other defines the second operand
  64710. * @returns the current updated Vector4
  64711. */
  64712. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  64713. /**
  64714. * Gets a new Vector4 from current Vector4 floored values
  64715. * @returns a new Vector4
  64716. */
  64717. floor(): Vector4;
  64718. /**
  64719. * Gets a new Vector4 from current Vector3 floored values
  64720. * @returns a new Vector4
  64721. */
  64722. fract(): Vector4;
  64723. /**
  64724. * Returns the Vector4 length (float).
  64725. * @returns the length
  64726. */
  64727. length(): number;
  64728. /**
  64729. * Returns the Vector4 squared length (float).
  64730. * @returns the length squared
  64731. */
  64732. lengthSquared(): number;
  64733. /**
  64734. * Normalizes in place the Vector4.
  64735. * @returns the updated Vector4.
  64736. */
  64737. normalize(): Vector4;
  64738. /**
  64739. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  64740. * @returns this converted to a new vector3
  64741. */
  64742. toVector3(): Vector3;
  64743. /**
  64744. * Returns a new Vector4 copied from the current one.
  64745. * @returns the new cloned vector
  64746. */
  64747. clone(): Vector4;
  64748. /**
  64749. * Updates the current Vector4 with the given one coordinates.
  64750. * @param source the source vector to copy from
  64751. * @returns the updated Vector4.
  64752. */
  64753. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  64754. /**
  64755. * Updates the current Vector4 coordinates with the given floats.
  64756. * @param x float to copy from
  64757. * @param y float to copy from
  64758. * @param z float to copy from
  64759. * @param w float to copy from
  64760. * @returns the updated Vector4.
  64761. */
  64762. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  64763. /**
  64764. * Updates the current Vector4 coordinates with the given floats.
  64765. * @param x float to set from
  64766. * @param y float to set from
  64767. * @param z float to set from
  64768. * @param w float to set from
  64769. * @returns the updated Vector4.
  64770. */
  64771. set(x: number, y: number, z: number, w: number): Vector4;
  64772. /**
  64773. * Copies the given float to the current Vector3 coordinates
  64774. * @param v defines the x, y, z and w coordinates of the operand
  64775. * @returns the current updated Vector3
  64776. */
  64777. setAll(v: number): Vector4;
  64778. /**
  64779. * Returns a new Vector4 set from the starting index of the given array.
  64780. * @param array the array to pull values from
  64781. * @param offset the offset into the array to start at
  64782. * @returns the new vector
  64783. */
  64784. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  64785. /**
  64786. * Updates the given vector "result" from the starting index of the given array.
  64787. * @param array the array to pull values from
  64788. * @param offset the offset into the array to start at
  64789. * @param result the vector to store the result in
  64790. */
  64791. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  64792. /**
  64793. * Updates the given vector "result" from the starting index of the given Float32Array.
  64794. * @param array the array to pull values from
  64795. * @param offset the offset into the array to start at
  64796. * @param result the vector to store the result in
  64797. */
  64798. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  64799. /**
  64800. * Updates the given vector "result" coordinates from the given floats.
  64801. * @param x float to set from
  64802. * @param y float to set from
  64803. * @param z float to set from
  64804. * @param w float to set from
  64805. * @param result the vector to the floats in
  64806. */
  64807. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  64808. /**
  64809. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  64810. * @returns the new vector
  64811. */
  64812. static Zero(): Vector4;
  64813. /**
  64814. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  64815. * @returns the new vector
  64816. */
  64817. static One(): Vector4;
  64818. /**
  64819. * Returns a new normalized Vector4 from the given one.
  64820. * @param vector the vector to normalize
  64821. * @returns the vector
  64822. */
  64823. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  64824. /**
  64825. * Updates the given vector "result" from the normalization of the given one.
  64826. * @param vector the vector to normalize
  64827. * @param result the vector to store the result in
  64828. */
  64829. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  64830. /**
  64831. * Returns a vector with the minimum values from the left and right vectors
  64832. * @param left left vector to minimize
  64833. * @param right right vector to minimize
  64834. * @returns a new vector with the minimum of the left and right vector values
  64835. */
  64836. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  64837. /**
  64838. * Returns a vector with the maximum values from the left and right vectors
  64839. * @param left left vector to maximize
  64840. * @param right right vector to maximize
  64841. * @returns a new vector with the maximum of the left and right vector values
  64842. */
  64843. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  64844. /**
  64845. * Returns the distance (float) between the vectors "value1" and "value2".
  64846. * @param value1 value to calulate the distance between
  64847. * @param value2 value to calulate the distance between
  64848. * @return the distance between the two vectors
  64849. */
  64850. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  64851. /**
  64852. * Returns the squared distance (float) between the vectors "value1" and "value2".
  64853. * @param value1 value to calulate the distance between
  64854. * @param value2 value to calulate the distance between
  64855. * @return the distance between the two vectors squared
  64856. */
  64857. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  64858. /**
  64859. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  64860. * @param value1 value to calulate the center between
  64861. * @param value2 value to calulate the center between
  64862. * @return the center between the two vectors
  64863. */
  64864. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  64865. /**
  64866. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  64867. * This methods computes transformed normalized direction vectors only.
  64868. * @param vector the vector to transform
  64869. * @param transformation the transformation matrix to apply
  64870. * @returns the new vector
  64871. */
  64872. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  64873. /**
  64874. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  64875. * This methods computes transformed normalized direction vectors only.
  64876. * @param vector the vector to transform
  64877. * @param transformation the transformation matrix to apply
  64878. * @param result the vector to store the result in
  64879. */
  64880. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  64881. /**
  64882. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  64883. * This methods computes transformed normalized direction vectors only.
  64884. * @param x value to transform
  64885. * @param y value to transform
  64886. * @param z value to transform
  64887. * @param w value to transform
  64888. * @param transformation the transformation matrix to apply
  64889. * @param result the vector to store the results in
  64890. */
  64891. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  64892. /**
  64893. * Creates a new Vector4 from a Vector3
  64894. * @param source defines the source data
  64895. * @param w defines the 4th component (default is 0)
  64896. * @returns a new Vector4
  64897. */
  64898. static FromVector3(source: Vector3, w?: number): Vector4;
  64899. }
  64900. /**
  64901. * Interface for the size containing width and height
  64902. */
  64903. export interface ISize {
  64904. /**
  64905. * Width
  64906. */
  64907. width: number;
  64908. /**
  64909. * Heighht
  64910. */
  64911. height: number;
  64912. }
  64913. /**
  64914. * Size containing widht and height
  64915. */
  64916. export class Size implements ISize {
  64917. /**
  64918. * Width
  64919. */
  64920. width: number;
  64921. /**
  64922. * Height
  64923. */
  64924. height: number;
  64925. /**
  64926. * Creates a Size object from the given width and height (floats).
  64927. * @param width width of the new size
  64928. * @param height height of the new size
  64929. */
  64930. constructor(width: number, height: number);
  64931. /**
  64932. * Returns a string with the Size width and height
  64933. * @returns a string with the Size width and height
  64934. */
  64935. toString(): string;
  64936. /**
  64937. * "Size"
  64938. * @returns the string "Size"
  64939. */
  64940. getClassName(): string;
  64941. /**
  64942. * Returns the Size hash code.
  64943. * @returns a hash code for a unique width and height
  64944. */
  64945. getHashCode(): number;
  64946. /**
  64947. * Updates the current size from the given one.
  64948. * @param src the given size
  64949. */
  64950. copyFrom(src: Size): void;
  64951. /**
  64952. * Updates in place the current Size from the given floats.
  64953. * @param width width of the new size
  64954. * @param height height of the new size
  64955. * @returns the updated Size.
  64956. */
  64957. copyFromFloats(width: number, height: number): Size;
  64958. /**
  64959. * Updates in place the current Size from the given floats.
  64960. * @param width width to set
  64961. * @param height height to set
  64962. * @returns the updated Size.
  64963. */
  64964. set(width: number, height: number): Size;
  64965. /**
  64966. * Multiplies the width and height by numbers
  64967. * @param w factor to multiple the width by
  64968. * @param h factor to multiple the height by
  64969. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  64970. */
  64971. multiplyByFloats(w: number, h: number): Size;
  64972. /**
  64973. * Clones the size
  64974. * @returns a new Size copied from the given one.
  64975. */
  64976. clone(): Size;
  64977. /**
  64978. * True if the current Size and the given one width and height are strictly equal.
  64979. * @param other the other size to compare against
  64980. * @returns True if the current Size and the given one width and height are strictly equal.
  64981. */
  64982. equals(other: Size): boolean;
  64983. /**
  64984. * The surface of the Size : width * height (float).
  64985. */
  64986. readonly surface: number;
  64987. /**
  64988. * Create a new size of zero
  64989. * @returns a new Size set to (0.0, 0.0)
  64990. */
  64991. static Zero(): Size;
  64992. /**
  64993. * Sums the width and height of two sizes
  64994. * @param otherSize size to add to this size
  64995. * @returns a new Size set as the addition result of the current Size and the given one.
  64996. */
  64997. add(otherSize: Size): Size;
  64998. /**
  64999. * Subtracts the width and height of two
  65000. * @param otherSize size to subtract to this size
  65001. * @returns a new Size set as the subtraction result of the given one from the current Size.
  65002. */
  65003. subtract(otherSize: Size): Size;
  65004. /**
  65005. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  65006. * @param start starting size to lerp between
  65007. * @param end end size to lerp between
  65008. * @param amount amount to lerp between the start and end values
  65009. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  65010. */
  65011. static Lerp(start: Size, end: Size, amount: number): Size;
  65012. }
  65013. /**
  65014. * Class used to store quaternion data
  65015. * @see https://en.wikipedia.org/wiki/Quaternion
  65016. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  65017. */
  65018. export class Quaternion {
  65019. /** defines the first component (0 by default) */
  65020. x: number;
  65021. /** defines the second component (0 by default) */
  65022. y: number;
  65023. /** defines the third component (0 by default) */
  65024. z: number;
  65025. /** defines the fourth component (1.0 by default) */
  65026. w: number;
  65027. /**
  65028. * Creates a new Quaternion from the given floats
  65029. * @param x defines the first component (0 by default)
  65030. * @param y defines the second component (0 by default)
  65031. * @param z defines the third component (0 by default)
  65032. * @param w defines the fourth component (1.0 by default)
  65033. */
  65034. constructor(
  65035. /** defines the first component (0 by default) */
  65036. x?: number,
  65037. /** defines the second component (0 by default) */
  65038. y?: number,
  65039. /** defines the third component (0 by default) */
  65040. z?: number,
  65041. /** defines the fourth component (1.0 by default) */
  65042. w?: number);
  65043. /**
  65044. * Gets a string representation for the current quaternion
  65045. * @returns a string with the Quaternion coordinates
  65046. */
  65047. toString(): string;
  65048. /**
  65049. * Gets the class name of the quaternion
  65050. * @returns the string "Quaternion"
  65051. */
  65052. getClassName(): string;
  65053. /**
  65054. * Gets a hash code for this quaternion
  65055. * @returns the quaternion hash code
  65056. */
  65057. getHashCode(): number;
  65058. /**
  65059. * Copy the quaternion to an array
  65060. * @returns a new array populated with 4 elements from the quaternion coordinates
  65061. */
  65062. asArray(): number[];
  65063. /**
  65064. * Check if two quaternions are equals
  65065. * @param otherQuaternion defines the second operand
  65066. * @return true if the current quaternion and the given one coordinates are strictly equals
  65067. */
  65068. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  65069. /**
  65070. * Clone the current quaternion
  65071. * @returns a new quaternion copied from the current one
  65072. */
  65073. clone(): Quaternion;
  65074. /**
  65075. * Copy a quaternion to the current one
  65076. * @param other defines the other quaternion
  65077. * @returns the updated current quaternion
  65078. */
  65079. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  65080. /**
  65081. * Updates the current quaternion with the given float coordinates
  65082. * @param x defines the x coordinate
  65083. * @param y defines the y coordinate
  65084. * @param z defines the z coordinate
  65085. * @param w defines the w coordinate
  65086. * @returns the updated current quaternion
  65087. */
  65088. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  65089. /**
  65090. * Updates the current quaternion from the given float coordinates
  65091. * @param x defines the x coordinate
  65092. * @param y defines the y coordinate
  65093. * @param z defines the z coordinate
  65094. * @param w defines the w coordinate
  65095. * @returns the updated current quaternion
  65096. */
  65097. set(x: number, y: number, z: number, w: number): Quaternion;
  65098. /**
  65099. * Adds two quaternions
  65100. * @param other defines the second operand
  65101. * @returns a new quaternion as the addition result of the given one and the current quaternion
  65102. */
  65103. add(other: DeepImmutable<Quaternion>): Quaternion;
  65104. /**
  65105. * Add a quaternion to the current one
  65106. * @param other defines the quaternion to add
  65107. * @returns the current quaternion
  65108. */
  65109. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  65110. /**
  65111. * Subtract two quaternions
  65112. * @param other defines the second operand
  65113. * @returns a new quaternion as the subtraction result of the given one from the current one
  65114. */
  65115. subtract(other: Quaternion): Quaternion;
  65116. /**
  65117. * Multiplies the current quaternion by a scale factor
  65118. * @param value defines the scale factor
  65119. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  65120. */
  65121. scale(value: number): Quaternion;
  65122. /**
  65123. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  65124. * @param scale defines the scale factor
  65125. * @param result defines the Quaternion object where to store the result
  65126. * @returns the unmodified current quaternion
  65127. */
  65128. scaleToRef(scale: number, result: Quaternion): Quaternion;
  65129. /**
  65130. * Multiplies in place the current quaternion by a scale factor
  65131. * @param value defines the scale factor
  65132. * @returns the current modified quaternion
  65133. */
  65134. scaleInPlace(value: number): Quaternion;
  65135. /**
  65136. * Scale the current quaternion values by a factor and add the result to a given quaternion
  65137. * @param scale defines the scale factor
  65138. * @param result defines the Quaternion object where to store the result
  65139. * @returns the unmodified current quaternion
  65140. */
  65141. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  65142. /**
  65143. * Multiplies two quaternions
  65144. * @param q1 defines the second operand
  65145. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  65146. */
  65147. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  65148. /**
  65149. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  65150. * @param q1 defines the second operand
  65151. * @param result defines the target quaternion
  65152. * @returns the current quaternion
  65153. */
  65154. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  65155. /**
  65156. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  65157. * @param q1 defines the second operand
  65158. * @returns the currentupdated quaternion
  65159. */
  65160. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  65161. /**
  65162. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  65163. * @param ref defines the target quaternion
  65164. * @returns the current quaternion
  65165. */
  65166. conjugateToRef(ref: Quaternion): Quaternion;
  65167. /**
  65168. * Conjugates in place (1-q) the current quaternion
  65169. * @returns the current updated quaternion
  65170. */
  65171. conjugateInPlace(): Quaternion;
  65172. /**
  65173. * Conjugates in place (1-q) the current quaternion
  65174. * @returns a new quaternion
  65175. */
  65176. conjugate(): Quaternion;
  65177. /**
  65178. * Gets length of current quaternion
  65179. * @returns the quaternion length (float)
  65180. */
  65181. length(): number;
  65182. /**
  65183. * Normalize in place the current quaternion
  65184. * @returns the current updated quaternion
  65185. */
  65186. normalize(): Quaternion;
  65187. /**
  65188. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  65189. * @param order is a reserved parameter and is ignore for now
  65190. * @returns a new Vector3 containing the Euler angles
  65191. */
  65192. toEulerAngles(order?: string): Vector3;
  65193. /**
  65194. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  65195. * @param result defines the vector which will be filled with the Euler angles
  65196. * @param order is a reserved parameter and is ignore for now
  65197. * @returns the current unchanged quaternion
  65198. */
  65199. toEulerAnglesToRef(result: Vector3): Quaternion;
  65200. /**
  65201. * Updates the given rotation matrix with the current quaternion values
  65202. * @param result defines the target matrix
  65203. * @returns the current unchanged quaternion
  65204. */
  65205. toRotationMatrix(result: Matrix): Quaternion;
  65206. /**
  65207. * Updates the current quaternion from the given rotation matrix values
  65208. * @param matrix defines the source matrix
  65209. * @returns the current updated quaternion
  65210. */
  65211. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  65212. /**
  65213. * Creates a new quaternion from a rotation matrix
  65214. * @param matrix defines the source matrix
  65215. * @returns a new quaternion created from the given rotation matrix values
  65216. */
  65217. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  65218. /**
  65219. * Updates the given quaternion with the given rotation matrix values
  65220. * @param matrix defines the source matrix
  65221. * @param result defines the target quaternion
  65222. */
  65223. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  65224. /**
  65225. * Returns the dot product (float) between the quaternions "left" and "right"
  65226. * @param left defines the left operand
  65227. * @param right defines the right operand
  65228. * @returns the dot product
  65229. */
  65230. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  65231. /**
  65232. * Checks if the two quaternions are close to each other
  65233. * @param quat0 defines the first quaternion to check
  65234. * @param quat1 defines the second quaternion to check
  65235. * @returns true if the two quaternions are close to each other
  65236. */
  65237. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  65238. /**
  65239. * Creates an empty quaternion
  65240. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  65241. */
  65242. static Zero(): Quaternion;
  65243. /**
  65244. * Inverse a given quaternion
  65245. * @param q defines the source quaternion
  65246. * @returns a new quaternion as the inverted current quaternion
  65247. */
  65248. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  65249. /**
  65250. * Inverse a given quaternion
  65251. * @param q defines the source quaternion
  65252. * @param result the quaternion the result will be stored in
  65253. * @returns the result quaternion
  65254. */
  65255. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  65256. /**
  65257. * Creates an identity quaternion
  65258. * @returns the identity quaternion
  65259. */
  65260. static Identity(): Quaternion;
  65261. /**
  65262. * Gets a boolean indicating if the given quaternion is identity
  65263. * @param quaternion defines the quaternion to check
  65264. * @returns true if the quaternion is identity
  65265. */
  65266. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  65267. /**
  65268. * Creates a quaternion from a rotation around an axis
  65269. * @param axis defines the axis to use
  65270. * @param angle defines the angle to use
  65271. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  65272. */
  65273. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  65274. /**
  65275. * Creates a rotation around an axis and stores it into the given quaternion
  65276. * @param axis defines the axis to use
  65277. * @param angle defines the angle to use
  65278. * @param result defines the target quaternion
  65279. * @returns the target quaternion
  65280. */
  65281. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  65282. /**
  65283. * Creates a new quaternion from data stored into an array
  65284. * @param array defines the data source
  65285. * @param offset defines the offset in the source array where the data starts
  65286. * @returns a new quaternion
  65287. */
  65288. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  65289. /**
  65290. * Create a quaternion from Euler rotation angles
  65291. * @param x Pitch
  65292. * @param y Yaw
  65293. * @param z Roll
  65294. * @returns the new Quaternion
  65295. */
  65296. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  65297. /**
  65298. * Updates a quaternion from Euler rotation angles
  65299. * @param x Pitch
  65300. * @param y Yaw
  65301. * @param z Roll
  65302. * @param result the quaternion to store the result
  65303. * @returns the updated quaternion
  65304. */
  65305. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  65306. /**
  65307. * Create a quaternion from Euler rotation vector
  65308. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  65309. * @returns the new Quaternion
  65310. */
  65311. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  65312. /**
  65313. * Updates a quaternion from Euler rotation vector
  65314. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  65315. * @param result the quaternion to store the result
  65316. * @returns the updated quaternion
  65317. */
  65318. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  65319. /**
  65320. * Creates a new quaternion from the given Euler float angles (y, x, z)
  65321. * @param yaw defines the rotation around Y axis
  65322. * @param pitch defines the rotation around X axis
  65323. * @param roll defines the rotation around Z axis
  65324. * @returns the new quaternion
  65325. */
  65326. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  65327. /**
  65328. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  65329. * @param yaw defines the rotation around Y axis
  65330. * @param pitch defines the rotation around X axis
  65331. * @param roll defines the rotation around Z axis
  65332. * @param result defines the target quaternion
  65333. */
  65334. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  65335. /**
  65336. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  65337. * @param alpha defines the rotation around first axis
  65338. * @param beta defines the rotation around second axis
  65339. * @param gamma defines the rotation around third axis
  65340. * @returns the new quaternion
  65341. */
  65342. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  65343. /**
  65344. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  65345. * @param alpha defines the rotation around first axis
  65346. * @param beta defines the rotation around second axis
  65347. * @param gamma defines the rotation around third axis
  65348. * @param result defines the target quaternion
  65349. */
  65350. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  65351. /**
  65352. * 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)
  65353. * @param axis1 defines the first axis
  65354. * @param axis2 defines the second axis
  65355. * @param axis3 defines the third axis
  65356. * @returns the new quaternion
  65357. */
  65358. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  65359. /**
  65360. * 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
  65361. * @param axis1 defines the first axis
  65362. * @param axis2 defines the second axis
  65363. * @param axis3 defines the third axis
  65364. * @param ref defines the target quaternion
  65365. */
  65366. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  65367. /**
  65368. * Interpolates between two quaternions
  65369. * @param left defines first quaternion
  65370. * @param right defines second quaternion
  65371. * @param amount defines the gradient to use
  65372. * @returns the new interpolated quaternion
  65373. */
  65374. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  65375. /**
  65376. * Interpolates between two quaternions and stores it into a target quaternion
  65377. * @param left defines first quaternion
  65378. * @param right defines second quaternion
  65379. * @param amount defines the gradient to use
  65380. * @param result defines the target quaternion
  65381. */
  65382. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  65383. /**
  65384. * Interpolate between two quaternions using Hermite interpolation
  65385. * @param value1 defines first quaternion
  65386. * @param tangent1 defines the incoming tangent
  65387. * @param value2 defines second quaternion
  65388. * @param tangent2 defines the outgoing tangent
  65389. * @param amount defines the target quaternion
  65390. * @returns the new interpolated quaternion
  65391. */
  65392. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  65393. }
  65394. /**
  65395. * Class used to store matrix data (4x4)
  65396. */
  65397. export class Matrix {
  65398. private static _updateFlagSeed;
  65399. private static _identityReadOnly;
  65400. private _isIdentity;
  65401. private _isIdentityDirty;
  65402. private _isIdentity3x2;
  65403. private _isIdentity3x2Dirty;
  65404. /**
  65405. * Gets the update flag of the matrix which is an unique number for the matrix.
  65406. * It will be incremented every time the matrix data change.
  65407. * You can use it to speed the comparison between two versions of the same matrix.
  65408. */
  65409. updateFlag: number;
  65410. private readonly _m;
  65411. /**
  65412. * Gets the internal data of the matrix
  65413. */
  65414. readonly m: DeepImmutable<Float32Array>;
  65415. /** @hidden */
  65416. _markAsUpdated(): void;
  65417. /** @hidden */
  65418. private _updateIdentityStatus;
  65419. /**
  65420. * Creates an empty matrix (filled with zeros)
  65421. */
  65422. constructor();
  65423. /**
  65424. * Check if the current matrix is identity
  65425. * @returns true is the matrix is the identity matrix
  65426. */
  65427. isIdentity(): boolean;
  65428. /**
  65429. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  65430. * @returns true is the matrix is the identity matrix
  65431. */
  65432. isIdentityAs3x2(): boolean;
  65433. /**
  65434. * Gets the determinant of the matrix
  65435. * @returns the matrix determinant
  65436. */
  65437. determinant(): number;
  65438. /**
  65439. * Returns the matrix as a Float32Array
  65440. * @returns the matrix underlying array
  65441. */
  65442. toArray(): DeepImmutable<Float32Array>;
  65443. /**
  65444. * Returns the matrix as a Float32Array
  65445. * @returns the matrix underlying array.
  65446. */
  65447. asArray(): DeepImmutable<Float32Array>;
  65448. /**
  65449. * Inverts the current matrix in place
  65450. * @returns the current inverted matrix
  65451. */
  65452. invert(): Matrix;
  65453. /**
  65454. * Sets all the matrix elements to zero
  65455. * @returns the current matrix
  65456. */
  65457. reset(): Matrix;
  65458. /**
  65459. * Adds the current matrix with a second one
  65460. * @param other defines the matrix to add
  65461. * @returns a new matrix as the addition of the current matrix and the given one
  65462. */
  65463. add(other: DeepImmutable<Matrix>): Matrix;
  65464. /**
  65465. * Sets the given matrix "result" to the addition of the current matrix and the given one
  65466. * @param other defines the matrix to add
  65467. * @param result defines the target matrix
  65468. * @returns the current matrix
  65469. */
  65470. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  65471. /**
  65472. * Adds in place the given matrix to the current matrix
  65473. * @param other defines the second operand
  65474. * @returns the current updated matrix
  65475. */
  65476. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  65477. /**
  65478. * Sets the given matrix to the current inverted Matrix
  65479. * @param other defines the target matrix
  65480. * @returns the unmodified current matrix
  65481. */
  65482. invertToRef(other: Matrix): Matrix;
  65483. /**
  65484. * add a value at the specified position in the current Matrix
  65485. * @param index the index of the value within the matrix. between 0 and 15.
  65486. * @param value the value to be added
  65487. * @returns the current updated matrix
  65488. */
  65489. addAtIndex(index: number, value: number): Matrix;
  65490. /**
  65491. * mutiply the specified position in the current Matrix by a value
  65492. * @param index the index of the value within the matrix. between 0 and 15.
  65493. * @param value the value to be added
  65494. * @returns the current updated matrix
  65495. */
  65496. multiplyAtIndex(index: number, value: number): Matrix;
  65497. /**
  65498. * Inserts the translation vector (using 3 floats) in the current matrix
  65499. * @param x defines the 1st component of the translation
  65500. * @param y defines the 2nd component of the translation
  65501. * @param z defines the 3rd component of the translation
  65502. * @returns the current updated matrix
  65503. */
  65504. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  65505. /**
  65506. * Adds the translation vector (using 3 floats) in the current matrix
  65507. * @param x defines the 1st component of the translation
  65508. * @param y defines the 2nd component of the translation
  65509. * @param z defines the 3rd component of the translation
  65510. * @returns the current updated matrix
  65511. */
  65512. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  65513. /**
  65514. * Inserts the translation vector in the current matrix
  65515. * @param vector3 defines the translation to insert
  65516. * @returns the current updated matrix
  65517. */
  65518. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  65519. /**
  65520. * Gets the translation value of the current matrix
  65521. * @returns a new Vector3 as the extracted translation from the matrix
  65522. */
  65523. getTranslation(): Vector3;
  65524. /**
  65525. * Fill a Vector3 with the extracted translation from the matrix
  65526. * @param result defines the Vector3 where to store the translation
  65527. * @returns the current matrix
  65528. */
  65529. getTranslationToRef(result: Vector3): Matrix;
  65530. /**
  65531. * Remove rotation and scaling part from the matrix
  65532. * @returns the updated matrix
  65533. */
  65534. removeRotationAndScaling(): Matrix;
  65535. /**
  65536. * Multiply two matrices
  65537. * @param other defines the second operand
  65538. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  65539. */
  65540. multiply(other: DeepImmutable<Matrix>): Matrix;
  65541. /**
  65542. * Copy the current matrix from the given one
  65543. * @param other defines the source matrix
  65544. * @returns the current updated matrix
  65545. */
  65546. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  65547. /**
  65548. * Populates the given array from the starting index with the current matrix values
  65549. * @param array defines the target array
  65550. * @param offset defines the offset in the target array where to start storing values
  65551. * @returns the current matrix
  65552. */
  65553. copyToArray(array: Float32Array, offset?: number): Matrix;
  65554. /**
  65555. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  65556. * @param other defines the second operand
  65557. * @param result defines the matrix where to store the multiplication
  65558. * @returns the current matrix
  65559. */
  65560. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  65561. /**
  65562. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  65563. * @param other defines the second operand
  65564. * @param result defines the array where to store the multiplication
  65565. * @param offset defines the offset in the target array where to start storing values
  65566. * @returns the current matrix
  65567. */
  65568. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  65569. /**
  65570. * Check equality between this matrix and a second one
  65571. * @param value defines the second matrix to compare
  65572. * @returns true is the current matrix and the given one values are strictly equal
  65573. */
  65574. equals(value: DeepImmutable<Matrix>): boolean;
  65575. /**
  65576. * Clone the current matrix
  65577. * @returns a new matrix from the current matrix
  65578. */
  65579. clone(): Matrix;
  65580. /**
  65581. * Returns the name of the current matrix class
  65582. * @returns the string "Matrix"
  65583. */
  65584. getClassName(): string;
  65585. /**
  65586. * Gets the hash code of the current matrix
  65587. * @returns the hash code
  65588. */
  65589. getHashCode(): number;
  65590. /**
  65591. * Decomposes the current Matrix into a translation, rotation and scaling components
  65592. * @param scale defines the scale vector3 given as a reference to update
  65593. * @param rotation defines the rotation quaternion given as a reference to update
  65594. * @param translation defines the translation vector3 given as a reference to update
  65595. * @returns true if operation was successful
  65596. */
  65597. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  65598. /**
  65599. * Gets specific row of the matrix
  65600. * @param index defines the number of the row to get
  65601. * @returns the index-th row of the current matrix as a new Vector4
  65602. */
  65603. getRow(index: number): Nullable<Vector4>;
  65604. /**
  65605. * Sets the index-th row of the current matrix to the vector4 values
  65606. * @param index defines the number of the row to set
  65607. * @param row defines the target vector4
  65608. * @returns the updated current matrix
  65609. */
  65610. setRow(index: number, row: Vector4): Matrix;
  65611. /**
  65612. * Compute the transpose of the matrix
  65613. * @returns the new transposed matrix
  65614. */
  65615. transpose(): Matrix;
  65616. /**
  65617. * Compute the transpose of the matrix and store it in a given matrix
  65618. * @param result defines the target matrix
  65619. * @returns the current matrix
  65620. */
  65621. transposeToRef(result: Matrix): Matrix;
  65622. /**
  65623. * Sets the index-th row of the current matrix with the given 4 x float values
  65624. * @param index defines the row index
  65625. * @param x defines the x component to set
  65626. * @param y defines the y component to set
  65627. * @param z defines the z component to set
  65628. * @param w defines the w component to set
  65629. * @returns the updated current matrix
  65630. */
  65631. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  65632. /**
  65633. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  65634. * @param scale defines the scale factor
  65635. * @returns a new matrix
  65636. */
  65637. scale(scale: number): Matrix;
  65638. /**
  65639. * Scale the current matrix values by a factor to a given result matrix
  65640. * @param scale defines the scale factor
  65641. * @param result defines the matrix to store the result
  65642. * @returns the current matrix
  65643. */
  65644. scaleToRef(scale: number, result: Matrix): Matrix;
  65645. /**
  65646. * Scale the current matrix values by a factor and add the result to a given matrix
  65647. * @param scale defines the scale factor
  65648. * @param result defines the Matrix to store the result
  65649. * @returns the current matrix
  65650. */
  65651. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  65652. /**
  65653. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  65654. * @param ref matrix to store the result
  65655. */
  65656. toNormalMatrix(ref: Matrix): void;
  65657. /**
  65658. * Gets only rotation part of the current matrix
  65659. * @returns a new matrix sets to the extracted rotation matrix from the current one
  65660. */
  65661. getRotationMatrix(): Matrix;
  65662. /**
  65663. * Extracts the rotation matrix from the current one and sets it as the given "result"
  65664. * @param result defines the target matrix to store data to
  65665. * @returns the current matrix
  65666. */
  65667. getRotationMatrixToRef(result: Matrix): Matrix;
  65668. /**
  65669. * Toggles model matrix from being right handed to left handed in place and vice versa
  65670. */
  65671. toggleModelMatrixHandInPlace(): void;
  65672. /**
  65673. * Toggles projection matrix from being right handed to left handed in place and vice versa
  65674. */
  65675. toggleProjectionMatrixHandInPlace(): void;
  65676. /**
  65677. * Creates a matrix from an array
  65678. * @param array defines the source array
  65679. * @param offset defines an offset in the source array
  65680. * @returns a new Matrix set from the starting index of the given array
  65681. */
  65682. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  65683. /**
  65684. * Copy the content of an array into a given matrix
  65685. * @param array defines the source array
  65686. * @param offset defines an offset in the source array
  65687. * @param result defines the target matrix
  65688. */
  65689. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  65690. /**
  65691. * Stores an array into a matrix after having multiplied each component by a given factor
  65692. * @param array defines the source array
  65693. * @param offset defines the offset in the source array
  65694. * @param scale defines the scaling factor
  65695. * @param result defines the target matrix
  65696. */
  65697. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  65698. /**
  65699. * Gets an identity matrix that must not be updated
  65700. */
  65701. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  65702. /**
  65703. * Stores a list of values (16) inside a given matrix
  65704. * @param initialM11 defines 1st value of 1st row
  65705. * @param initialM12 defines 2nd value of 1st row
  65706. * @param initialM13 defines 3rd value of 1st row
  65707. * @param initialM14 defines 4th value of 1st row
  65708. * @param initialM21 defines 1st value of 2nd row
  65709. * @param initialM22 defines 2nd value of 2nd row
  65710. * @param initialM23 defines 3rd value of 2nd row
  65711. * @param initialM24 defines 4th value of 2nd row
  65712. * @param initialM31 defines 1st value of 3rd row
  65713. * @param initialM32 defines 2nd value of 3rd row
  65714. * @param initialM33 defines 3rd value of 3rd row
  65715. * @param initialM34 defines 4th value of 3rd row
  65716. * @param initialM41 defines 1st value of 4th row
  65717. * @param initialM42 defines 2nd value of 4th row
  65718. * @param initialM43 defines 3rd value of 4th row
  65719. * @param initialM44 defines 4th value of 4th row
  65720. * @param result defines the target matrix
  65721. */
  65722. 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;
  65723. /**
  65724. * Creates new matrix from a list of values (16)
  65725. * @param initialM11 defines 1st value of 1st row
  65726. * @param initialM12 defines 2nd value of 1st row
  65727. * @param initialM13 defines 3rd value of 1st row
  65728. * @param initialM14 defines 4th value of 1st row
  65729. * @param initialM21 defines 1st value of 2nd row
  65730. * @param initialM22 defines 2nd value of 2nd row
  65731. * @param initialM23 defines 3rd value of 2nd row
  65732. * @param initialM24 defines 4th value of 2nd row
  65733. * @param initialM31 defines 1st value of 3rd row
  65734. * @param initialM32 defines 2nd value of 3rd row
  65735. * @param initialM33 defines 3rd value of 3rd row
  65736. * @param initialM34 defines 4th value of 3rd row
  65737. * @param initialM41 defines 1st value of 4th row
  65738. * @param initialM42 defines 2nd value of 4th row
  65739. * @param initialM43 defines 3rd value of 4th row
  65740. * @param initialM44 defines 4th value of 4th row
  65741. * @returns the new matrix
  65742. */
  65743. 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;
  65744. /**
  65745. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  65746. * @param scale defines the scale vector3
  65747. * @param rotation defines the rotation quaternion
  65748. * @param translation defines the translation vector3
  65749. * @returns a new matrix
  65750. */
  65751. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  65752. /**
  65753. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  65754. * @param scale defines the scale vector3
  65755. * @param rotation defines the rotation quaternion
  65756. * @param translation defines the translation vector3
  65757. * @param result defines the target matrix
  65758. */
  65759. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  65760. /**
  65761. * Creates a new identity matrix
  65762. * @returns a new identity matrix
  65763. */
  65764. static Identity(): Matrix;
  65765. /**
  65766. * Creates a new identity matrix and stores the result in a given matrix
  65767. * @param result defines the target matrix
  65768. */
  65769. static IdentityToRef(result: Matrix): void;
  65770. /**
  65771. * Creates a new zero matrix
  65772. * @returns a new zero matrix
  65773. */
  65774. static Zero(): Matrix;
  65775. /**
  65776. * Creates a new rotation matrix for "angle" radians around the X axis
  65777. * @param angle defines the angle (in radians) to use
  65778. * @return the new matrix
  65779. */
  65780. static RotationX(angle: number): Matrix;
  65781. /**
  65782. * Creates a new matrix as the invert of a given matrix
  65783. * @param source defines the source matrix
  65784. * @returns the new matrix
  65785. */
  65786. static Invert(source: DeepImmutable<Matrix>): Matrix;
  65787. /**
  65788. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  65789. * @param angle defines the angle (in radians) to use
  65790. * @param result defines the target matrix
  65791. */
  65792. static RotationXToRef(angle: number, result: Matrix): void;
  65793. /**
  65794. * Creates a new rotation matrix for "angle" radians around the Y axis
  65795. * @param angle defines the angle (in radians) to use
  65796. * @return the new matrix
  65797. */
  65798. static RotationY(angle: number): Matrix;
  65799. /**
  65800. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  65801. * @param angle defines the angle (in radians) to use
  65802. * @param result defines the target matrix
  65803. */
  65804. static RotationYToRef(angle: number, result: Matrix): void;
  65805. /**
  65806. * Creates a new rotation matrix for "angle" radians around the Z axis
  65807. * @param angle defines the angle (in radians) to use
  65808. * @return the new matrix
  65809. */
  65810. static RotationZ(angle: number): Matrix;
  65811. /**
  65812. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  65813. * @param angle defines the angle (in radians) to use
  65814. * @param result defines the target matrix
  65815. */
  65816. static RotationZToRef(angle: number, result: Matrix): void;
  65817. /**
  65818. * Creates a new rotation matrix for "angle" radians around the given axis
  65819. * @param axis defines the axis to use
  65820. * @param angle defines the angle (in radians) to use
  65821. * @return the new matrix
  65822. */
  65823. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  65824. /**
  65825. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  65826. * @param axis defines the axis to use
  65827. * @param angle defines the angle (in radians) to use
  65828. * @param result defines the target matrix
  65829. */
  65830. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  65831. /**
  65832. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  65833. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  65834. * @param from defines the vector to align
  65835. * @param to defines the vector to align to
  65836. * @param result defines the target matrix
  65837. */
  65838. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  65839. /**
  65840. * Creates a rotation matrix
  65841. * @param yaw defines the yaw angle in radians (Y axis)
  65842. * @param pitch defines the pitch angle in radians (X axis)
  65843. * @param roll defines the roll angle in radians (X axis)
  65844. * @returns the new rotation matrix
  65845. */
  65846. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  65847. /**
  65848. * Creates a rotation matrix and stores it in a given matrix
  65849. * @param yaw defines the yaw angle in radians (Y axis)
  65850. * @param pitch defines the pitch angle in radians (X axis)
  65851. * @param roll defines the roll angle in radians (X axis)
  65852. * @param result defines the target matrix
  65853. */
  65854. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  65855. /**
  65856. * Creates a scaling matrix
  65857. * @param x defines the scale factor on X axis
  65858. * @param y defines the scale factor on Y axis
  65859. * @param z defines the scale factor on Z axis
  65860. * @returns the new matrix
  65861. */
  65862. static Scaling(x: number, y: number, z: number): Matrix;
  65863. /**
  65864. * Creates a scaling matrix and stores it in a given matrix
  65865. * @param x defines the scale factor on X axis
  65866. * @param y defines the scale factor on Y axis
  65867. * @param z defines the scale factor on Z axis
  65868. * @param result defines the target matrix
  65869. */
  65870. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  65871. /**
  65872. * Creates a translation matrix
  65873. * @param x defines the translation on X axis
  65874. * @param y defines the translation on Y axis
  65875. * @param z defines the translationon Z axis
  65876. * @returns the new matrix
  65877. */
  65878. static Translation(x: number, y: number, z: number): Matrix;
  65879. /**
  65880. * Creates a translation matrix and stores it in a given matrix
  65881. * @param x defines the translation on X axis
  65882. * @param y defines the translation on Y axis
  65883. * @param z defines the translationon Z axis
  65884. * @param result defines the target matrix
  65885. */
  65886. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  65887. /**
  65888. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  65889. * @param startValue defines the start value
  65890. * @param endValue defines the end value
  65891. * @param gradient defines the gradient factor
  65892. * @returns the new matrix
  65893. */
  65894. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  65895. /**
  65896. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  65897. * @param startValue defines the start value
  65898. * @param endValue defines the end value
  65899. * @param gradient defines the gradient factor
  65900. * @param result defines the Matrix object where to store data
  65901. */
  65902. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  65903. /**
  65904. * Builds a new matrix whose values are computed by:
  65905. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  65906. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  65907. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  65908. * @param startValue defines the first matrix
  65909. * @param endValue defines the second matrix
  65910. * @param gradient defines the gradient between the two matrices
  65911. * @returns the new matrix
  65912. */
  65913. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  65914. /**
  65915. * Update a matrix to values which are computed by:
  65916. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  65917. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  65918. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  65919. * @param startValue defines the first matrix
  65920. * @param endValue defines the second matrix
  65921. * @param gradient defines the gradient between the two matrices
  65922. * @param result defines the target matrix
  65923. */
  65924. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  65925. /**
  65926. * 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"
  65927. * This function works in left handed mode
  65928. * @param eye defines the final position of the entity
  65929. * @param target defines where the entity should look at
  65930. * @param up defines the up vector for the entity
  65931. * @returns the new matrix
  65932. */
  65933. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  65934. /**
  65935. * 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".
  65936. * This function works in left handed mode
  65937. * @param eye defines the final position of the entity
  65938. * @param target defines where the entity should look at
  65939. * @param up defines the up vector for the entity
  65940. * @param result defines the target matrix
  65941. */
  65942. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  65943. /**
  65944. * 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"
  65945. * This function works in right handed mode
  65946. * @param eye defines the final position of the entity
  65947. * @param target defines where the entity should look at
  65948. * @param up defines the up vector for the entity
  65949. * @returns the new matrix
  65950. */
  65951. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  65952. /**
  65953. * 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".
  65954. * This function works in right handed mode
  65955. * @param eye defines the final position of the entity
  65956. * @param target defines where the entity should look at
  65957. * @param up defines the up vector for the entity
  65958. * @param result defines the target matrix
  65959. */
  65960. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  65961. /**
  65962. * Create a left-handed orthographic projection matrix
  65963. * @param width defines the viewport width
  65964. * @param height defines the viewport height
  65965. * @param znear defines the near clip plane
  65966. * @param zfar defines the far clip plane
  65967. * @returns a new matrix as a left-handed orthographic projection matrix
  65968. */
  65969. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  65970. /**
  65971. * Store a left-handed orthographic projection to a given matrix
  65972. * @param width defines the viewport width
  65973. * @param height defines the viewport height
  65974. * @param znear defines the near clip plane
  65975. * @param zfar defines the far clip plane
  65976. * @param result defines the target matrix
  65977. */
  65978. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  65979. /**
  65980. * Create a left-handed orthographic projection matrix
  65981. * @param left defines the viewport left coordinate
  65982. * @param right defines the viewport right coordinate
  65983. * @param bottom defines the viewport bottom coordinate
  65984. * @param top defines the viewport top coordinate
  65985. * @param znear defines the near clip plane
  65986. * @param zfar defines the far clip plane
  65987. * @returns a new matrix as a left-handed orthographic projection matrix
  65988. */
  65989. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  65990. /**
  65991. * Stores a left-handed orthographic projection into a given matrix
  65992. * @param left defines the viewport left coordinate
  65993. * @param right defines the viewport right coordinate
  65994. * @param bottom defines the viewport bottom coordinate
  65995. * @param top defines the viewport top coordinate
  65996. * @param znear defines the near clip plane
  65997. * @param zfar defines the far clip plane
  65998. * @param result defines the target matrix
  65999. */
  66000. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  66001. /**
  66002. * Creates a right-handed orthographic projection matrix
  66003. * @param left defines the viewport left coordinate
  66004. * @param right defines the viewport right coordinate
  66005. * @param bottom defines the viewport bottom coordinate
  66006. * @param top defines the viewport top coordinate
  66007. * @param znear defines the near clip plane
  66008. * @param zfar defines the far clip plane
  66009. * @returns a new matrix as a right-handed orthographic projection matrix
  66010. */
  66011. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  66012. /**
  66013. * Stores a right-handed orthographic projection into a given matrix
  66014. * @param left defines the viewport left coordinate
  66015. * @param right defines the viewport right coordinate
  66016. * @param bottom defines the viewport bottom coordinate
  66017. * @param top defines the viewport top coordinate
  66018. * @param znear defines the near clip plane
  66019. * @param zfar defines the far clip plane
  66020. * @param result defines the target matrix
  66021. */
  66022. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  66023. /**
  66024. * Creates a left-handed perspective projection matrix
  66025. * @param width defines the viewport width
  66026. * @param height defines the viewport height
  66027. * @param znear defines the near clip plane
  66028. * @param zfar defines the far clip plane
  66029. * @returns a new matrix as a left-handed perspective projection matrix
  66030. */
  66031. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  66032. /**
  66033. * Creates a left-handed perspective projection matrix
  66034. * @param fov defines the horizontal field of view
  66035. * @param aspect defines the aspect ratio
  66036. * @param znear defines the near clip plane
  66037. * @param zfar defines the far clip plane
  66038. * @returns a new matrix as a left-handed perspective projection matrix
  66039. */
  66040. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  66041. /**
  66042. * Stores a left-handed perspective projection into a given matrix
  66043. * @param fov defines the horizontal field of view
  66044. * @param aspect defines the aspect ratio
  66045. * @param znear defines the near clip plane
  66046. * @param zfar defines the far clip plane
  66047. * @param result defines the target matrix
  66048. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  66049. */
  66050. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  66051. /**
  66052. * Creates a right-handed perspective projection matrix
  66053. * @param fov defines the horizontal field of view
  66054. * @param aspect defines the aspect ratio
  66055. * @param znear defines the near clip plane
  66056. * @param zfar defines the far clip plane
  66057. * @returns a new matrix as a right-handed perspective projection matrix
  66058. */
  66059. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  66060. /**
  66061. * Stores a right-handed perspective projection into a given matrix
  66062. * @param fov defines the horizontal field of view
  66063. * @param aspect defines the aspect ratio
  66064. * @param znear defines the near clip plane
  66065. * @param zfar defines the far clip plane
  66066. * @param result defines the target matrix
  66067. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  66068. */
  66069. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  66070. /**
  66071. * Stores a perspective projection for WebVR info a given matrix
  66072. * @param fov defines the field of view
  66073. * @param znear defines the near clip plane
  66074. * @param zfar defines the far clip plane
  66075. * @param result defines the target matrix
  66076. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  66077. */
  66078. static PerspectiveFovWebVRToRef(fov: {
  66079. upDegrees: number;
  66080. downDegrees: number;
  66081. leftDegrees: number;
  66082. rightDegrees: number;
  66083. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  66084. /**
  66085. * Computes a complete transformation matrix
  66086. * @param viewport defines the viewport to use
  66087. * @param world defines the world matrix
  66088. * @param view defines the view matrix
  66089. * @param projection defines the projection matrix
  66090. * @param zmin defines the near clip plane
  66091. * @param zmax defines the far clip plane
  66092. * @returns the transformation matrix
  66093. */
  66094. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  66095. /**
  66096. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  66097. * @param matrix defines the matrix to use
  66098. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  66099. */
  66100. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  66101. /**
  66102. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  66103. * @param matrix defines the matrix to use
  66104. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  66105. */
  66106. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  66107. /**
  66108. * Compute the transpose of a given matrix
  66109. * @param matrix defines the matrix to transpose
  66110. * @returns the new matrix
  66111. */
  66112. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  66113. /**
  66114. * Compute the transpose of a matrix and store it in a target matrix
  66115. * @param matrix defines the matrix to transpose
  66116. * @param result defines the target matrix
  66117. */
  66118. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  66119. /**
  66120. * Computes a reflection matrix from a plane
  66121. * @param plane defines the reflection plane
  66122. * @returns a new matrix
  66123. */
  66124. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  66125. /**
  66126. * Computes a reflection matrix from a plane
  66127. * @param plane defines the reflection plane
  66128. * @param result defines the target matrix
  66129. */
  66130. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  66131. /**
  66132. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  66133. * @param xaxis defines the value of the 1st axis
  66134. * @param yaxis defines the value of the 2nd axis
  66135. * @param zaxis defines the value of the 3rd axis
  66136. * @param result defines the target matrix
  66137. */
  66138. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  66139. /**
  66140. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  66141. * @param quat defines the quaternion to use
  66142. * @param result defines the target matrix
  66143. */
  66144. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  66145. }
  66146. /**
  66147. * Represens a plane by the equation ax + by + cz + d = 0
  66148. */
  66149. export class Plane {
  66150. /**
  66151. * Normal of the plane (a,b,c)
  66152. */
  66153. normal: Vector3;
  66154. /**
  66155. * d component of the plane
  66156. */
  66157. d: number;
  66158. /**
  66159. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  66160. * @param a a component of the plane
  66161. * @param b b component of the plane
  66162. * @param c c component of the plane
  66163. * @param d d component of the plane
  66164. */
  66165. constructor(a: number, b: number, c: number, d: number);
  66166. /**
  66167. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  66168. */
  66169. asArray(): number[];
  66170. /**
  66171. * @returns a new plane copied from the current Plane.
  66172. */
  66173. clone(): Plane;
  66174. /**
  66175. * @returns the string "Plane".
  66176. */
  66177. getClassName(): string;
  66178. /**
  66179. * @returns the Plane hash code.
  66180. */
  66181. getHashCode(): number;
  66182. /**
  66183. * Normalize the current Plane in place.
  66184. * @returns the updated Plane.
  66185. */
  66186. normalize(): Plane;
  66187. /**
  66188. * Applies a transformation the plane and returns the result
  66189. * @param transformation the transformation matrix to be applied to the plane
  66190. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  66191. */
  66192. transform(transformation: DeepImmutable<Matrix>): Plane;
  66193. /**
  66194. * Calcualtte the dot product between the point and the plane normal
  66195. * @param point point to calculate the dot product with
  66196. * @returns the dot product (float) of the point coordinates and the plane normal.
  66197. */
  66198. dotCoordinate(point: DeepImmutable<Vector3>): number;
  66199. /**
  66200. * Updates the current Plane from the plane defined by the three given points.
  66201. * @param point1 one of the points used to contruct the plane
  66202. * @param point2 one of the points used to contruct the plane
  66203. * @param point3 one of the points used to contruct the plane
  66204. * @returns the updated Plane.
  66205. */
  66206. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  66207. /**
  66208. * Checks if the plane is facing a given direction
  66209. * @param direction the direction to check if the plane is facing
  66210. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  66211. * @returns True is the vector "direction" is the same side than the plane normal.
  66212. */
  66213. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  66214. /**
  66215. * Calculates the distance to a point
  66216. * @param point point to calculate distance to
  66217. * @returns the signed distance (float) from the given point to the Plane.
  66218. */
  66219. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  66220. /**
  66221. * Creates a plane from an array
  66222. * @param array the array to create a plane from
  66223. * @returns a new Plane from the given array.
  66224. */
  66225. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  66226. /**
  66227. * Creates a plane from three points
  66228. * @param point1 point used to create the plane
  66229. * @param point2 point used to create the plane
  66230. * @param point3 point used to create the plane
  66231. * @returns a new Plane defined by the three given points.
  66232. */
  66233. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  66234. /**
  66235. * Creates a plane from an origin point and a normal
  66236. * @param origin origin of the plane to be constructed
  66237. * @param normal normal of the plane to be constructed
  66238. * @returns a new Plane the normal vector to this plane at the given origin point.
  66239. * Note : the vector "normal" is updated because normalized.
  66240. */
  66241. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  66242. /**
  66243. * Calculates the distance from a plane and a point
  66244. * @param origin origin of the plane to be constructed
  66245. * @param normal normal of the plane to be constructed
  66246. * @param point point to calculate distance to
  66247. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  66248. */
  66249. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  66250. }
  66251. /**
  66252. * Class used to represent a viewport on screen
  66253. */
  66254. export class Viewport {
  66255. /** viewport left coordinate */
  66256. x: number;
  66257. /** viewport top coordinate */
  66258. y: number;
  66259. /**viewport width */
  66260. width: number;
  66261. /** viewport height */
  66262. height: number;
  66263. /**
  66264. * Creates a Viewport object located at (x, y) and sized (width, height)
  66265. * @param x defines viewport left coordinate
  66266. * @param y defines viewport top coordinate
  66267. * @param width defines the viewport width
  66268. * @param height defines the viewport height
  66269. */
  66270. constructor(
  66271. /** viewport left coordinate */
  66272. x: number,
  66273. /** viewport top coordinate */
  66274. y: number,
  66275. /**viewport width */
  66276. width: number,
  66277. /** viewport height */
  66278. height: number);
  66279. /**
  66280. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  66281. * @param renderWidth defines the rendering width
  66282. * @param renderHeight defines the rendering height
  66283. * @returns a new Viewport
  66284. */
  66285. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  66286. /**
  66287. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  66288. * @param renderWidth defines the rendering width
  66289. * @param renderHeight defines the rendering height
  66290. * @param ref defines the target viewport
  66291. * @returns the current viewport
  66292. */
  66293. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  66294. /**
  66295. * Returns a new Viewport copied from the current one
  66296. * @returns a new Viewport
  66297. */
  66298. clone(): Viewport;
  66299. }
  66300. /**
  66301. * Reprasents a camera frustum
  66302. */
  66303. export class Frustum {
  66304. /**
  66305. * Gets the planes representing the frustum
  66306. * @param transform matrix to be applied to the returned planes
  66307. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  66308. */
  66309. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  66310. /**
  66311. * Gets the near frustum plane transformed by the transform matrix
  66312. * @param transform transformation matrix to be applied to the resulting frustum plane
  66313. * @param frustumPlane the resuling frustum plane
  66314. */
  66315. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66316. /**
  66317. * Gets the far frustum plane transformed by the transform matrix
  66318. * @param transform transformation matrix to be applied to the resulting frustum plane
  66319. * @param frustumPlane the resuling frustum plane
  66320. */
  66321. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66322. /**
  66323. * Gets the left frustum plane transformed by the transform matrix
  66324. * @param transform transformation matrix to be applied to the resulting frustum plane
  66325. * @param frustumPlane the resuling frustum plane
  66326. */
  66327. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66328. /**
  66329. * Gets the right frustum plane transformed by the transform matrix
  66330. * @param transform transformation matrix to be applied to the resulting frustum plane
  66331. * @param frustumPlane the resuling frustum plane
  66332. */
  66333. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66334. /**
  66335. * Gets the top frustum plane transformed by the transform matrix
  66336. * @param transform transformation matrix to be applied to the resulting frustum plane
  66337. * @param frustumPlane the resuling frustum plane
  66338. */
  66339. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66340. /**
  66341. * Gets the bottom frustum plane transformed by the transform matrix
  66342. * @param transform transformation matrix to be applied to the resulting frustum plane
  66343. * @param frustumPlane the resuling frustum plane
  66344. */
  66345. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  66346. /**
  66347. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  66348. * @param transform transformation matrix to be applied to the resulting frustum planes
  66349. * @param frustumPlanes the resuling frustum planes
  66350. */
  66351. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  66352. }
  66353. /** Defines supported spaces */
  66354. export enum Space {
  66355. /** Local (object) space */
  66356. LOCAL = 0,
  66357. /** World space */
  66358. WORLD = 1,
  66359. /** Bone space */
  66360. BONE = 2
  66361. }
  66362. /** Defines the 3 main axes */
  66363. export class Axis {
  66364. /** X axis */
  66365. static X: Vector3;
  66366. /** Y axis */
  66367. static Y: Vector3;
  66368. /** Z axis */
  66369. static Z: Vector3;
  66370. }
  66371. /** Class used to represent a Bezier curve */
  66372. export class BezierCurve {
  66373. /**
  66374. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  66375. * @param t defines the time
  66376. * @param x1 defines the left coordinate on X axis
  66377. * @param y1 defines the left coordinate on Y axis
  66378. * @param x2 defines the right coordinate on X axis
  66379. * @param y2 defines the right coordinate on Y axis
  66380. * @returns the interpolated value
  66381. */
  66382. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  66383. }
  66384. /**
  66385. * Defines potential orientation for back face culling
  66386. */
  66387. export enum Orientation {
  66388. /**
  66389. * Clockwise
  66390. */
  66391. CW = 0,
  66392. /** Counter clockwise */
  66393. CCW = 1
  66394. }
  66395. /**
  66396. * Defines angle representation
  66397. */
  66398. export class Angle {
  66399. private _radians;
  66400. /**
  66401. * Creates an Angle object of "radians" radians (float).
  66402. * @param radians the angle in radians
  66403. */
  66404. constructor(radians: number);
  66405. /**
  66406. * Get value in degrees
  66407. * @returns the Angle value in degrees (float)
  66408. */
  66409. degrees(): number;
  66410. /**
  66411. * Get value in radians
  66412. * @returns the Angle value in radians (float)
  66413. */
  66414. radians(): number;
  66415. /**
  66416. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  66417. * @param a defines first vector
  66418. * @param b defines second vector
  66419. * @returns a new Angle
  66420. */
  66421. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  66422. /**
  66423. * Gets a new Angle object from the given float in radians
  66424. * @param radians defines the angle value in radians
  66425. * @returns a new Angle
  66426. */
  66427. static FromRadians(radians: number): Angle;
  66428. /**
  66429. * Gets a new Angle object from the given float in degrees
  66430. * @param degrees defines the angle value in degrees
  66431. * @returns a new Angle
  66432. */
  66433. static FromDegrees(degrees: number): Angle;
  66434. }
  66435. /**
  66436. * This represents an arc in a 2d space.
  66437. */
  66438. export class Arc2 {
  66439. /** Defines the start point of the arc */
  66440. startPoint: Vector2;
  66441. /** Defines the mid point of the arc */
  66442. midPoint: Vector2;
  66443. /** Defines the end point of the arc */
  66444. endPoint: Vector2;
  66445. /**
  66446. * Defines the center point of the arc.
  66447. */
  66448. centerPoint: Vector2;
  66449. /**
  66450. * Defines the radius of the arc.
  66451. */
  66452. radius: number;
  66453. /**
  66454. * Defines the angle of the arc (from mid point to end point).
  66455. */
  66456. angle: Angle;
  66457. /**
  66458. * Defines the start angle of the arc (from start point to middle point).
  66459. */
  66460. startAngle: Angle;
  66461. /**
  66462. * Defines the orientation of the arc (clock wise/counter clock wise).
  66463. */
  66464. orientation: Orientation;
  66465. /**
  66466. * Creates an Arc object from the three given points : start, middle and end.
  66467. * @param startPoint Defines the start point of the arc
  66468. * @param midPoint Defines the midlle point of the arc
  66469. * @param endPoint Defines the end point of the arc
  66470. */
  66471. constructor(
  66472. /** Defines the start point of the arc */
  66473. startPoint: Vector2,
  66474. /** Defines the mid point of the arc */
  66475. midPoint: Vector2,
  66476. /** Defines the end point of the arc */
  66477. endPoint: Vector2);
  66478. }
  66479. /**
  66480. * Represents a 2D path made up of multiple 2D points
  66481. */
  66482. export class Path2 {
  66483. private _points;
  66484. private _length;
  66485. /**
  66486. * If the path start and end point are the same
  66487. */
  66488. closed: boolean;
  66489. /**
  66490. * Creates a Path2 object from the starting 2D coordinates x and y.
  66491. * @param x the starting points x value
  66492. * @param y the starting points y value
  66493. */
  66494. constructor(x: number, y: number);
  66495. /**
  66496. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  66497. * @param x the added points x value
  66498. * @param y the added points y value
  66499. * @returns the updated Path2.
  66500. */
  66501. addLineTo(x: number, y: number): Path2;
  66502. /**
  66503. * 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.
  66504. * @param midX middle point x value
  66505. * @param midY middle point y value
  66506. * @param endX end point x value
  66507. * @param endY end point y value
  66508. * @param numberOfSegments (default: 36)
  66509. * @returns the updated Path2.
  66510. */
  66511. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  66512. /**
  66513. * Closes the Path2.
  66514. * @returns the Path2.
  66515. */
  66516. close(): Path2;
  66517. /**
  66518. * Gets the sum of the distance between each sequential point in the path
  66519. * @returns the Path2 total length (float).
  66520. */
  66521. length(): number;
  66522. /**
  66523. * Gets the points which construct the path
  66524. * @returns the Path2 internal array of points.
  66525. */
  66526. getPoints(): Vector2[];
  66527. /**
  66528. * Retreives the point at the distance aways from the starting point
  66529. * @param normalizedLengthPosition the length along the path to retreive the point from
  66530. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  66531. */
  66532. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  66533. /**
  66534. * Creates a new path starting from an x and y position
  66535. * @param x starting x value
  66536. * @param y starting y value
  66537. * @returns a new Path2 starting at the coordinates (x, y).
  66538. */
  66539. static StartingAt(x: number, y: number): Path2;
  66540. }
  66541. /**
  66542. * Represents a 3D path made up of multiple 3D points
  66543. */
  66544. export class Path3D {
  66545. /**
  66546. * an array of Vector3, the curve axis of the Path3D
  66547. */
  66548. path: Vector3[];
  66549. private _curve;
  66550. private _distances;
  66551. private _tangents;
  66552. private _normals;
  66553. private _binormals;
  66554. private _raw;
  66555. /**
  66556. * new Path3D(path, normal, raw)
  66557. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  66558. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  66559. * @param path an array of Vector3, the curve axis of the Path3D
  66560. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  66561. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  66562. */
  66563. constructor(
  66564. /**
  66565. * an array of Vector3, the curve axis of the Path3D
  66566. */
  66567. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  66568. /**
  66569. * Returns the Path3D array of successive Vector3 designing its curve.
  66570. * @returns the Path3D array of successive Vector3 designing its curve.
  66571. */
  66572. getCurve(): Vector3[];
  66573. /**
  66574. * Returns an array populated with tangent vectors on each Path3D curve point.
  66575. * @returns an array populated with tangent vectors on each Path3D curve point.
  66576. */
  66577. getTangents(): Vector3[];
  66578. /**
  66579. * Returns an array populated with normal vectors on each Path3D curve point.
  66580. * @returns an array populated with normal vectors on each Path3D curve point.
  66581. */
  66582. getNormals(): Vector3[];
  66583. /**
  66584. * Returns an array populated with binormal vectors on each Path3D curve point.
  66585. * @returns an array populated with binormal vectors on each Path3D curve point.
  66586. */
  66587. getBinormals(): Vector3[];
  66588. /**
  66589. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  66590. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  66591. */
  66592. getDistances(): number[];
  66593. /**
  66594. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  66595. * @param path path which all values are copied into the curves points
  66596. * @param firstNormal which should be projected onto the curve
  66597. * @returns the same object updated.
  66598. */
  66599. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  66600. private _compute;
  66601. private _getFirstNonNullVector;
  66602. private _getLastNonNullVector;
  66603. private _normalVector;
  66604. }
  66605. /**
  66606. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  66607. * A Curve3 is designed from a series of successive Vector3.
  66608. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  66609. */
  66610. export class Curve3 {
  66611. private _points;
  66612. private _length;
  66613. /**
  66614. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  66615. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  66616. * @param v1 (Vector3) the control point
  66617. * @param v2 (Vector3) the end point of the Quadratic Bezier
  66618. * @param nbPoints (integer) the wanted number of points in the curve
  66619. * @returns the created Curve3
  66620. */
  66621. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66622. /**
  66623. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  66624. * @param v0 (Vector3) the origin point of the Cubic Bezier
  66625. * @param v1 (Vector3) the first control point
  66626. * @param v2 (Vector3) the second control point
  66627. * @param v3 (Vector3) the end point of the Cubic Bezier
  66628. * @param nbPoints (integer) the wanted number of points in the curve
  66629. * @returns the created Curve3
  66630. */
  66631. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66632. /**
  66633. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  66634. * @param p1 (Vector3) the origin point of the Hermite Spline
  66635. * @param t1 (Vector3) the tangent vector at the origin point
  66636. * @param p2 (Vector3) the end point of the Hermite Spline
  66637. * @param t2 (Vector3) the tangent vector at the end point
  66638. * @param nbPoints (integer) the wanted number of points in the curve
  66639. * @returns the created Curve3
  66640. */
  66641. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66642. /**
  66643. * Returns a Curve3 object along a CatmullRom Spline curve :
  66644. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  66645. * @param nbPoints (integer) the wanted number of points between each curve control points
  66646. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  66647. * @returns the created Curve3
  66648. */
  66649. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  66650. /**
  66651. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  66652. * A Curve3 is designed from a series of successive Vector3.
  66653. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  66654. * @param points points which make up the curve
  66655. */
  66656. constructor(points: Vector3[]);
  66657. /**
  66658. * @returns the Curve3 stored array of successive Vector3
  66659. */
  66660. getPoints(): Vector3[];
  66661. /**
  66662. * @returns the computed length (float) of the curve.
  66663. */
  66664. length(): number;
  66665. /**
  66666. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  66667. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  66668. * curveA and curveB keep unchanged.
  66669. * @param curve the curve to continue from this curve
  66670. * @returns the newly constructed curve
  66671. */
  66672. continue(curve: DeepImmutable<Curve3>): Curve3;
  66673. private _computeLength;
  66674. }
  66675. /**
  66676. * Contains position and normal vectors for a vertex
  66677. */
  66678. export class PositionNormalVertex {
  66679. /** the position of the vertex (defaut: 0,0,0) */
  66680. position: Vector3;
  66681. /** the normal of the vertex (defaut: 0,1,0) */
  66682. normal: Vector3;
  66683. /**
  66684. * Creates a PositionNormalVertex
  66685. * @param position the position of the vertex (defaut: 0,0,0)
  66686. * @param normal the normal of the vertex (defaut: 0,1,0)
  66687. */
  66688. constructor(
  66689. /** the position of the vertex (defaut: 0,0,0) */
  66690. position?: Vector3,
  66691. /** the normal of the vertex (defaut: 0,1,0) */
  66692. normal?: Vector3);
  66693. /**
  66694. * Clones the PositionNormalVertex
  66695. * @returns the cloned PositionNormalVertex
  66696. */
  66697. clone(): PositionNormalVertex;
  66698. }
  66699. /**
  66700. * Contains position, normal and uv vectors for a vertex
  66701. */
  66702. export class PositionNormalTextureVertex {
  66703. /** the position of the vertex (defaut: 0,0,0) */
  66704. position: Vector3;
  66705. /** the normal of the vertex (defaut: 0,1,0) */
  66706. normal: Vector3;
  66707. /** the uv of the vertex (default: 0,0) */
  66708. uv: Vector2;
  66709. /**
  66710. * Creates a PositionNormalTextureVertex
  66711. * @param position the position of the vertex (defaut: 0,0,0)
  66712. * @param normal the normal of the vertex (defaut: 0,1,0)
  66713. * @param uv the uv of the vertex (default: 0,0)
  66714. */
  66715. constructor(
  66716. /** the position of the vertex (defaut: 0,0,0) */
  66717. position?: Vector3,
  66718. /** the normal of the vertex (defaut: 0,1,0) */
  66719. normal?: Vector3,
  66720. /** the uv of the vertex (default: 0,0) */
  66721. uv?: Vector2);
  66722. /**
  66723. * Clones the PositionNormalTextureVertex
  66724. * @returns the cloned PositionNormalTextureVertex
  66725. */
  66726. clone(): PositionNormalTextureVertex;
  66727. }
  66728. /**
  66729. * @hidden
  66730. */
  66731. export class Tmp {
  66732. static Color3: Color3[];
  66733. static Color4: Color4[];
  66734. static Vector2: Vector2[];
  66735. static Vector3: Vector3[];
  66736. static Vector4: Vector4[];
  66737. static Quaternion: Quaternion[];
  66738. static Matrix: Matrix[];
  66739. }
  66740. }
  66741. declare module BABYLON {
  66742. /**
  66743. * Class used to enable access to offline support
  66744. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66745. */
  66746. export interface IOfflineProvider {
  66747. /**
  66748. * Gets a boolean indicating if scene must be saved in the database
  66749. */
  66750. enableSceneOffline: boolean;
  66751. /**
  66752. * Gets a boolean indicating if textures must be saved in the database
  66753. */
  66754. enableTexturesOffline: boolean;
  66755. /**
  66756. * Open the offline support and make it available
  66757. * @param successCallback defines the callback to call on success
  66758. * @param errorCallback defines the callback to call on error
  66759. */
  66760. open(successCallback: () => void, errorCallback: () => void): void;
  66761. /**
  66762. * Loads an image from the offline support
  66763. * @param url defines the url to load from
  66764. * @param image defines the target DOM image
  66765. */
  66766. loadImage(url: string, image: HTMLImageElement): void;
  66767. /**
  66768. * Loads a file from offline support
  66769. * @param url defines the URL to load from
  66770. * @param sceneLoaded defines a callback to call on success
  66771. * @param progressCallBack defines a callback to call when progress changed
  66772. * @param errorCallback defines a callback to call on error
  66773. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  66774. */
  66775. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66776. }
  66777. }
  66778. declare module BABYLON {
  66779. /**
  66780. * A class serves as a medium between the observable and its observers
  66781. */
  66782. export class EventState {
  66783. /**
  66784. * Create a new EventState
  66785. * @param mask defines the mask associated with this state
  66786. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66787. * @param target defines the original target of the state
  66788. * @param currentTarget defines the current target of the state
  66789. */
  66790. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  66791. /**
  66792. * Initialize the current event state
  66793. * @param mask defines the mask associated with this state
  66794. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66795. * @param target defines the original target of the state
  66796. * @param currentTarget defines the current target of the state
  66797. * @returns the current event state
  66798. */
  66799. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  66800. /**
  66801. * An Observer can set this property to true to prevent subsequent observers of being notified
  66802. */
  66803. skipNextObservers: boolean;
  66804. /**
  66805. * Get the mask value that were used to trigger the event corresponding to this EventState object
  66806. */
  66807. mask: number;
  66808. /**
  66809. * The object that originally notified the event
  66810. */
  66811. target?: any;
  66812. /**
  66813. * The current object in the bubbling phase
  66814. */
  66815. currentTarget?: any;
  66816. /**
  66817. * This will be populated with the return value of the last function that was executed.
  66818. * If it is the first function in the callback chain it will be the event data.
  66819. */
  66820. lastReturnValue?: any;
  66821. }
  66822. /**
  66823. * Represent an Observer registered to a given Observable object.
  66824. */
  66825. export class Observer<T> {
  66826. /**
  66827. * Defines the callback to call when the observer is notified
  66828. */
  66829. callback: (eventData: T, eventState: EventState) => void;
  66830. /**
  66831. * Defines the mask of the observer (used to filter notifications)
  66832. */
  66833. mask: number;
  66834. /**
  66835. * Defines the current scope used to restore the JS context
  66836. */
  66837. scope: any;
  66838. /** @hidden */
  66839. _willBeUnregistered: boolean;
  66840. /**
  66841. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  66842. */
  66843. unregisterOnNextCall: boolean;
  66844. /**
  66845. * Creates a new observer
  66846. * @param callback defines the callback to call when the observer is notified
  66847. * @param mask defines the mask of the observer (used to filter notifications)
  66848. * @param scope defines the current scope used to restore the JS context
  66849. */
  66850. constructor(
  66851. /**
  66852. * Defines the callback to call when the observer is notified
  66853. */
  66854. callback: (eventData: T, eventState: EventState) => void,
  66855. /**
  66856. * Defines the mask of the observer (used to filter notifications)
  66857. */
  66858. mask: number,
  66859. /**
  66860. * Defines the current scope used to restore the JS context
  66861. */
  66862. scope?: any);
  66863. }
  66864. /**
  66865. * Represent a list of observers registered to multiple Observables object.
  66866. */
  66867. export class MultiObserver<T> {
  66868. private _observers;
  66869. private _observables;
  66870. /**
  66871. * Release associated resources
  66872. */
  66873. dispose(): void;
  66874. /**
  66875. * Raise a callback when one of the observable will notify
  66876. * @param observables defines a list of observables to watch
  66877. * @param callback defines the callback to call on notification
  66878. * @param mask defines the mask used to filter notifications
  66879. * @param scope defines the current scope used to restore the JS context
  66880. * @returns the new MultiObserver
  66881. */
  66882. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  66883. }
  66884. /**
  66885. * The Observable class is a simple implementation of the Observable pattern.
  66886. *
  66887. * 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.
  66888. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  66889. * 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).
  66890. * 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.
  66891. */
  66892. export class Observable<T> {
  66893. private _observers;
  66894. private _eventState;
  66895. private _onObserverAdded;
  66896. /**
  66897. * Gets the list of observers
  66898. */
  66899. readonly observers: Array<Observer<T>>;
  66900. /**
  66901. * Creates a new observable
  66902. * @param onObserverAdded defines a callback to call when a new observer is added
  66903. */
  66904. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  66905. /**
  66906. * Create a new Observer with the specified callback
  66907. * @param callback the callback that will be executed for that Observer
  66908. * @param mask the mask used to filter observers
  66909. * @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.
  66910. * @param scope optional scope for the callback to be called from
  66911. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  66912. * @returns the new observer created for the callback
  66913. */
  66914. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  66915. /**
  66916. * Create a new Observer with the specified callback and unregisters after the next notification
  66917. * @param callback the callback that will be executed for that Observer
  66918. * @returns the new observer created for the callback
  66919. */
  66920. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  66921. /**
  66922. * Remove an Observer from the Observable object
  66923. * @param observer the instance of the Observer to remove
  66924. * @returns false if it doesn't belong to this Observable
  66925. */
  66926. remove(observer: Nullable<Observer<T>>): boolean;
  66927. /**
  66928. * Remove a callback from the Observable object
  66929. * @param callback the callback to remove
  66930. * @param scope optional scope. If used only the callbacks with this scope will be removed
  66931. * @returns false if it doesn't belong to this Observable
  66932. */
  66933. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  66934. private _deferUnregister;
  66935. private _remove;
  66936. /**
  66937. * Moves the observable to the top of the observer list making it get called first when notified
  66938. * @param observer the observer to move
  66939. */
  66940. makeObserverTopPriority(observer: Observer<T>): void;
  66941. /**
  66942. * Moves the observable to the bottom of the observer list making it get called last when notified
  66943. * @param observer the observer to move
  66944. */
  66945. makeObserverBottomPriority(observer: Observer<T>): void;
  66946. /**
  66947. * Notify all Observers by calling their respective callback with the given data
  66948. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  66949. * @param eventData defines the data to send to all observers
  66950. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  66951. * @param target defines the original target of the state
  66952. * @param currentTarget defines the current target of the state
  66953. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  66954. */
  66955. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  66956. /**
  66957. * Calling this will execute each callback, expecting it to be a promise or return a value.
  66958. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  66959. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  66960. * and it is crucial that all callbacks will be executed.
  66961. * The order of the callbacks is kept, callbacks are not executed parallel.
  66962. *
  66963. * @param eventData The data to be sent to each callback
  66964. * @param mask is used to filter observers defaults to -1
  66965. * @param target defines the callback target (see EventState)
  66966. * @param currentTarget defines he current object in the bubbling phase
  66967. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  66968. */
  66969. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  66970. /**
  66971. * Notify a specific observer
  66972. * @param observer defines the observer to notify
  66973. * @param eventData defines the data to be sent to each callback
  66974. * @param mask is used to filter observers defaults to -1
  66975. */
  66976. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  66977. /**
  66978. * Gets a boolean indicating if the observable has at least one observer
  66979. * @returns true is the Observable has at least one Observer registered
  66980. */
  66981. hasObservers(): boolean;
  66982. /**
  66983. * Clear the list of observers
  66984. */
  66985. clear(): void;
  66986. /**
  66987. * Clone the current observable
  66988. * @returns a new observable
  66989. */
  66990. clone(): Observable<T>;
  66991. /**
  66992. * Does this observable handles observer registered with a given mask
  66993. * @param mask defines the mask to be tested
  66994. * @return whether or not one observer registered with the given mask is handeled
  66995. **/
  66996. hasSpecificMask(mask?: number): boolean;
  66997. }
  66998. }
  66999. declare module BABYLON {
  67000. /**
  67001. * Class used to help managing file picking and drag'n'drop
  67002. * File Storage
  67003. */
  67004. export class FilesInputStore {
  67005. /**
  67006. * List of files ready to be loaded
  67007. */
  67008. static FilesToLoad: {
  67009. [key: string]: File;
  67010. };
  67011. }
  67012. }
  67013. declare module BABYLON {
  67014. /** Defines the cross module used constants to avoid circular dependncies */
  67015. export class Constants {
  67016. /** Defines that alpha blending is disabled */
  67017. static readonly ALPHA_DISABLE: number;
  67018. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  67019. static readonly ALPHA_ADD: number;
  67020. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  67021. static readonly ALPHA_COMBINE: number;
  67022. /** Defines that alpha blending to DEST - SRC * DEST */
  67023. static readonly ALPHA_SUBTRACT: number;
  67024. /** Defines that alpha blending to SRC * DEST */
  67025. static readonly ALPHA_MULTIPLY: number;
  67026. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  67027. static readonly ALPHA_MAXIMIZED: number;
  67028. /** Defines that alpha blending to SRC + DEST */
  67029. static readonly ALPHA_ONEONE: number;
  67030. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  67031. static readonly ALPHA_PREMULTIPLIED: number;
  67032. /**
  67033. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  67034. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  67035. */
  67036. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  67037. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  67038. static readonly ALPHA_INTERPOLATE: number;
  67039. /**
  67040. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  67041. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  67042. */
  67043. static readonly ALPHA_SCREENMODE: number;
  67044. /** Defines that the ressource is not delayed*/
  67045. static readonly DELAYLOADSTATE_NONE: number;
  67046. /** Defines that the ressource was successfully delay loaded */
  67047. static readonly DELAYLOADSTATE_LOADED: number;
  67048. /** Defines that the ressource is currently delay loading */
  67049. static readonly DELAYLOADSTATE_LOADING: number;
  67050. /** Defines that the ressource is delayed and has not started loading */
  67051. static readonly DELAYLOADSTATE_NOTLOADED: number;
  67052. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  67053. static readonly NEVER: number;
  67054. /** 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 */
  67055. static readonly ALWAYS: number;
  67056. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  67057. static readonly LESS: number;
  67058. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  67059. static readonly EQUAL: number;
  67060. /** 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 */
  67061. static readonly LEQUAL: number;
  67062. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  67063. static readonly GREATER: number;
  67064. /** 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 */
  67065. static readonly GEQUAL: number;
  67066. /** 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 */
  67067. static readonly NOTEQUAL: number;
  67068. /** Passed to stencilOperation to specify that stencil value must be kept */
  67069. static readonly KEEP: number;
  67070. /** Passed to stencilOperation to specify that stencil value must be replaced */
  67071. static readonly REPLACE: number;
  67072. /** Passed to stencilOperation to specify that stencil value must be incremented */
  67073. static readonly INCR: number;
  67074. /** Passed to stencilOperation to specify that stencil value must be decremented */
  67075. static readonly DECR: number;
  67076. /** Passed to stencilOperation to specify that stencil value must be inverted */
  67077. static readonly INVERT: number;
  67078. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  67079. static readonly INCR_WRAP: number;
  67080. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  67081. static readonly DECR_WRAP: number;
  67082. /** Texture is not repeating outside of 0..1 UVs */
  67083. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  67084. /** Texture is repeating outside of 0..1 UVs */
  67085. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  67086. /** Texture is repeating and mirrored */
  67087. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  67088. /** ALPHA */
  67089. static readonly TEXTUREFORMAT_ALPHA: number;
  67090. /** LUMINANCE */
  67091. static readonly TEXTUREFORMAT_LUMINANCE: number;
  67092. /** LUMINANCE_ALPHA */
  67093. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  67094. /** RGB */
  67095. static readonly TEXTUREFORMAT_RGB: number;
  67096. /** RGBA */
  67097. static readonly TEXTUREFORMAT_RGBA: number;
  67098. /** RED */
  67099. static readonly TEXTUREFORMAT_RED: number;
  67100. /** RED (2nd reference) */
  67101. static readonly TEXTUREFORMAT_R: number;
  67102. /** RG */
  67103. static readonly TEXTUREFORMAT_RG: number;
  67104. /** RED_INTEGER */
  67105. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  67106. /** RED_INTEGER (2nd reference) */
  67107. static readonly TEXTUREFORMAT_R_INTEGER: number;
  67108. /** RG_INTEGER */
  67109. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  67110. /** RGB_INTEGER */
  67111. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  67112. /** RGBA_INTEGER */
  67113. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  67114. /** UNSIGNED_BYTE */
  67115. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  67116. /** UNSIGNED_BYTE (2nd reference) */
  67117. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  67118. /** FLOAT */
  67119. static readonly TEXTURETYPE_FLOAT: number;
  67120. /** HALF_FLOAT */
  67121. static readonly TEXTURETYPE_HALF_FLOAT: number;
  67122. /** BYTE */
  67123. static readonly TEXTURETYPE_BYTE: number;
  67124. /** SHORT */
  67125. static readonly TEXTURETYPE_SHORT: number;
  67126. /** UNSIGNED_SHORT */
  67127. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  67128. /** INT */
  67129. static readonly TEXTURETYPE_INT: number;
  67130. /** UNSIGNED_INT */
  67131. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  67132. /** UNSIGNED_SHORT_4_4_4_4 */
  67133. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  67134. /** UNSIGNED_SHORT_5_5_5_1 */
  67135. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  67136. /** UNSIGNED_SHORT_5_6_5 */
  67137. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  67138. /** UNSIGNED_INT_2_10_10_10_REV */
  67139. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  67140. /** UNSIGNED_INT_24_8 */
  67141. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  67142. /** UNSIGNED_INT_10F_11F_11F_REV */
  67143. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  67144. /** UNSIGNED_INT_5_9_9_9_REV */
  67145. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  67146. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  67147. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  67148. /** nearest is mag = nearest and min = nearest and mip = linear */
  67149. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  67150. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67151. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  67152. /** Trilinear is mag = linear and min = linear and mip = linear */
  67153. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  67154. /** nearest is mag = nearest and min = nearest and mip = linear */
  67155. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  67156. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67157. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  67158. /** Trilinear is mag = linear and min = linear and mip = linear */
  67159. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  67160. /** mag = nearest and min = nearest and mip = nearest */
  67161. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  67162. /** mag = nearest and min = linear and mip = nearest */
  67163. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  67164. /** mag = nearest and min = linear and mip = linear */
  67165. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  67166. /** mag = nearest and min = linear and mip = none */
  67167. static readonly TEXTURE_NEAREST_LINEAR: number;
  67168. /** mag = nearest and min = nearest and mip = none */
  67169. static readonly TEXTURE_NEAREST_NEAREST: number;
  67170. /** mag = linear and min = nearest and mip = nearest */
  67171. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  67172. /** mag = linear and min = nearest and mip = linear */
  67173. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  67174. /** mag = linear and min = linear and mip = none */
  67175. static readonly TEXTURE_LINEAR_LINEAR: number;
  67176. /** mag = linear and min = nearest and mip = none */
  67177. static readonly TEXTURE_LINEAR_NEAREST: number;
  67178. /** Explicit coordinates mode */
  67179. static readonly TEXTURE_EXPLICIT_MODE: number;
  67180. /** Spherical coordinates mode */
  67181. static readonly TEXTURE_SPHERICAL_MODE: number;
  67182. /** Planar coordinates mode */
  67183. static readonly TEXTURE_PLANAR_MODE: number;
  67184. /** Cubic coordinates mode */
  67185. static readonly TEXTURE_CUBIC_MODE: number;
  67186. /** Projection coordinates mode */
  67187. static readonly TEXTURE_PROJECTION_MODE: number;
  67188. /** Skybox coordinates mode */
  67189. static readonly TEXTURE_SKYBOX_MODE: number;
  67190. /** Inverse Cubic coordinates mode */
  67191. static readonly TEXTURE_INVCUBIC_MODE: number;
  67192. /** Equirectangular coordinates mode */
  67193. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  67194. /** Equirectangular Fixed coordinates mode */
  67195. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  67196. /** Equirectangular Fixed Mirrored coordinates mode */
  67197. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  67198. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  67199. static readonly SCALEMODE_FLOOR: number;
  67200. /** Defines that texture rescaling will look for the nearest power of 2 size */
  67201. static readonly SCALEMODE_NEAREST: number;
  67202. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  67203. static readonly SCALEMODE_CEILING: number;
  67204. /**
  67205. * The dirty texture flag value
  67206. */
  67207. static readonly MATERIAL_TextureDirtyFlag: number;
  67208. /**
  67209. * The dirty light flag value
  67210. */
  67211. static readonly MATERIAL_LightDirtyFlag: number;
  67212. /**
  67213. * The dirty fresnel flag value
  67214. */
  67215. static readonly MATERIAL_FresnelDirtyFlag: number;
  67216. /**
  67217. * The dirty attribute flag value
  67218. */
  67219. static readonly MATERIAL_AttributesDirtyFlag: number;
  67220. /**
  67221. * The dirty misc flag value
  67222. */
  67223. static readonly MATERIAL_MiscDirtyFlag: number;
  67224. /**
  67225. * The all dirty flag value
  67226. */
  67227. static readonly MATERIAL_AllDirtyFlag: number;
  67228. /**
  67229. * Returns the triangle fill mode
  67230. */
  67231. static readonly MATERIAL_TriangleFillMode: number;
  67232. /**
  67233. * Returns the wireframe mode
  67234. */
  67235. static readonly MATERIAL_WireFrameFillMode: number;
  67236. /**
  67237. * Returns the point fill mode
  67238. */
  67239. static readonly MATERIAL_PointFillMode: number;
  67240. /**
  67241. * Returns the point list draw mode
  67242. */
  67243. static readonly MATERIAL_PointListDrawMode: number;
  67244. /**
  67245. * Returns the line list draw mode
  67246. */
  67247. static readonly MATERIAL_LineListDrawMode: number;
  67248. /**
  67249. * Returns the line loop draw mode
  67250. */
  67251. static readonly MATERIAL_LineLoopDrawMode: number;
  67252. /**
  67253. * Returns the line strip draw mode
  67254. */
  67255. static readonly MATERIAL_LineStripDrawMode: number;
  67256. /**
  67257. * Returns the triangle strip draw mode
  67258. */
  67259. static readonly MATERIAL_TriangleStripDrawMode: number;
  67260. /**
  67261. * Returns the triangle fan draw mode
  67262. */
  67263. static readonly MATERIAL_TriangleFanDrawMode: number;
  67264. /**
  67265. * Stores the clock-wise side orientation
  67266. */
  67267. static readonly MATERIAL_ClockWiseSideOrientation: number;
  67268. /**
  67269. * Stores the counter clock-wise side orientation
  67270. */
  67271. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  67272. /**
  67273. * Nothing
  67274. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67275. */
  67276. static readonly ACTION_NothingTrigger: number;
  67277. /**
  67278. * On pick
  67279. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67280. */
  67281. static readonly ACTION_OnPickTrigger: number;
  67282. /**
  67283. * On left pick
  67284. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67285. */
  67286. static readonly ACTION_OnLeftPickTrigger: number;
  67287. /**
  67288. * On right pick
  67289. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67290. */
  67291. static readonly ACTION_OnRightPickTrigger: number;
  67292. /**
  67293. * On center pick
  67294. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67295. */
  67296. static readonly ACTION_OnCenterPickTrigger: number;
  67297. /**
  67298. * On pick down
  67299. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67300. */
  67301. static readonly ACTION_OnPickDownTrigger: number;
  67302. /**
  67303. * On double pick
  67304. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67305. */
  67306. static readonly ACTION_OnDoublePickTrigger: number;
  67307. /**
  67308. * On pick up
  67309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67310. */
  67311. static readonly ACTION_OnPickUpTrigger: number;
  67312. /**
  67313. * On pick out.
  67314. * This trigger will only be raised if you also declared a OnPickDown
  67315. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67316. */
  67317. static readonly ACTION_OnPickOutTrigger: number;
  67318. /**
  67319. * On long press
  67320. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67321. */
  67322. static readonly ACTION_OnLongPressTrigger: number;
  67323. /**
  67324. * On pointer over
  67325. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67326. */
  67327. static readonly ACTION_OnPointerOverTrigger: number;
  67328. /**
  67329. * On pointer out
  67330. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67331. */
  67332. static readonly ACTION_OnPointerOutTrigger: number;
  67333. /**
  67334. * On every frame
  67335. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67336. */
  67337. static readonly ACTION_OnEveryFrameTrigger: number;
  67338. /**
  67339. * On intersection enter
  67340. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67341. */
  67342. static readonly ACTION_OnIntersectionEnterTrigger: number;
  67343. /**
  67344. * On intersection exit
  67345. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67346. */
  67347. static readonly ACTION_OnIntersectionExitTrigger: number;
  67348. /**
  67349. * On key down
  67350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67351. */
  67352. static readonly ACTION_OnKeyDownTrigger: number;
  67353. /**
  67354. * On key up
  67355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67356. */
  67357. static readonly ACTION_OnKeyUpTrigger: number;
  67358. /**
  67359. * Billboard mode will only apply to Y axis
  67360. */
  67361. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  67362. /**
  67363. * Billboard mode will apply to all axes
  67364. */
  67365. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  67366. /**
  67367. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  67368. */
  67369. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  67370. /**
  67371. * Gets or sets base Assets URL
  67372. */
  67373. static PARTICLES_BaseAssetsUrl: string;
  67374. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  67375. * Test order :
  67376. * Is the bounding sphere outside the frustum ?
  67377. * If not, are the bounding box vertices outside the frustum ?
  67378. * It not, then the cullable object is in the frustum.
  67379. */
  67380. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  67381. /** Culling strategy : Bounding Sphere Only.
  67382. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  67383. * It's also less accurate than the standard because some not visible objects can still be selected.
  67384. * Test : is the bounding sphere outside the frustum ?
  67385. * If not, then the cullable object is in the frustum.
  67386. */
  67387. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  67388. /** Culling strategy : Optimistic Inclusion.
  67389. * This in an inclusion test first, then the standard exclusion test.
  67390. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  67391. * 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.
  67392. * Anyway, it's as accurate as the standard strategy.
  67393. * Test :
  67394. * Is the cullable object bounding sphere center in the frustum ?
  67395. * If not, apply the default culling strategy.
  67396. */
  67397. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  67398. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  67399. * This in an inclusion test first, then the bounding sphere only exclusion test.
  67400. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  67401. * 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.
  67402. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  67403. * Test :
  67404. * Is the cullable object bounding sphere center in the frustum ?
  67405. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  67406. */
  67407. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  67408. /**
  67409. * No logging while loading
  67410. */
  67411. static readonly SCENELOADER_NO_LOGGING: number;
  67412. /**
  67413. * Minimal logging while loading
  67414. */
  67415. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  67416. /**
  67417. * Summary logging while loading
  67418. */
  67419. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  67420. /**
  67421. * Detailled logging while loading
  67422. */
  67423. static readonly SCENELOADER_DETAILED_LOGGING: number;
  67424. }
  67425. }
  67426. declare module BABYLON {
  67427. /**
  67428. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  67429. * Babylon.js
  67430. */
  67431. export class DomManagement {
  67432. /**
  67433. * Checks if the window object exists
  67434. * @returns true if the window object exists
  67435. */
  67436. static IsWindowObjectExist(): boolean;
  67437. /**
  67438. * Extracts text content from a DOM element hierarchy
  67439. * @param element defines the root element
  67440. * @returns a string
  67441. */
  67442. static GetDOMTextContent(element: HTMLElement): string;
  67443. }
  67444. }
  67445. declare module BABYLON {
  67446. /**
  67447. * Logger used througouht the application to allow configuration of
  67448. * the log level required for the messages.
  67449. */
  67450. export class Logger {
  67451. /**
  67452. * No log
  67453. */
  67454. static readonly NoneLogLevel: number;
  67455. /**
  67456. * Only message logs
  67457. */
  67458. static readonly MessageLogLevel: number;
  67459. /**
  67460. * Only warning logs
  67461. */
  67462. static readonly WarningLogLevel: number;
  67463. /**
  67464. * Only error logs
  67465. */
  67466. static readonly ErrorLogLevel: number;
  67467. /**
  67468. * All logs
  67469. */
  67470. static readonly AllLogLevel: number;
  67471. private static _LogCache;
  67472. /**
  67473. * Gets a value indicating the number of loading errors
  67474. * @ignorenaming
  67475. */
  67476. static errorsCount: number;
  67477. /**
  67478. * Callback called when a new log is added
  67479. */
  67480. static OnNewCacheEntry: (entry: string) => void;
  67481. private static _AddLogEntry;
  67482. private static _FormatMessage;
  67483. private static _LogDisabled;
  67484. private static _LogEnabled;
  67485. private static _WarnDisabled;
  67486. private static _WarnEnabled;
  67487. private static _ErrorDisabled;
  67488. private static _ErrorEnabled;
  67489. /**
  67490. * Log a message to the console
  67491. */
  67492. static Log: (message: string) => void;
  67493. /**
  67494. * Write a warning message to the console
  67495. */
  67496. static Warn: (message: string) => void;
  67497. /**
  67498. * Write an error message to the console
  67499. */
  67500. static Error: (message: string) => void;
  67501. /**
  67502. * Gets current log cache (list of logs)
  67503. */
  67504. static readonly LogCache: string;
  67505. /**
  67506. * Clears the log cache
  67507. */
  67508. static ClearLogCache(): void;
  67509. /**
  67510. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  67511. */
  67512. static LogLevels: number;
  67513. }
  67514. }
  67515. declare module BABYLON {
  67516. /** @hidden */
  67517. export class _TypeStore {
  67518. /** @hidden */
  67519. static RegisteredTypes: {
  67520. [key: string]: Object;
  67521. };
  67522. /** @hidden */
  67523. static GetClass(fqdn: string): any;
  67524. }
  67525. }
  67526. declare module BABYLON {
  67527. /**
  67528. * Class containing a set of static utilities functions for deep copy.
  67529. */
  67530. export class DeepCopier {
  67531. /**
  67532. * Tries to copy an object by duplicating every property
  67533. * @param source defines the source object
  67534. * @param destination defines the target object
  67535. * @param doNotCopyList defines a list of properties to avoid
  67536. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  67537. */
  67538. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  67539. }
  67540. }
  67541. declare module BABYLON {
  67542. /**
  67543. * Class containing a set of static utilities functions for precision date
  67544. */
  67545. export class PrecisionDate {
  67546. /**
  67547. * Gets either window.performance.now() if supported or Date.now() else
  67548. */
  67549. static readonly Now: number;
  67550. }
  67551. }
  67552. declare module BABYLON {
  67553. /** @hidden */
  67554. export class _DevTools {
  67555. static WarnImport(name: string): string;
  67556. }
  67557. }
  67558. declare module BABYLON {
  67559. /**
  67560. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  67561. */
  67562. export class WebRequest {
  67563. private _xhr;
  67564. /**
  67565. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  67566. * i.e. when loading files, where the server/service expects an Authorization header
  67567. */
  67568. static CustomRequestHeaders: {
  67569. [key: string]: string;
  67570. };
  67571. /**
  67572. * Add callback functions in this array to update all the requests before they get sent to the network
  67573. */
  67574. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  67575. private _injectCustomRequestHeaders;
  67576. /**
  67577. * Gets or sets a function to be called when loading progress changes
  67578. */
  67579. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  67580. /**
  67581. * Returns client's state
  67582. */
  67583. readonly readyState: number;
  67584. /**
  67585. * Returns client's status
  67586. */
  67587. readonly status: number;
  67588. /**
  67589. * Returns client's status as a text
  67590. */
  67591. readonly statusText: string;
  67592. /**
  67593. * Returns client's response
  67594. */
  67595. readonly response: any;
  67596. /**
  67597. * Returns client's response url
  67598. */
  67599. readonly responseURL: string;
  67600. /**
  67601. * Returns client's response as text
  67602. */
  67603. readonly responseText: string;
  67604. /**
  67605. * Gets or sets the expected response type
  67606. */
  67607. responseType: XMLHttpRequestResponseType;
  67608. /** @hidden */
  67609. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  67610. /** @hidden */
  67611. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  67612. /**
  67613. * Cancels any network activity
  67614. */
  67615. abort(): void;
  67616. /**
  67617. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  67618. * @param body defines an optional request body
  67619. */
  67620. send(body?: Document | BodyInit | null): void;
  67621. /**
  67622. * Sets the request method, request URL
  67623. * @param method defines the method to use (GET, POST, etc..)
  67624. * @param url defines the url to connect with
  67625. */
  67626. open(method: string, url: string): void;
  67627. }
  67628. }
  67629. declare module BABYLON {
  67630. /**
  67631. * Class used to evalaute queries containing `and` and `or` operators
  67632. */
  67633. export class AndOrNotEvaluator {
  67634. /**
  67635. * Evaluate a query
  67636. * @param query defines the query to evaluate
  67637. * @param evaluateCallback defines the callback used to filter result
  67638. * @returns true if the query matches
  67639. */
  67640. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  67641. private static _HandleParenthesisContent;
  67642. private static _SimplifyNegation;
  67643. }
  67644. }
  67645. declare module BABYLON {
  67646. /**
  67647. * Class used to store custom tags
  67648. */
  67649. export class Tags {
  67650. /**
  67651. * Adds support for tags on the given object
  67652. * @param obj defines the object to use
  67653. */
  67654. static EnableFor(obj: any): void;
  67655. /**
  67656. * Removes tags support
  67657. * @param obj defines the object to use
  67658. */
  67659. static DisableFor(obj: any): void;
  67660. /**
  67661. * Gets a boolean indicating if the given object has tags
  67662. * @param obj defines the object to use
  67663. * @returns a boolean
  67664. */
  67665. static HasTags(obj: any): boolean;
  67666. /**
  67667. * Gets the tags available on a given object
  67668. * @param obj defines the object to use
  67669. * @param asString defines if the tags must be returned as a string instead of an array of strings
  67670. * @returns the tags
  67671. */
  67672. static GetTags(obj: any, asString?: boolean): any;
  67673. /**
  67674. * Adds tags to an object
  67675. * @param obj defines the object to use
  67676. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  67677. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  67678. */
  67679. static AddTagsTo(obj: any, tagsString: string): void;
  67680. /**
  67681. * @hidden
  67682. */
  67683. static _AddTagTo(obj: any, tag: string): void;
  67684. /**
  67685. * Removes specific tags from a specific object
  67686. * @param obj defines the object to use
  67687. * @param tagsString defines the tags to remove
  67688. */
  67689. static RemoveTagsFrom(obj: any, tagsString: string): void;
  67690. /**
  67691. * @hidden
  67692. */
  67693. static _RemoveTagFrom(obj: any, tag: string): void;
  67694. /**
  67695. * Defines if tags hosted on an object match a given query
  67696. * @param obj defines the object to use
  67697. * @param tagsQuery defines the tag query
  67698. * @returns a boolean
  67699. */
  67700. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  67701. }
  67702. }
  67703. declare module BABYLON {
  67704. /**
  67705. * Manages the defines for the Material
  67706. */
  67707. export class MaterialDefines {
  67708. /** @hidden */
  67709. protected _keys: string[];
  67710. private _isDirty;
  67711. /** @hidden */
  67712. _renderId: number;
  67713. /** @hidden */
  67714. _areLightsDirty: boolean;
  67715. /** @hidden */
  67716. _areAttributesDirty: boolean;
  67717. /** @hidden */
  67718. _areTexturesDirty: boolean;
  67719. /** @hidden */
  67720. _areFresnelDirty: boolean;
  67721. /** @hidden */
  67722. _areMiscDirty: boolean;
  67723. /** @hidden */
  67724. _areImageProcessingDirty: boolean;
  67725. /** @hidden */
  67726. _normals: boolean;
  67727. /** @hidden */
  67728. _uvs: boolean;
  67729. /** @hidden */
  67730. _needNormals: boolean;
  67731. /** @hidden */
  67732. _needUVs: boolean;
  67733. [id: string]: any;
  67734. /**
  67735. * Specifies if the material needs to be re-calculated
  67736. */
  67737. readonly isDirty: boolean;
  67738. /**
  67739. * Marks the material to indicate that it has been re-calculated
  67740. */
  67741. markAsProcessed(): void;
  67742. /**
  67743. * Marks the material to indicate that it needs to be re-calculated
  67744. */
  67745. markAsUnprocessed(): void;
  67746. /**
  67747. * Marks the material to indicate all of its defines need to be re-calculated
  67748. */
  67749. markAllAsDirty(): void;
  67750. /**
  67751. * Marks the material to indicate that image processing needs to be re-calculated
  67752. */
  67753. markAsImageProcessingDirty(): void;
  67754. /**
  67755. * Marks the material to indicate the lights need to be re-calculated
  67756. */
  67757. markAsLightDirty(): void;
  67758. /**
  67759. * Marks the attribute state as changed
  67760. */
  67761. markAsAttributesDirty(): void;
  67762. /**
  67763. * Marks the texture state as changed
  67764. */
  67765. markAsTexturesDirty(): void;
  67766. /**
  67767. * Marks the fresnel state as changed
  67768. */
  67769. markAsFresnelDirty(): void;
  67770. /**
  67771. * Marks the misc state as changed
  67772. */
  67773. markAsMiscDirty(): void;
  67774. /**
  67775. * Rebuilds the material defines
  67776. */
  67777. rebuild(): void;
  67778. /**
  67779. * Specifies if two material defines are equal
  67780. * @param other - A material define instance to compare to
  67781. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  67782. */
  67783. isEqual(other: MaterialDefines): boolean;
  67784. /**
  67785. * Clones this instance's defines to another instance
  67786. * @param other - material defines to clone values to
  67787. */
  67788. cloneTo(other: MaterialDefines): void;
  67789. /**
  67790. * Resets the material define values
  67791. */
  67792. reset(): void;
  67793. /**
  67794. * Converts the material define values to a string
  67795. * @returns - String of material define information
  67796. */
  67797. toString(): string;
  67798. }
  67799. }
  67800. declare module BABYLON {
  67801. /**
  67802. * Class used to store and describe the pipeline context associated with an effect
  67803. */
  67804. export interface IPipelineContext {
  67805. /**
  67806. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  67807. */
  67808. isAsync: boolean;
  67809. /**
  67810. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  67811. */
  67812. isReady: boolean;
  67813. /** @hidden */
  67814. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  67815. }
  67816. }
  67817. declare module BABYLON {
  67818. /**
  67819. * Class used to store gfx data (like WebGLBuffer)
  67820. */
  67821. export class DataBuffer {
  67822. /**
  67823. * Gets or sets the number of objects referencing this buffer
  67824. */
  67825. references: number;
  67826. /** Gets or sets the size of the underlying buffer */
  67827. capacity: number;
  67828. /**
  67829. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  67830. */
  67831. is32Bits: boolean;
  67832. /**
  67833. * Gets the underlying buffer
  67834. */
  67835. readonly underlyingResource: any;
  67836. }
  67837. }
  67838. declare module BABYLON {
  67839. /** @hidden */
  67840. export interface IShaderProcessor {
  67841. attributeProcessor?: (attribute: string) => string;
  67842. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  67843. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  67844. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  67845. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  67846. lineProcessor?: (line: string, isFragment: boolean) => string;
  67847. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  67848. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  67849. }
  67850. }
  67851. declare module BABYLON {
  67852. /** @hidden */
  67853. export interface ProcessingOptions {
  67854. defines: string[];
  67855. indexParameters: any;
  67856. isFragment: boolean;
  67857. shouldUseHighPrecisionShader: boolean;
  67858. supportsUniformBuffers: boolean;
  67859. shadersRepository: string;
  67860. includesShadersStore: {
  67861. [key: string]: string;
  67862. };
  67863. processor?: IShaderProcessor;
  67864. version: string;
  67865. platformName: string;
  67866. lookForClosingBracketForUniformBuffer?: boolean;
  67867. }
  67868. }
  67869. declare module BABYLON {
  67870. /** @hidden */
  67871. export class ShaderCodeNode {
  67872. line: string;
  67873. children: ShaderCodeNode[];
  67874. additionalDefineKey?: string;
  67875. additionalDefineValue?: string;
  67876. isValid(preprocessors: {
  67877. [key: string]: string;
  67878. }): boolean;
  67879. process(preprocessors: {
  67880. [key: string]: string;
  67881. }, options: ProcessingOptions): string;
  67882. }
  67883. }
  67884. declare module BABYLON {
  67885. /** @hidden */
  67886. export class ShaderCodeCursor {
  67887. private _lines;
  67888. lineIndex: number;
  67889. readonly currentLine: string;
  67890. readonly canRead: boolean;
  67891. lines: string[];
  67892. }
  67893. }
  67894. declare module BABYLON {
  67895. /** @hidden */
  67896. export class ShaderCodeConditionNode extends ShaderCodeNode {
  67897. process(preprocessors: {
  67898. [key: string]: string;
  67899. }, options: ProcessingOptions): string;
  67900. }
  67901. }
  67902. declare module BABYLON {
  67903. /** @hidden */
  67904. export class ShaderDefineExpression {
  67905. isTrue(preprocessors: {
  67906. [key: string]: string;
  67907. }): boolean;
  67908. }
  67909. }
  67910. declare module BABYLON {
  67911. /** @hidden */
  67912. export class ShaderCodeTestNode extends ShaderCodeNode {
  67913. testExpression: ShaderDefineExpression;
  67914. isValid(preprocessors: {
  67915. [key: string]: string;
  67916. }): boolean;
  67917. }
  67918. }
  67919. declare module BABYLON {
  67920. /** @hidden */
  67921. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  67922. define: string;
  67923. not: boolean;
  67924. constructor(define: string, not?: boolean);
  67925. isTrue(preprocessors: {
  67926. [key: string]: string;
  67927. }): boolean;
  67928. }
  67929. }
  67930. declare module BABYLON {
  67931. /** @hidden */
  67932. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  67933. leftOperand: ShaderDefineExpression;
  67934. rightOperand: ShaderDefineExpression;
  67935. isTrue(preprocessors: {
  67936. [key: string]: string;
  67937. }): boolean;
  67938. }
  67939. }
  67940. declare module BABYLON {
  67941. /** @hidden */
  67942. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  67943. leftOperand: ShaderDefineExpression;
  67944. rightOperand: ShaderDefineExpression;
  67945. isTrue(preprocessors: {
  67946. [key: string]: string;
  67947. }): boolean;
  67948. }
  67949. }
  67950. declare module BABYLON {
  67951. /** @hidden */
  67952. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  67953. define: string;
  67954. operand: string;
  67955. testValue: string;
  67956. constructor(define: string, operand: string, testValue: string);
  67957. isTrue(preprocessors: {
  67958. [key: string]: string;
  67959. }): boolean;
  67960. }
  67961. }
  67962. declare module BABYLON {
  67963. /** @hidden */
  67964. export class ShaderProcessor {
  67965. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  67966. private static _ProcessPrecision;
  67967. private static _ExtractOperation;
  67968. private static _BuildSubExpression;
  67969. private static _BuildExpression;
  67970. private static _MoveCursorWithinIf;
  67971. private static _MoveCursor;
  67972. private static _EvaluatePreProcessors;
  67973. private static _PreparePreProcessors;
  67974. private static _ProcessShaderConversion;
  67975. private static _ProcessIncludes;
  67976. }
  67977. }
  67978. declare module BABYLON {
  67979. /**
  67980. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  67981. */
  67982. export class PerformanceMonitor {
  67983. private _enabled;
  67984. private _rollingFrameTime;
  67985. private _lastFrameTimeMs;
  67986. /**
  67987. * constructor
  67988. * @param frameSampleSize The number of samples required to saturate the sliding window
  67989. */
  67990. constructor(frameSampleSize?: number);
  67991. /**
  67992. * Samples current frame
  67993. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  67994. */
  67995. sampleFrame(timeMs?: number): void;
  67996. /**
  67997. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  67998. */
  67999. readonly averageFrameTime: number;
  68000. /**
  68001. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  68002. */
  68003. readonly averageFrameTimeVariance: number;
  68004. /**
  68005. * Returns the frame time of the most recent frame
  68006. */
  68007. readonly instantaneousFrameTime: number;
  68008. /**
  68009. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  68010. */
  68011. readonly averageFPS: number;
  68012. /**
  68013. * Returns the average framerate in frames per second using the most recent frame time
  68014. */
  68015. readonly instantaneousFPS: number;
  68016. /**
  68017. * Returns true if enough samples have been taken to completely fill the sliding window
  68018. */
  68019. readonly isSaturated: boolean;
  68020. /**
  68021. * Enables contributions to the sliding window sample set
  68022. */
  68023. enable(): void;
  68024. /**
  68025. * Disables contributions to the sliding window sample set
  68026. * Samples will not be interpolated over the disabled period
  68027. */
  68028. disable(): void;
  68029. /**
  68030. * Returns true if sampling is enabled
  68031. */
  68032. readonly isEnabled: boolean;
  68033. /**
  68034. * Resets performance monitor
  68035. */
  68036. reset(): void;
  68037. }
  68038. /**
  68039. * RollingAverage
  68040. *
  68041. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  68042. */
  68043. export class RollingAverage {
  68044. /**
  68045. * Current average
  68046. */
  68047. average: number;
  68048. /**
  68049. * Current variance
  68050. */
  68051. variance: number;
  68052. protected _samples: Array<number>;
  68053. protected _sampleCount: number;
  68054. protected _pos: number;
  68055. protected _m2: number;
  68056. /**
  68057. * constructor
  68058. * @param length The number of samples required to saturate the sliding window
  68059. */
  68060. constructor(length: number);
  68061. /**
  68062. * Adds a sample to the sample set
  68063. * @param v The sample value
  68064. */
  68065. add(v: number): void;
  68066. /**
  68067. * Returns previously added values or null if outside of history or outside the sliding window domain
  68068. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  68069. * @return Value previously recorded with add() or null if outside of range
  68070. */
  68071. history(i: number): number;
  68072. /**
  68073. * Returns true if enough samples have been taken to completely fill the sliding window
  68074. * @return true if sample-set saturated
  68075. */
  68076. isSaturated(): boolean;
  68077. /**
  68078. * Resets the rolling average (equivalent to 0 samples taken so far)
  68079. */
  68080. reset(): void;
  68081. /**
  68082. * Wraps a value around the sample range boundaries
  68083. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  68084. * @return Wrapped position in sample range
  68085. */
  68086. protected _wrapPosition(i: number): number;
  68087. }
  68088. }
  68089. declare module BABYLON {
  68090. /**
  68091. * This class implement a typical dictionary using a string as key and the generic type T as value.
  68092. * The underlying implementation relies on an associative array to ensure the best performances.
  68093. * The value can be anything including 'null' but except 'undefined'
  68094. */
  68095. export class StringDictionary<T> {
  68096. /**
  68097. * This will clear this dictionary and copy the content from the 'source' one.
  68098. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  68099. * @param source the dictionary to take the content from and copy to this dictionary
  68100. */
  68101. copyFrom(source: StringDictionary<T>): void;
  68102. /**
  68103. * Get a value based from its key
  68104. * @param key the given key to get the matching value from
  68105. * @return the value if found, otherwise undefined is returned
  68106. */
  68107. get(key: string): T | undefined;
  68108. /**
  68109. * Get a value from its key or add it if it doesn't exist.
  68110. * This method will ensure you that a given key/data will be present in the dictionary.
  68111. * @param key the given key to get the matching value from
  68112. * @param factory the factory that will create the value if the key is not present in the dictionary.
  68113. * The factory will only be invoked if there's no data for the given key.
  68114. * @return the value corresponding to the key.
  68115. */
  68116. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  68117. /**
  68118. * Get a value from its key if present in the dictionary otherwise add it
  68119. * @param key the key to get the value from
  68120. * @param val if there's no such key/value pair in the dictionary add it with this value
  68121. * @return the value corresponding to the key
  68122. */
  68123. getOrAdd(key: string, val: T): T;
  68124. /**
  68125. * Check if there's a given key in the dictionary
  68126. * @param key the key to check for
  68127. * @return true if the key is present, false otherwise
  68128. */
  68129. contains(key: string): boolean;
  68130. /**
  68131. * Add a new key and its corresponding value
  68132. * @param key the key to add
  68133. * @param value the value corresponding to the key
  68134. * @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
  68135. */
  68136. add(key: string, value: T): boolean;
  68137. /**
  68138. * Update a specific value associated to a key
  68139. * @param key defines the key to use
  68140. * @param value defines the value to store
  68141. * @returns true if the value was updated (or false if the key was not found)
  68142. */
  68143. set(key: string, value: T): boolean;
  68144. /**
  68145. * Get the element of the given key and remove it from the dictionary
  68146. * @param key defines the key to search
  68147. * @returns the value associated with the key or null if not found
  68148. */
  68149. getAndRemove(key: string): Nullable<T>;
  68150. /**
  68151. * Remove a key/value from the dictionary.
  68152. * @param key the key to remove
  68153. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  68154. */
  68155. remove(key: string): boolean;
  68156. /**
  68157. * Clear the whole content of the dictionary
  68158. */
  68159. clear(): void;
  68160. /**
  68161. * Gets the current count
  68162. */
  68163. readonly count: number;
  68164. /**
  68165. * Execute a callback on each key/val of the dictionary.
  68166. * Note that you can remove any element in this dictionary in the callback implementation
  68167. * @param callback the callback to execute on a given key/value pair
  68168. */
  68169. forEach(callback: (key: string, val: T) => void): void;
  68170. /**
  68171. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  68172. * If the callback returns null or undefined the method will iterate to the next key/value pair
  68173. * Note that you can remove any element in this dictionary in the callback implementation
  68174. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  68175. * @returns the first item
  68176. */
  68177. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  68178. private _count;
  68179. private _data;
  68180. }
  68181. }
  68182. declare module BABYLON {
  68183. /**
  68184. * Helper class that provides a small promise polyfill
  68185. */
  68186. export class PromisePolyfill {
  68187. /**
  68188. * Static function used to check if the polyfill is required
  68189. * If this is the case then the function will inject the polyfill to window.Promise
  68190. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  68191. */
  68192. static Apply(force?: boolean): void;
  68193. }
  68194. }
  68195. declare module BABYLON {
  68196. /**
  68197. * Class used to store data that will be store in GPU memory
  68198. */
  68199. export class Buffer {
  68200. private _engine;
  68201. private _buffer;
  68202. /** @hidden */
  68203. _data: Nullable<DataArray>;
  68204. private _updatable;
  68205. private _instanced;
  68206. /**
  68207. * Gets the byte stride.
  68208. */
  68209. readonly byteStride: number;
  68210. /**
  68211. * Constructor
  68212. * @param engine the engine
  68213. * @param data the data to use for this buffer
  68214. * @param updatable whether the data is updatable
  68215. * @param stride the stride (optional)
  68216. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  68217. * @param instanced whether the buffer is instanced (optional)
  68218. * @param useBytes set to true if the stride in in bytes (optional)
  68219. */
  68220. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  68221. /**
  68222. * Create a new VertexBuffer based on the current buffer
  68223. * @param kind defines the vertex buffer kind (position, normal, etc.)
  68224. * @param offset defines offset in the buffer (0 by default)
  68225. * @param size defines the size in floats of attributes (position is 3 for instance)
  68226. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  68227. * @param instanced defines if the vertex buffer contains indexed data
  68228. * @param useBytes defines if the offset and stride are in bytes
  68229. * @returns the new vertex buffer
  68230. */
  68231. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  68232. /**
  68233. * Gets a boolean indicating if the Buffer is updatable?
  68234. * @returns true if the buffer is updatable
  68235. */
  68236. isUpdatable(): boolean;
  68237. /**
  68238. * Gets current buffer's data
  68239. * @returns a DataArray or null
  68240. */
  68241. getData(): Nullable<DataArray>;
  68242. /**
  68243. * Gets underlying native buffer
  68244. * @returns underlying native buffer
  68245. */
  68246. getBuffer(): Nullable<DataBuffer>;
  68247. /**
  68248. * Gets the stride in float32 units (i.e. byte stride / 4).
  68249. * May not be an integer if the byte stride is not divisible by 4.
  68250. * DEPRECATED. Use byteStride instead.
  68251. * @returns the stride in float32 units
  68252. */
  68253. getStrideSize(): number;
  68254. /**
  68255. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  68256. * @param data defines the data to store
  68257. */
  68258. create(data?: Nullable<DataArray>): void;
  68259. /** @hidden */
  68260. _rebuild(): void;
  68261. /**
  68262. * Update current buffer data
  68263. * @param data defines the data to store
  68264. */
  68265. update(data: DataArray): void;
  68266. /**
  68267. * Updates the data directly.
  68268. * @param data the new data
  68269. * @param offset the new offset
  68270. * @param vertexCount the vertex count (optional)
  68271. * @param useBytes set to true if the offset is in bytes
  68272. */
  68273. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  68274. /**
  68275. * Release all resources
  68276. */
  68277. dispose(): void;
  68278. }
  68279. /**
  68280. * Specialized buffer used to store vertex data
  68281. */
  68282. export class VertexBuffer {
  68283. /** @hidden */
  68284. _buffer: Buffer;
  68285. private _kind;
  68286. private _size;
  68287. private _ownsBuffer;
  68288. private _instanced;
  68289. private _instanceDivisor;
  68290. /**
  68291. * The byte type.
  68292. */
  68293. static readonly BYTE: number;
  68294. /**
  68295. * The unsigned byte type.
  68296. */
  68297. static readonly UNSIGNED_BYTE: number;
  68298. /**
  68299. * The short type.
  68300. */
  68301. static readonly SHORT: number;
  68302. /**
  68303. * The unsigned short type.
  68304. */
  68305. static readonly UNSIGNED_SHORT: number;
  68306. /**
  68307. * The integer type.
  68308. */
  68309. static readonly INT: number;
  68310. /**
  68311. * The unsigned integer type.
  68312. */
  68313. static readonly UNSIGNED_INT: number;
  68314. /**
  68315. * The float type.
  68316. */
  68317. static readonly FLOAT: number;
  68318. /**
  68319. * Gets or sets the instance divisor when in instanced mode
  68320. */
  68321. instanceDivisor: number;
  68322. /**
  68323. * Gets the byte stride.
  68324. */
  68325. readonly byteStride: number;
  68326. /**
  68327. * Gets the byte offset.
  68328. */
  68329. readonly byteOffset: number;
  68330. /**
  68331. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  68332. */
  68333. readonly normalized: boolean;
  68334. /**
  68335. * Gets the data type of each component in the array.
  68336. */
  68337. readonly type: number;
  68338. /**
  68339. * Constructor
  68340. * @param engine the engine
  68341. * @param data the data to use for this vertex buffer
  68342. * @param kind the vertex buffer kind
  68343. * @param updatable whether the data is updatable
  68344. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  68345. * @param stride the stride (optional)
  68346. * @param instanced whether the buffer is instanced (optional)
  68347. * @param offset the offset of the data (optional)
  68348. * @param size the number of components (optional)
  68349. * @param type the type of the component (optional)
  68350. * @param normalized whether the data contains normalized data (optional)
  68351. * @param useBytes set to true if stride and offset are in bytes (optional)
  68352. */
  68353. 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);
  68354. /** @hidden */
  68355. _rebuild(): void;
  68356. /**
  68357. * Returns the kind of the VertexBuffer (string)
  68358. * @returns a string
  68359. */
  68360. getKind(): string;
  68361. /**
  68362. * Gets a boolean indicating if the VertexBuffer is updatable?
  68363. * @returns true if the buffer is updatable
  68364. */
  68365. isUpdatable(): boolean;
  68366. /**
  68367. * Gets current buffer's data
  68368. * @returns a DataArray or null
  68369. */
  68370. getData(): Nullable<DataArray>;
  68371. /**
  68372. * Gets underlying native buffer
  68373. * @returns underlying native buffer
  68374. */
  68375. getBuffer(): Nullable<DataBuffer>;
  68376. /**
  68377. * Gets the stride in float32 units (i.e. byte stride / 4).
  68378. * May not be an integer if the byte stride is not divisible by 4.
  68379. * DEPRECATED. Use byteStride instead.
  68380. * @returns the stride in float32 units
  68381. */
  68382. getStrideSize(): number;
  68383. /**
  68384. * Returns the offset as a multiple of the type byte length.
  68385. * DEPRECATED. Use byteOffset instead.
  68386. * @returns the offset in bytes
  68387. */
  68388. getOffset(): number;
  68389. /**
  68390. * Returns the number of components per vertex attribute (integer)
  68391. * @returns the size in float
  68392. */
  68393. getSize(): number;
  68394. /**
  68395. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  68396. * @returns true if this buffer is instanced
  68397. */
  68398. getIsInstanced(): boolean;
  68399. /**
  68400. * Returns the instancing divisor, zero for non-instanced (integer).
  68401. * @returns a number
  68402. */
  68403. getInstanceDivisor(): number;
  68404. /**
  68405. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  68406. * @param data defines the data to store
  68407. */
  68408. create(data?: DataArray): void;
  68409. /**
  68410. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  68411. * This function will create a new buffer if the current one is not updatable
  68412. * @param data defines the data to store
  68413. */
  68414. update(data: DataArray): void;
  68415. /**
  68416. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  68417. * Returns the directly updated WebGLBuffer.
  68418. * @param data the new data
  68419. * @param offset the new offset
  68420. * @param useBytes set to true if the offset is in bytes
  68421. */
  68422. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  68423. /**
  68424. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  68425. */
  68426. dispose(): void;
  68427. /**
  68428. * Enumerates each value of this vertex buffer as numbers.
  68429. * @param count the number of values to enumerate
  68430. * @param callback the callback function called for each value
  68431. */
  68432. forEach(count: number, callback: (value: number, index: number) => void): void;
  68433. /**
  68434. * Positions
  68435. */
  68436. static readonly PositionKind: string;
  68437. /**
  68438. * Normals
  68439. */
  68440. static readonly NormalKind: string;
  68441. /**
  68442. * Tangents
  68443. */
  68444. static readonly TangentKind: string;
  68445. /**
  68446. * Texture coordinates
  68447. */
  68448. static readonly UVKind: string;
  68449. /**
  68450. * Texture coordinates 2
  68451. */
  68452. static readonly UV2Kind: string;
  68453. /**
  68454. * Texture coordinates 3
  68455. */
  68456. static readonly UV3Kind: string;
  68457. /**
  68458. * Texture coordinates 4
  68459. */
  68460. static readonly UV4Kind: string;
  68461. /**
  68462. * Texture coordinates 5
  68463. */
  68464. static readonly UV5Kind: string;
  68465. /**
  68466. * Texture coordinates 6
  68467. */
  68468. static readonly UV6Kind: string;
  68469. /**
  68470. * Colors
  68471. */
  68472. static readonly ColorKind: string;
  68473. /**
  68474. * Matrix indices (for bones)
  68475. */
  68476. static readonly MatricesIndicesKind: string;
  68477. /**
  68478. * Matrix weights (for bones)
  68479. */
  68480. static readonly MatricesWeightsKind: string;
  68481. /**
  68482. * Additional matrix indices (for bones)
  68483. */
  68484. static readonly MatricesIndicesExtraKind: string;
  68485. /**
  68486. * Additional matrix weights (for bones)
  68487. */
  68488. static readonly MatricesWeightsExtraKind: string;
  68489. /**
  68490. * Deduces the stride given a kind.
  68491. * @param kind The kind string to deduce
  68492. * @returns The deduced stride
  68493. */
  68494. static DeduceStride(kind: string): number;
  68495. /**
  68496. * Gets the byte length of the given type.
  68497. * @param type the type
  68498. * @returns the number of bytes
  68499. */
  68500. static GetTypeByteLength(type: number): number;
  68501. /**
  68502. * Enumerates each value of the given parameters as numbers.
  68503. * @param data the data to enumerate
  68504. * @param byteOffset the byte offset of the data
  68505. * @param byteStride the byte stride of the data
  68506. * @param componentCount the number of components per element
  68507. * @param componentType the type of the component
  68508. * @param count the number of values to enumerate
  68509. * @param normalized whether the data is normalized
  68510. * @param callback the callback function called for each value
  68511. */
  68512. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  68513. private static _GetFloatValue;
  68514. }
  68515. }
  68516. declare module BABYLON {
  68517. /**
  68518. * Class representing spherical harmonics coefficients to the 3rd degree
  68519. */
  68520. export class SphericalHarmonics {
  68521. /**
  68522. * Defines whether or not the harmonics have been prescaled for rendering.
  68523. */
  68524. preScaled: boolean;
  68525. /**
  68526. * The l0,0 coefficients of the spherical harmonics
  68527. */
  68528. l00: Vector3;
  68529. /**
  68530. * The l1,-1 coefficients of the spherical harmonics
  68531. */
  68532. l1_1: Vector3;
  68533. /**
  68534. * The l1,0 coefficients of the spherical harmonics
  68535. */
  68536. l10: Vector3;
  68537. /**
  68538. * The l1,1 coefficients of the spherical harmonics
  68539. */
  68540. l11: Vector3;
  68541. /**
  68542. * The l2,-2 coefficients of the spherical harmonics
  68543. */
  68544. l2_2: Vector3;
  68545. /**
  68546. * The l2,-1 coefficients of the spherical harmonics
  68547. */
  68548. l2_1: Vector3;
  68549. /**
  68550. * The l2,0 coefficients of the spherical harmonics
  68551. */
  68552. l20: Vector3;
  68553. /**
  68554. * The l2,1 coefficients of the spherical harmonics
  68555. */
  68556. l21: Vector3;
  68557. /**
  68558. * The l2,2 coefficients of the spherical harmonics
  68559. */
  68560. l22: Vector3;
  68561. /**
  68562. * Adds a light to the spherical harmonics
  68563. * @param direction the direction of the light
  68564. * @param color the color of the light
  68565. * @param deltaSolidAngle the delta solid angle of the light
  68566. */
  68567. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  68568. /**
  68569. * Scales the spherical harmonics by the given amount
  68570. * @param scale the amount to scale
  68571. */
  68572. scaleInPlace(scale: number): void;
  68573. /**
  68574. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  68575. *
  68576. * ```
  68577. * E_lm = A_l * L_lm
  68578. * ```
  68579. *
  68580. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  68581. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  68582. * the scaling factors are given in equation 9.
  68583. */
  68584. convertIncidentRadianceToIrradiance(): void;
  68585. /**
  68586. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  68587. *
  68588. * ```
  68589. * L = (1/pi) * E * rho
  68590. * ```
  68591. *
  68592. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  68593. */
  68594. convertIrradianceToLambertianRadiance(): void;
  68595. /**
  68596. * Integrates the reconstruction coefficients directly in to the SH preventing further
  68597. * required operations at run time.
  68598. *
  68599. * This is simply done by scaling back the SH with Ylm constants parameter.
  68600. * The trigonometric part being applied by the shader at run time.
  68601. */
  68602. preScaleForRendering(): void;
  68603. /**
  68604. * Constructs a spherical harmonics from an array.
  68605. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  68606. * @returns the spherical harmonics
  68607. */
  68608. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  68609. /**
  68610. * Gets the spherical harmonics from polynomial
  68611. * @param polynomial the spherical polynomial
  68612. * @returns the spherical harmonics
  68613. */
  68614. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  68615. }
  68616. /**
  68617. * Class representing spherical polynomial coefficients to the 3rd degree
  68618. */
  68619. export class SphericalPolynomial {
  68620. private _harmonics;
  68621. /**
  68622. * The spherical harmonics used to create the polynomials.
  68623. */
  68624. readonly preScaledHarmonics: SphericalHarmonics;
  68625. /**
  68626. * The x coefficients of the spherical polynomial
  68627. */
  68628. x: Vector3;
  68629. /**
  68630. * The y coefficients of the spherical polynomial
  68631. */
  68632. y: Vector3;
  68633. /**
  68634. * The z coefficients of the spherical polynomial
  68635. */
  68636. z: Vector3;
  68637. /**
  68638. * The xx coefficients of the spherical polynomial
  68639. */
  68640. xx: Vector3;
  68641. /**
  68642. * The yy coefficients of the spherical polynomial
  68643. */
  68644. yy: Vector3;
  68645. /**
  68646. * The zz coefficients of the spherical polynomial
  68647. */
  68648. zz: Vector3;
  68649. /**
  68650. * The xy coefficients of the spherical polynomial
  68651. */
  68652. xy: Vector3;
  68653. /**
  68654. * The yz coefficients of the spherical polynomial
  68655. */
  68656. yz: Vector3;
  68657. /**
  68658. * The zx coefficients of the spherical polynomial
  68659. */
  68660. zx: Vector3;
  68661. /**
  68662. * Adds an ambient color to the spherical polynomial
  68663. * @param color the color to add
  68664. */
  68665. addAmbient(color: Color3): void;
  68666. /**
  68667. * Scales the spherical polynomial by the given amount
  68668. * @param scale the amount to scale
  68669. */
  68670. scaleInPlace(scale: number): void;
  68671. /**
  68672. * Gets the spherical polynomial from harmonics
  68673. * @param harmonics the spherical harmonics
  68674. * @returns the spherical polynomial
  68675. */
  68676. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  68677. /**
  68678. * Constructs a spherical polynomial from an array.
  68679. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  68680. * @returns the spherical polynomial
  68681. */
  68682. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  68683. }
  68684. }
  68685. declare module BABYLON {
  68686. /**
  68687. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  68688. */
  68689. export interface CubeMapInfo {
  68690. /**
  68691. * The pixel array for the front face.
  68692. * This is stored in format, left to right, up to down format.
  68693. */
  68694. front: Nullable<ArrayBufferView>;
  68695. /**
  68696. * The pixel array for the back face.
  68697. * This is stored in format, left to right, up to down format.
  68698. */
  68699. back: Nullable<ArrayBufferView>;
  68700. /**
  68701. * The pixel array for the left face.
  68702. * This is stored in format, left to right, up to down format.
  68703. */
  68704. left: Nullable<ArrayBufferView>;
  68705. /**
  68706. * The pixel array for the right face.
  68707. * This is stored in format, left to right, up to down format.
  68708. */
  68709. right: Nullable<ArrayBufferView>;
  68710. /**
  68711. * The pixel array for the up face.
  68712. * This is stored in format, left to right, up to down format.
  68713. */
  68714. up: Nullable<ArrayBufferView>;
  68715. /**
  68716. * The pixel array for the down face.
  68717. * This is stored in format, left to right, up to down format.
  68718. */
  68719. down: Nullable<ArrayBufferView>;
  68720. /**
  68721. * The size of the cubemap stored.
  68722. *
  68723. * Each faces will be size * size pixels.
  68724. */
  68725. size: number;
  68726. /**
  68727. * The format of the texture.
  68728. *
  68729. * RGBA, RGB.
  68730. */
  68731. format: number;
  68732. /**
  68733. * The type of the texture data.
  68734. *
  68735. * UNSIGNED_INT, FLOAT.
  68736. */
  68737. type: number;
  68738. /**
  68739. * Specifies whether the texture is in gamma space.
  68740. */
  68741. gammaSpace: boolean;
  68742. }
  68743. /**
  68744. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  68745. */
  68746. export class PanoramaToCubeMapTools {
  68747. private static FACE_FRONT;
  68748. private static FACE_BACK;
  68749. private static FACE_RIGHT;
  68750. private static FACE_LEFT;
  68751. private static FACE_DOWN;
  68752. private static FACE_UP;
  68753. /**
  68754. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  68755. *
  68756. * @param float32Array The source data.
  68757. * @param inputWidth The width of the input panorama.
  68758. * @param inputHeight The height of the input panorama.
  68759. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  68760. * @return The cubemap data
  68761. */
  68762. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  68763. private static CreateCubemapTexture;
  68764. private static CalcProjectionSpherical;
  68765. }
  68766. }
  68767. declare module BABYLON {
  68768. /**
  68769. * Helper class dealing with the extraction of spherical polynomial dataArray
  68770. * from a cube map.
  68771. */
  68772. export class CubeMapToSphericalPolynomialTools {
  68773. private static FileFaces;
  68774. /**
  68775. * Converts a texture to the according Spherical Polynomial data.
  68776. * This extracts the first 3 orders only as they are the only one used in the lighting.
  68777. *
  68778. * @param texture The texture to extract the information from.
  68779. * @return The Spherical Polynomial data.
  68780. */
  68781. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  68782. /**
  68783. * Converts a cubemap to the according Spherical Polynomial data.
  68784. * This extracts the first 3 orders only as they are the only one used in the lighting.
  68785. *
  68786. * @param cubeInfo The Cube map to extract the information from.
  68787. * @return The Spherical Polynomial data.
  68788. */
  68789. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  68790. }
  68791. }
  68792. declare module BABYLON {
  68793. /**
  68794. * The engine store class is responsible to hold all the instances of Engine and Scene created
  68795. * during the life time of the application.
  68796. */
  68797. export class EngineStore {
  68798. /** Gets the list of created engines */
  68799. static Instances: Engine[];
  68800. /** @hidden */
  68801. static _LastCreatedScene: Nullable<Scene>;
  68802. /**
  68803. * Gets the latest created engine
  68804. */
  68805. static readonly LastCreatedEngine: Nullable<Engine>;
  68806. /**
  68807. * Gets the latest created scene
  68808. */
  68809. static readonly LastCreatedScene: Nullable<Scene>;
  68810. }
  68811. }
  68812. declare module BABYLON {
  68813. /**
  68814. * Define options used to create a render target texture
  68815. */
  68816. export class RenderTargetCreationOptions {
  68817. /**
  68818. * Specifies is mipmaps must be generated
  68819. */
  68820. generateMipMaps?: boolean;
  68821. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  68822. generateDepthBuffer?: boolean;
  68823. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  68824. generateStencilBuffer?: boolean;
  68825. /** Defines texture type (int by default) */
  68826. type?: number;
  68827. /** Defines sampling mode (trilinear by default) */
  68828. samplingMode?: number;
  68829. /** Defines format (RGBA by default) */
  68830. format?: number;
  68831. }
  68832. }
  68833. declare module BABYLON {
  68834. /**
  68835. * @hidden
  68836. **/
  68837. export class _AlphaState {
  68838. private _isAlphaBlendDirty;
  68839. private _isBlendFunctionParametersDirty;
  68840. private _isBlendEquationParametersDirty;
  68841. private _isBlendConstantsDirty;
  68842. private _alphaBlend;
  68843. private _blendFunctionParameters;
  68844. private _blendEquationParameters;
  68845. private _blendConstants;
  68846. /**
  68847. * Initializes the state.
  68848. */
  68849. constructor();
  68850. readonly isDirty: boolean;
  68851. alphaBlend: boolean;
  68852. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  68853. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  68854. setAlphaEquationParameters(rgb: number, alpha: number): void;
  68855. reset(): void;
  68856. apply(gl: WebGLRenderingContext): void;
  68857. }
  68858. }
  68859. declare module BABYLON {
  68860. /**
  68861. * @hidden
  68862. **/
  68863. export class _DepthCullingState {
  68864. private _isDepthTestDirty;
  68865. private _isDepthMaskDirty;
  68866. private _isDepthFuncDirty;
  68867. private _isCullFaceDirty;
  68868. private _isCullDirty;
  68869. private _isZOffsetDirty;
  68870. private _isFrontFaceDirty;
  68871. private _depthTest;
  68872. private _depthMask;
  68873. private _depthFunc;
  68874. private _cull;
  68875. private _cullFace;
  68876. private _zOffset;
  68877. private _frontFace;
  68878. /**
  68879. * Initializes the state.
  68880. */
  68881. constructor();
  68882. readonly isDirty: boolean;
  68883. zOffset: number;
  68884. cullFace: Nullable<number>;
  68885. cull: Nullable<boolean>;
  68886. depthFunc: Nullable<number>;
  68887. depthMask: boolean;
  68888. depthTest: boolean;
  68889. frontFace: Nullable<number>;
  68890. reset(): void;
  68891. apply(gl: WebGLRenderingContext): void;
  68892. }
  68893. }
  68894. declare module BABYLON {
  68895. /**
  68896. * @hidden
  68897. **/
  68898. export class _StencilState {
  68899. /** 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 */
  68900. static readonly ALWAYS: number;
  68901. /** Passed to stencilOperation to specify that stencil value must be kept */
  68902. static readonly KEEP: number;
  68903. /** Passed to stencilOperation to specify that stencil value must be replaced */
  68904. static readonly REPLACE: number;
  68905. private _isStencilTestDirty;
  68906. private _isStencilMaskDirty;
  68907. private _isStencilFuncDirty;
  68908. private _isStencilOpDirty;
  68909. private _stencilTest;
  68910. private _stencilMask;
  68911. private _stencilFunc;
  68912. private _stencilFuncRef;
  68913. private _stencilFuncMask;
  68914. private _stencilOpStencilFail;
  68915. private _stencilOpDepthFail;
  68916. private _stencilOpStencilDepthPass;
  68917. readonly isDirty: boolean;
  68918. stencilFunc: number;
  68919. stencilFuncRef: number;
  68920. stencilFuncMask: number;
  68921. stencilOpStencilFail: number;
  68922. stencilOpDepthFail: number;
  68923. stencilOpStencilDepthPass: number;
  68924. stencilMask: number;
  68925. stencilTest: boolean;
  68926. constructor();
  68927. reset(): void;
  68928. apply(gl: WebGLRenderingContext): void;
  68929. }
  68930. }
  68931. declare module BABYLON {
  68932. /**
  68933. * @hidden
  68934. **/
  68935. export class _TimeToken {
  68936. _startTimeQuery: Nullable<WebGLQuery>;
  68937. _endTimeQuery: Nullable<WebGLQuery>;
  68938. _timeElapsedQuery: Nullable<WebGLQuery>;
  68939. _timeElapsedQueryEnded: boolean;
  68940. }
  68941. }
  68942. declare module BABYLON {
  68943. /**
  68944. * Class used to store data associated with WebGL texture data for the engine
  68945. * This class should not be used directly
  68946. */
  68947. export class InternalTexture {
  68948. /** @hidden */
  68949. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  68950. /**
  68951. * The source of the texture data is unknown
  68952. */
  68953. static DATASOURCE_UNKNOWN: number;
  68954. /**
  68955. * Texture data comes from an URL
  68956. */
  68957. static DATASOURCE_URL: number;
  68958. /**
  68959. * Texture data is only used for temporary storage
  68960. */
  68961. static DATASOURCE_TEMP: number;
  68962. /**
  68963. * Texture data comes from raw data (ArrayBuffer)
  68964. */
  68965. static DATASOURCE_RAW: number;
  68966. /**
  68967. * Texture content is dynamic (video or dynamic texture)
  68968. */
  68969. static DATASOURCE_DYNAMIC: number;
  68970. /**
  68971. * Texture content is generated by rendering to it
  68972. */
  68973. static DATASOURCE_RENDERTARGET: number;
  68974. /**
  68975. * Texture content is part of a multi render target process
  68976. */
  68977. static DATASOURCE_MULTIRENDERTARGET: number;
  68978. /**
  68979. * Texture data comes from a cube data file
  68980. */
  68981. static DATASOURCE_CUBE: number;
  68982. /**
  68983. * Texture data comes from a raw cube data
  68984. */
  68985. static DATASOURCE_CUBERAW: number;
  68986. /**
  68987. * Texture data come from a prefiltered cube data file
  68988. */
  68989. static DATASOURCE_CUBEPREFILTERED: number;
  68990. /**
  68991. * Texture content is raw 3D data
  68992. */
  68993. static DATASOURCE_RAW3D: number;
  68994. /**
  68995. * Texture content is a depth texture
  68996. */
  68997. static DATASOURCE_DEPTHTEXTURE: number;
  68998. /**
  68999. * Texture data comes from a raw cube data encoded with RGBD
  69000. */
  69001. static DATASOURCE_CUBERAW_RGBD: number;
  69002. /**
  69003. * Defines if the texture is ready
  69004. */
  69005. isReady: boolean;
  69006. /**
  69007. * Defines if the texture is a cube texture
  69008. */
  69009. isCube: boolean;
  69010. /**
  69011. * Defines if the texture contains 3D data
  69012. */
  69013. is3D: boolean;
  69014. /**
  69015. * Defines if the texture contains multiview data
  69016. */
  69017. isMultiview: boolean;
  69018. /**
  69019. * Gets the URL used to load this texture
  69020. */
  69021. url: string;
  69022. /**
  69023. * Gets the sampling mode of the texture
  69024. */
  69025. samplingMode: number;
  69026. /**
  69027. * Gets a boolean indicating if the texture needs mipmaps generation
  69028. */
  69029. generateMipMaps: boolean;
  69030. /**
  69031. * Gets the number of samples used by the texture (WebGL2+ only)
  69032. */
  69033. samples: number;
  69034. /**
  69035. * Gets the type of the texture (int, float...)
  69036. */
  69037. type: number;
  69038. /**
  69039. * Gets the format of the texture (RGB, RGBA...)
  69040. */
  69041. format: number;
  69042. /**
  69043. * Observable called when the texture is loaded
  69044. */
  69045. onLoadedObservable: Observable<InternalTexture>;
  69046. /**
  69047. * Gets the width of the texture
  69048. */
  69049. width: number;
  69050. /**
  69051. * Gets the height of the texture
  69052. */
  69053. height: number;
  69054. /**
  69055. * Gets the depth of the texture
  69056. */
  69057. depth: number;
  69058. /**
  69059. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  69060. */
  69061. baseWidth: number;
  69062. /**
  69063. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  69064. */
  69065. baseHeight: number;
  69066. /**
  69067. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  69068. */
  69069. baseDepth: number;
  69070. /**
  69071. * Gets a boolean indicating if the texture is inverted on Y axis
  69072. */
  69073. invertY: boolean;
  69074. /** @hidden */
  69075. _invertVScale: boolean;
  69076. /** @hidden */
  69077. _associatedChannel: number;
  69078. /** @hidden */
  69079. _dataSource: number;
  69080. /** @hidden */
  69081. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  69082. /** @hidden */
  69083. _bufferView: Nullable<ArrayBufferView>;
  69084. /** @hidden */
  69085. _bufferViewArray: Nullable<ArrayBufferView[]>;
  69086. /** @hidden */
  69087. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  69088. /** @hidden */
  69089. _size: number;
  69090. /** @hidden */
  69091. _extension: string;
  69092. /** @hidden */
  69093. _files: Nullable<string[]>;
  69094. /** @hidden */
  69095. _workingCanvas: Nullable<HTMLCanvasElement>;
  69096. /** @hidden */
  69097. _workingContext: Nullable<CanvasRenderingContext2D>;
  69098. /** @hidden */
  69099. _framebuffer: Nullable<WebGLFramebuffer>;
  69100. /** @hidden */
  69101. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  69102. /** @hidden */
  69103. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  69104. /** @hidden */
  69105. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  69106. /** @hidden */
  69107. _attachments: Nullable<number[]>;
  69108. /** @hidden */
  69109. _cachedCoordinatesMode: Nullable<number>;
  69110. /** @hidden */
  69111. _cachedWrapU: Nullable<number>;
  69112. /** @hidden */
  69113. _cachedWrapV: Nullable<number>;
  69114. /** @hidden */
  69115. _cachedWrapR: Nullable<number>;
  69116. /** @hidden */
  69117. _cachedAnisotropicFilteringLevel: Nullable<number>;
  69118. /** @hidden */
  69119. _isDisabled: boolean;
  69120. /** @hidden */
  69121. _compression: Nullable<string>;
  69122. /** @hidden */
  69123. _generateStencilBuffer: boolean;
  69124. /** @hidden */
  69125. _generateDepthBuffer: boolean;
  69126. /** @hidden */
  69127. _comparisonFunction: number;
  69128. /** @hidden */
  69129. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  69130. /** @hidden */
  69131. _lodGenerationScale: number;
  69132. /** @hidden */
  69133. _lodGenerationOffset: number;
  69134. /** @hidden */
  69135. _colorTextureArray: Nullable<WebGLTexture>;
  69136. /** @hidden */
  69137. _depthStencilTextureArray: Nullable<WebGLTexture>;
  69138. /** @hidden */
  69139. _lodTextureHigh: Nullable<BaseTexture>;
  69140. /** @hidden */
  69141. _lodTextureMid: Nullable<BaseTexture>;
  69142. /** @hidden */
  69143. _lodTextureLow: Nullable<BaseTexture>;
  69144. /** @hidden */
  69145. _isRGBD: boolean;
  69146. /** @hidden */
  69147. _linearSpecularLOD: boolean;
  69148. /** @hidden */
  69149. _irradianceTexture: Nullable<BaseTexture>;
  69150. /** @hidden */
  69151. _webGLTexture: Nullable<WebGLTexture>;
  69152. /** @hidden */
  69153. _references: number;
  69154. private _engine;
  69155. /**
  69156. * Gets the Engine the texture belongs to.
  69157. * @returns The babylon engine
  69158. */
  69159. getEngine(): Engine;
  69160. /**
  69161. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  69162. */
  69163. readonly dataSource: number;
  69164. /**
  69165. * Creates a new InternalTexture
  69166. * @param engine defines the engine to use
  69167. * @param dataSource defines the type of data that will be used
  69168. * @param delayAllocation if the texture allocation should be delayed (default: false)
  69169. */
  69170. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  69171. /**
  69172. * Increments the number of references (ie. the number of Texture that point to it)
  69173. */
  69174. incrementReferences(): void;
  69175. /**
  69176. * Change the size of the texture (not the size of the content)
  69177. * @param width defines the new width
  69178. * @param height defines the new height
  69179. * @param depth defines the new depth (1 by default)
  69180. */
  69181. updateSize(width: int, height: int, depth?: int): void;
  69182. /** @hidden */
  69183. _rebuild(): void;
  69184. /** @hidden */
  69185. _swapAndDie(target: InternalTexture): void;
  69186. /**
  69187. * Dispose the current allocated resources
  69188. */
  69189. dispose(): void;
  69190. }
  69191. }
  69192. declare module BABYLON {
  69193. /**
  69194. * This represents the main contract an easing function should follow.
  69195. * Easing functions are used throughout the animation system.
  69196. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69197. */
  69198. export interface IEasingFunction {
  69199. /**
  69200. * Given an input gradient between 0 and 1, this returns the corrseponding value
  69201. * of the easing function.
  69202. * The link below provides some of the most common examples of easing functions.
  69203. * @see https://easings.net/
  69204. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69205. * @returns the corresponding value on the curve defined by the easing function
  69206. */
  69207. ease(gradient: number): number;
  69208. }
  69209. /**
  69210. * Base class used for every default easing function.
  69211. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69212. */
  69213. export class EasingFunction implements IEasingFunction {
  69214. /**
  69215. * Interpolation follows the mathematical formula associated with the easing function.
  69216. */
  69217. static readonly EASINGMODE_EASEIN: number;
  69218. /**
  69219. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  69220. */
  69221. static readonly EASINGMODE_EASEOUT: number;
  69222. /**
  69223. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  69224. */
  69225. static readonly EASINGMODE_EASEINOUT: number;
  69226. private _easingMode;
  69227. /**
  69228. * Sets the easing mode of the current function.
  69229. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  69230. */
  69231. setEasingMode(easingMode: number): void;
  69232. /**
  69233. * Gets the current easing mode.
  69234. * @returns the easing mode
  69235. */
  69236. getEasingMode(): number;
  69237. /**
  69238. * @hidden
  69239. */
  69240. easeInCore(gradient: number): number;
  69241. /**
  69242. * Given an input gradient between 0 and 1, this returns the corresponding value
  69243. * of the easing function.
  69244. * @param gradient Defines the value between 0 and 1 we want the easing value for
  69245. * @returns the corresponding value on the curve defined by the easing function
  69246. */
  69247. ease(gradient: number): number;
  69248. }
  69249. /**
  69250. * Easing function with a circle shape (see link below).
  69251. * @see https://easings.net/#easeInCirc
  69252. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69253. */
  69254. export class CircleEase extends EasingFunction implements IEasingFunction {
  69255. /** @hidden */
  69256. easeInCore(gradient: number): number;
  69257. }
  69258. /**
  69259. * Easing function with a ease back shape (see link below).
  69260. * @see https://easings.net/#easeInBack
  69261. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69262. */
  69263. export class BackEase extends EasingFunction implements IEasingFunction {
  69264. /** Defines the amplitude of the function */
  69265. amplitude: number;
  69266. /**
  69267. * Instantiates a back ease easing
  69268. * @see https://easings.net/#easeInBack
  69269. * @param amplitude Defines the amplitude of the function
  69270. */
  69271. constructor(
  69272. /** Defines the amplitude of the function */
  69273. amplitude?: number);
  69274. /** @hidden */
  69275. easeInCore(gradient: number): number;
  69276. }
  69277. /**
  69278. * Easing function with a bouncing shape (see link below).
  69279. * @see https://easings.net/#easeInBounce
  69280. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69281. */
  69282. export class BounceEase extends EasingFunction implements IEasingFunction {
  69283. /** Defines the number of bounces */
  69284. bounces: number;
  69285. /** Defines the amplitude of the bounce */
  69286. bounciness: number;
  69287. /**
  69288. * Instantiates a bounce easing
  69289. * @see https://easings.net/#easeInBounce
  69290. * @param bounces Defines the number of bounces
  69291. * @param bounciness Defines the amplitude of the bounce
  69292. */
  69293. constructor(
  69294. /** Defines the number of bounces */
  69295. bounces?: number,
  69296. /** Defines the amplitude of the bounce */
  69297. bounciness?: number);
  69298. /** @hidden */
  69299. easeInCore(gradient: number): number;
  69300. }
  69301. /**
  69302. * Easing function with a power of 3 shape (see link below).
  69303. * @see https://easings.net/#easeInCubic
  69304. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69305. */
  69306. export class CubicEase extends EasingFunction implements IEasingFunction {
  69307. /** @hidden */
  69308. easeInCore(gradient: number): number;
  69309. }
  69310. /**
  69311. * Easing function with an elastic shape (see link below).
  69312. * @see https://easings.net/#easeInElastic
  69313. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69314. */
  69315. export class ElasticEase extends EasingFunction implements IEasingFunction {
  69316. /** Defines the number of oscillations*/
  69317. oscillations: number;
  69318. /** Defines the amplitude of the oscillations*/
  69319. springiness: number;
  69320. /**
  69321. * Instantiates an elastic easing function
  69322. * @see https://easings.net/#easeInElastic
  69323. * @param oscillations Defines the number of oscillations
  69324. * @param springiness Defines the amplitude of the oscillations
  69325. */
  69326. constructor(
  69327. /** Defines the number of oscillations*/
  69328. oscillations?: number,
  69329. /** Defines the amplitude of the oscillations*/
  69330. springiness?: number);
  69331. /** @hidden */
  69332. easeInCore(gradient: number): number;
  69333. }
  69334. /**
  69335. * Easing function with an exponential shape (see link below).
  69336. * @see https://easings.net/#easeInExpo
  69337. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69338. */
  69339. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  69340. /** Defines the exponent of the function */
  69341. exponent: number;
  69342. /**
  69343. * Instantiates an exponential easing function
  69344. * @see https://easings.net/#easeInExpo
  69345. * @param exponent Defines the exponent of the function
  69346. */
  69347. constructor(
  69348. /** Defines the exponent of the function */
  69349. exponent?: number);
  69350. /** @hidden */
  69351. easeInCore(gradient: number): number;
  69352. }
  69353. /**
  69354. * Easing function with a power shape (see link below).
  69355. * @see https://easings.net/#easeInQuad
  69356. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69357. */
  69358. export class PowerEase extends EasingFunction implements IEasingFunction {
  69359. /** Defines the power of the function */
  69360. power: number;
  69361. /**
  69362. * Instantiates an power base easing function
  69363. * @see https://easings.net/#easeInQuad
  69364. * @param power Defines the power of the function
  69365. */
  69366. constructor(
  69367. /** Defines the power of the function */
  69368. power?: number);
  69369. /** @hidden */
  69370. easeInCore(gradient: number): number;
  69371. }
  69372. /**
  69373. * Easing function with a power of 2 shape (see link below).
  69374. * @see https://easings.net/#easeInQuad
  69375. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69376. */
  69377. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  69378. /** @hidden */
  69379. easeInCore(gradient: number): number;
  69380. }
  69381. /**
  69382. * Easing function with a power of 4 shape (see link below).
  69383. * @see https://easings.net/#easeInQuart
  69384. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69385. */
  69386. export class QuarticEase extends EasingFunction implements IEasingFunction {
  69387. /** @hidden */
  69388. easeInCore(gradient: number): number;
  69389. }
  69390. /**
  69391. * Easing function with a power of 5 shape (see link below).
  69392. * @see https://easings.net/#easeInQuint
  69393. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69394. */
  69395. export class QuinticEase extends EasingFunction implements IEasingFunction {
  69396. /** @hidden */
  69397. easeInCore(gradient: number): number;
  69398. }
  69399. /**
  69400. * Easing function with a sin shape (see link below).
  69401. * @see https://easings.net/#easeInSine
  69402. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69403. */
  69404. export class SineEase extends EasingFunction implements IEasingFunction {
  69405. /** @hidden */
  69406. easeInCore(gradient: number): number;
  69407. }
  69408. /**
  69409. * Easing function with a bezier shape (see link below).
  69410. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  69411. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  69412. */
  69413. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  69414. /** Defines the x component of the start tangent in the bezier curve */
  69415. x1: number;
  69416. /** Defines the y component of the start tangent in the bezier curve */
  69417. y1: number;
  69418. /** Defines the x component of the end tangent in the bezier curve */
  69419. x2: number;
  69420. /** Defines the y component of the end tangent in the bezier curve */
  69421. y2: number;
  69422. /**
  69423. * Instantiates a bezier function
  69424. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  69425. * @param x1 Defines the x component of the start tangent in the bezier curve
  69426. * @param y1 Defines the y component of the start tangent in the bezier curve
  69427. * @param x2 Defines the x component of the end tangent in the bezier curve
  69428. * @param y2 Defines the y component of the end tangent in the bezier curve
  69429. */
  69430. constructor(
  69431. /** Defines the x component of the start tangent in the bezier curve */
  69432. x1?: number,
  69433. /** Defines the y component of the start tangent in the bezier curve */
  69434. y1?: number,
  69435. /** Defines the x component of the end tangent in the bezier curve */
  69436. x2?: number,
  69437. /** Defines the y component of the end tangent in the bezier curve */
  69438. y2?: number);
  69439. /** @hidden */
  69440. easeInCore(gradient: number): number;
  69441. }
  69442. }
  69443. declare module BABYLON {
  69444. /**
  69445. * Defines an interface which represents an animation key frame
  69446. */
  69447. export interface IAnimationKey {
  69448. /**
  69449. * Frame of the key frame
  69450. */
  69451. frame: number;
  69452. /**
  69453. * Value at the specifies key frame
  69454. */
  69455. value: any;
  69456. /**
  69457. * The input tangent for the cubic hermite spline
  69458. */
  69459. inTangent?: any;
  69460. /**
  69461. * The output tangent for the cubic hermite spline
  69462. */
  69463. outTangent?: any;
  69464. /**
  69465. * The animation interpolation type
  69466. */
  69467. interpolation?: AnimationKeyInterpolation;
  69468. }
  69469. /**
  69470. * Enum for the animation key frame interpolation type
  69471. */
  69472. export enum AnimationKeyInterpolation {
  69473. /**
  69474. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  69475. */
  69476. STEP = 1
  69477. }
  69478. }
  69479. declare module BABYLON {
  69480. /**
  69481. * Represents the range of an animation
  69482. */
  69483. export class AnimationRange {
  69484. /**The name of the animation range**/
  69485. name: string;
  69486. /**The starting frame of the animation */
  69487. from: number;
  69488. /**The ending frame of the animation*/
  69489. to: number;
  69490. /**
  69491. * Initializes the range of an animation
  69492. * @param name The name of the animation range
  69493. * @param from The starting frame of the animation
  69494. * @param to The ending frame of the animation
  69495. */
  69496. constructor(
  69497. /**The name of the animation range**/
  69498. name: string,
  69499. /**The starting frame of the animation */
  69500. from: number,
  69501. /**The ending frame of the animation*/
  69502. to: number);
  69503. /**
  69504. * Makes a copy of the animation range
  69505. * @returns A copy of the animation range
  69506. */
  69507. clone(): AnimationRange;
  69508. }
  69509. }
  69510. declare module BABYLON {
  69511. /**
  69512. * Composed of a frame, and an action function
  69513. */
  69514. export class AnimationEvent {
  69515. /** The frame for which the event is triggered **/
  69516. frame: number;
  69517. /** The event to perform when triggered **/
  69518. action: (currentFrame: number) => void;
  69519. /** Specifies if the event should be triggered only once**/
  69520. onlyOnce?: boolean | undefined;
  69521. /**
  69522. * Specifies if the animation event is done
  69523. */
  69524. isDone: boolean;
  69525. /**
  69526. * Initializes the animation event
  69527. * @param frame The frame for which the event is triggered
  69528. * @param action The event to perform when triggered
  69529. * @param onlyOnce Specifies if the event should be triggered only once
  69530. */
  69531. constructor(
  69532. /** The frame for which the event is triggered **/
  69533. frame: number,
  69534. /** The event to perform when triggered **/
  69535. action: (currentFrame: number) => void,
  69536. /** Specifies if the event should be triggered only once**/
  69537. onlyOnce?: boolean | undefined);
  69538. /** @hidden */
  69539. _clone(): AnimationEvent;
  69540. }
  69541. }
  69542. declare module BABYLON {
  69543. /**
  69544. * Interface used to define a behavior
  69545. */
  69546. export interface Behavior<T> {
  69547. /** gets or sets behavior's name */
  69548. name: string;
  69549. /**
  69550. * Function called when the behavior needs to be initialized (after attaching it to a target)
  69551. */
  69552. init(): void;
  69553. /**
  69554. * Called when the behavior is attached to a target
  69555. * @param target defines the target where the behavior is attached to
  69556. */
  69557. attach(target: T): void;
  69558. /**
  69559. * Called when the behavior is detached from its target
  69560. */
  69561. detach(): void;
  69562. }
  69563. /**
  69564. * Interface implemented by classes supporting behaviors
  69565. */
  69566. export interface IBehaviorAware<T> {
  69567. /**
  69568. * Attach a behavior
  69569. * @param behavior defines the behavior to attach
  69570. * @returns the current host
  69571. */
  69572. addBehavior(behavior: Behavior<T>): T;
  69573. /**
  69574. * Remove a behavior from the current object
  69575. * @param behavior defines the behavior to detach
  69576. * @returns the current host
  69577. */
  69578. removeBehavior(behavior: Behavior<T>): T;
  69579. /**
  69580. * Gets a behavior using its name to search
  69581. * @param name defines the name to search
  69582. * @returns the behavior or null if not found
  69583. */
  69584. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  69585. }
  69586. }
  69587. declare module BABYLON {
  69588. /**
  69589. * @hidden
  69590. */
  69591. export class IntersectionInfo {
  69592. bu: Nullable<number>;
  69593. bv: Nullable<number>;
  69594. distance: number;
  69595. faceId: number;
  69596. subMeshId: number;
  69597. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  69598. }
  69599. }
  69600. declare module BABYLON {
  69601. /**
  69602. * Class used to store bounding sphere information
  69603. */
  69604. export class BoundingSphere {
  69605. /**
  69606. * Gets the center of the bounding sphere in local space
  69607. */
  69608. readonly center: Vector3;
  69609. /**
  69610. * Radius of the bounding sphere in local space
  69611. */
  69612. radius: number;
  69613. /**
  69614. * Gets the center of the bounding sphere in world space
  69615. */
  69616. readonly centerWorld: Vector3;
  69617. /**
  69618. * Radius of the bounding sphere in world space
  69619. */
  69620. radiusWorld: number;
  69621. /**
  69622. * Gets the minimum vector in local space
  69623. */
  69624. readonly minimum: Vector3;
  69625. /**
  69626. * Gets the maximum vector in local space
  69627. */
  69628. readonly maximum: Vector3;
  69629. private _worldMatrix;
  69630. private static readonly TmpVector3;
  69631. /**
  69632. * Creates a new bounding sphere
  69633. * @param min defines the minimum vector (in local space)
  69634. * @param max defines the maximum vector (in local space)
  69635. * @param worldMatrix defines the new world matrix
  69636. */
  69637. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  69638. /**
  69639. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  69640. * @param min defines the new minimum vector (in local space)
  69641. * @param max defines the new maximum vector (in local space)
  69642. * @param worldMatrix defines the new world matrix
  69643. */
  69644. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  69645. /**
  69646. * Scale the current bounding sphere by applying a scale factor
  69647. * @param factor defines the scale factor to apply
  69648. * @returns the current bounding box
  69649. */
  69650. scale(factor: number): BoundingSphere;
  69651. /**
  69652. * Gets the world matrix of the bounding box
  69653. * @returns a matrix
  69654. */
  69655. getWorldMatrix(): DeepImmutable<Matrix>;
  69656. /** @hidden */
  69657. _update(worldMatrix: DeepImmutable<Matrix>): void;
  69658. /**
  69659. * Tests if the bounding sphere is intersecting the frustum planes
  69660. * @param frustumPlanes defines the frustum planes to test
  69661. * @returns true if there is an intersection
  69662. */
  69663. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69664. /**
  69665. * Tests if the bounding sphere center is in between the frustum planes.
  69666. * Used for optimistic fast inclusion.
  69667. * @param frustumPlanes defines the frustum planes to test
  69668. * @returns true if the sphere center is in between the frustum planes
  69669. */
  69670. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69671. /**
  69672. * Tests if a point is inside the bounding sphere
  69673. * @param point defines the point to test
  69674. * @returns true if the point is inside the bounding sphere
  69675. */
  69676. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  69677. /**
  69678. * Checks if two sphere intersct
  69679. * @param sphere0 sphere 0
  69680. * @param sphere1 sphere 1
  69681. * @returns true if the speres intersect
  69682. */
  69683. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  69684. }
  69685. }
  69686. declare module BABYLON {
  69687. /**
  69688. * Class used to store bounding box information
  69689. */
  69690. export class BoundingBox implements ICullable {
  69691. /**
  69692. * Gets the 8 vectors representing the bounding box in local space
  69693. */
  69694. readonly vectors: Vector3[];
  69695. /**
  69696. * Gets the center of the bounding box in local space
  69697. */
  69698. readonly center: Vector3;
  69699. /**
  69700. * Gets the center of the bounding box in world space
  69701. */
  69702. readonly centerWorld: Vector3;
  69703. /**
  69704. * Gets the extend size in local space
  69705. */
  69706. readonly extendSize: Vector3;
  69707. /**
  69708. * Gets the extend size in world space
  69709. */
  69710. readonly extendSizeWorld: Vector3;
  69711. /**
  69712. * Gets the OBB (object bounding box) directions
  69713. */
  69714. readonly directions: Vector3[];
  69715. /**
  69716. * Gets the 8 vectors representing the bounding box in world space
  69717. */
  69718. readonly vectorsWorld: Vector3[];
  69719. /**
  69720. * Gets the minimum vector in world space
  69721. */
  69722. readonly minimumWorld: Vector3;
  69723. /**
  69724. * Gets the maximum vector in world space
  69725. */
  69726. readonly maximumWorld: Vector3;
  69727. /**
  69728. * Gets the minimum vector in local space
  69729. */
  69730. readonly minimum: Vector3;
  69731. /**
  69732. * Gets the maximum vector in local space
  69733. */
  69734. readonly maximum: Vector3;
  69735. private _worldMatrix;
  69736. private static readonly TmpVector3;
  69737. /**
  69738. * @hidden
  69739. */
  69740. _tag: number;
  69741. /**
  69742. * Creates a new bounding box
  69743. * @param min defines the minimum vector (in local space)
  69744. * @param max defines the maximum vector (in local space)
  69745. * @param worldMatrix defines the new world matrix
  69746. */
  69747. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  69748. /**
  69749. * Recreates the entire bounding box from scratch as if we call the constructor in place
  69750. * @param min defines the new minimum vector (in local space)
  69751. * @param max defines the new maximum vector (in local space)
  69752. * @param worldMatrix defines the new world matrix
  69753. */
  69754. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  69755. /**
  69756. * Scale the current bounding box by applying a scale factor
  69757. * @param factor defines the scale factor to apply
  69758. * @returns the current bounding box
  69759. */
  69760. scale(factor: number): BoundingBox;
  69761. /**
  69762. * Gets the world matrix of the bounding box
  69763. * @returns a matrix
  69764. */
  69765. getWorldMatrix(): DeepImmutable<Matrix>;
  69766. /** @hidden */
  69767. _update(world: DeepImmutable<Matrix>): void;
  69768. /**
  69769. * Tests if the bounding box is intersecting the frustum planes
  69770. * @param frustumPlanes defines the frustum planes to test
  69771. * @returns true if there is an intersection
  69772. */
  69773. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69774. /**
  69775. * Tests if the bounding box is entirely inside the frustum planes
  69776. * @param frustumPlanes defines the frustum planes to test
  69777. * @returns true if there is an inclusion
  69778. */
  69779. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69780. /**
  69781. * Tests if a point is inside the bounding box
  69782. * @param point defines the point to test
  69783. * @returns true if the point is inside the bounding box
  69784. */
  69785. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  69786. /**
  69787. * Tests if the bounding box intersects with a bounding sphere
  69788. * @param sphere defines the sphere to test
  69789. * @returns true if there is an intersection
  69790. */
  69791. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  69792. /**
  69793. * Tests if the bounding box intersects with a box defined by a min and max vectors
  69794. * @param min defines the min vector to use
  69795. * @param max defines the max vector to use
  69796. * @returns true if there is an intersection
  69797. */
  69798. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  69799. /**
  69800. * Tests if two bounding boxes are intersections
  69801. * @param box0 defines the first box to test
  69802. * @param box1 defines the second box to test
  69803. * @returns true if there is an intersection
  69804. */
  69805. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  69806. /**
  69807. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  69808. * @param minPoint defines the minimum vector of the bounding box
  69809. * @param maxPoint defines the maximum vector of the bounding box
  69810. * @param sphereCenter defines the sphere center
  69811. * @param sphereRadius defines the sphere radius
  69812. * @returns true if there is an intersection
  69813. */
  69814. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  69815. /**
  69816. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  69817. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  69818. * @param frustumPlanes defines the frustum planes to test
  69819. * @return true if there is an inclusion
  69820. */
  69821. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69822. /**
  69823. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  69824. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  69825. * @param frustumPlanes defines the frustum planes to test
  69826. * @return true if there is an intersection
  69827. */
  69828. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69829. }
  69830. }
  69831. declare module BABYLON {
  69832. /** @hidden */
  69833. export class Collider {
  69834. /** Define if a collision was found */
  69835. collisionFound: boolean;
  69836. /**
  69837. * Define last intersection point in local space
  69838. */
  69839. intersectionPoint: Vector3;
  69840. /**
  69841. * Define last collided mesh
  69842. */
  69843. collidedMesh: Nullable<AbstractMesh>;
  69844. private _collisionPoint;
  69845. private _planeIntersectionPoint;
  69846. private _tempVector;
  69847. private _tempVector2;
  69848. private _tempVector3;
  69849. private _tempVector4;
  69850. private _edge;
  69851. private _baseToVertex;
  69852. private _destinationPoint;
  69853. private _slidePlaneNormal;
  69854. private _displacementVector;
  69855. /** @hidden */
  69856. _radius: Vector3;
  69857. /** @hidden */
  69858. _retry: number;
  69859. private _velocity;
  69860. private _basePoint;
  69861. private _epsilon;
  69862. /** @hidden */
  69863. _velocityWorldLength: number;
  69864. /** @hidden */
  69865. _basePointWorld: Vector3;
  69866. private _velocityWorld;
  69867. private _normalizedVelocity;
  69868. /** @hidden */
  69869. _initialVelocity: Vector3;
  69870. /** @hidden */
  69871. _initialPosition: Vector3;
  69872. private _nearestDistance;
  69873. private _collisionMask;
  69874. collisionMask: number;
  69875. /**
  69876. * Gets the plane normal used to compute the sliding response (in local space)
  69877. */
  69878. readonly slidePlaneNormal: Vector3;
  69879. /** @hidden */
  69880. _initialize(source: Vector3, dir: Vector3, e: number): void;
  69881. /** @hidden */
  69882. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  69883. /** @hidden */
  69884. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  69885. /** @hidden */
  69886. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  69887. /** @hidden */
  69888. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  69889. /** @hidden */
  69890. _getResponse(pos: Vector3, vel: Vector3): void;
  69891. }
  69892. }
  69893. declare module BABYLON {
  69894. /**
  69895. * Interface for cullable objects
  69896. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  69897. */
  69898. export interface ICullable {
  69899. /**
  69900. * Checks if the object or part of the object is in the frustum
  69901. * @param frustumPlanes Camera near/planes
  69902. * @returns true if the object is in frustum otherwise false
  69903. */
  69904. isInFrustum(frustumPlanes: Plane[]): boolean;
  69905. /**
  69906. * Checks if a cullable object (mesh...) is in the camera frustum
  69907. * Unlike isInFrustum this cheks the full bounding box
  69908. * @param frustumPlanes Camera near/planes
  69909. * @returns true if the object is in frustum otherwise false
  69910. */
  69911. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  69912. }
  69913. /**
  69914. * Info for a bounding data of a mesh
  69915. */
  69916. export class BoundingInfo implements ICullable {
  69917. /**
  69918. * Bounding box for the mesh
  69919. */
  69920. readonly boundingBox: BoundingBox;
  69921. /**
  69922. * Bounding sphere for the mesh
  69923. */
  69924. readonly boundingSphere: BoundingSphere;
  69925. private _isLocked;
  69926. private static readonly TmpVector3;
  69927. /**
  69928. * Constructs bounding info
  69929. * @param minimum min vector of the bounding box/sphere
  69930. * @param maximum max vector of the bounding box/sphere
  69931. * @param worldMatrix defines the new world matrix
  69932. */
  69933. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  69934. /**
  69935. * Recreates the entire bounding info from scratch as if we call the constructor in place
  69936. * @param min defines the new minimum vector (in local space)
  69937. * @param max defines the new maximum vector (in local space)
  69938. * @param worldMatrix defines the new world matrix
  69939. */
  69940. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  69941. /**
  69942. * min vector of the bounding box/sphere
  69943. */
  69944. readonly minimum: Vector3;
  69945. /**
  69946. * max vector of the bounding box/sphere
  69947. */
  69948. readonly maximum: Vector3;
  69949. /**
  69950. * If the info is locked and won't be updated to avoid perf overhead
  69951. */
  69952. isLocked: boolean;
  69953. /**
  69954. * Updates the bounding sphere and box
  69955. * @param world world matrix to be used to update
  69956. */
  69957. update(world: DeepImmutable<Matrix>): void;
  69958. /**
  69959. * Recreate the bounding info to be centered around a specific point given a specific extend.
  69960. * @param center New center of the bounding info
  69961. * @param extend New extend of the bounding info
  69962. * @returns the current bounding info
  69963. */
  69964. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  69965. /**
  69966. * Scale the current bounding info by applying a scale factor
  69967. * @param factor defines the scale factor to apply
  69968. * @returns the current bounding info
  69969. */
  69970. scale(factor: number): BoundingInfo;
  69971. /**
  69972. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  69973. * @param frustumPlanes defines the frustum to test
  69974. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  69975. * @returns true if the bounding info is in the frustum planes
  69976. */
  69977. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  69978. /**
  69979. * Gets the world distance between the min and max points of the bounding box
  69980. */
  69981. readonly diagonalLength: number;
  69982. /**
  69983. * Checks if a cullable object (mesh...) is in the camera frustum
  69984. * Unlike isInFrustum this cheks the full bounding box
  69985. * @param frustumPlanes Camera near/planes
  69986. * @returns true if the object is in frustum otherwise false
  69987. */
  69988. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69989. /** @hidden */
  69990. _checkCollision(collider: Collider): boolean;
  69991. /**
  69992. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  69993. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  69994. * @param point the point to check intersection with
  69995. * @returns if the point intersects
  69996. */
  69997. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  69998. /**
  69999. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  70000. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  70001. * @param boundingInfo the bounding info to check intersection with
  70002. * @param precise if the intersection should be done using OBB
  70003. * @returns if the bounding info intersects
  70004. */
  70005. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  70006. }
  70007. }
  70008. declare module BABYLON {
  70009. /**
  70010. * Defines an array and its length.
  70011. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  70012. */
  70013. export interface ISmartArrayLike<T> {
  70014. /**
  70015. * The data of the array.
  70016. */
  70017. data: Array<T>;
  70018. /**
  70019. * The active length of the array.
  70020. */
  70021. length: number;
  70022. }
  70023. /**
  70024. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70025. */
  70026. export class SmartArray<T> implements ISmartArrayLike<T> {
  70027. /**
  70028. * The full set of data from the array.
  70029. */
  70030. data: Array<T>;
  70031. /**
  70032. * The active length of the array.
  70033. */
  70034. length: number;
  70035. protected _id: number;
  70036. /**
  70037. * Instantiates a Smart Array.
  70038. * @param capacity defines the default capacity of the array.
  70039. */
  70040. constructor(capacity: number);
  70041. /**
  70042. * Pushes a value at the end of the active data.
  70043. * @param value defines the object to push in the array.
  70044. */
  70045. push(value: T): void;
  70046. /**
  70047. * Iterates over the active data and apply the lambda to them.
  70048. * @param func defines the action to apply on each value.
  70049. */
  70050. forEach(func: (content: T) => void): void;
  70051. /**
  70052. * Sorts the full sets of data.
  70053. * @param compareFn defines the comparison function to apply.
  70054. */
  70055. sort(compareFn: (a: T, b: T) => number): void;
  70056. /**
  70057. * Resets the active data to an empty array.
  70058. */
  70059. reset(): void;
  70060. /**
  70061. * Releases all the data from the array as well as the array.
  70062. */
  70063. dispose(): void;
  70064. /**
  70065. * Concats the active data with a given array.
  70066. * @param array defines the data to concatenate with.
  70067. */
  70068. concat(array: any): void;
  70069. /**
  70070. * Returns the position of a value in the active data.
  70071. * @param value defines the value to find the index for
  70072. * @returns the index if found in the active data otherwise -1
  70073. */
  70074. indexOf(value: T): number;
  70075. /**
  70076. * Returns whether an element is part of the active data.
  70077. * @param value defines the value to look for
  70078. * @returns true if found in the active data otherwise false
  70079. */
  70080. contains(value: T): boolean;
  70081. private static _GlobalId;
  70082. }
  70083. /**
  70084. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  70085. * The data in this array can only be present once
  70086. */
  70087. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  70088. private _duplicateId;
  70089. /**
  70090. * Pushes a value at the end of the active data.
  70091. * THIS DOES NOT PREVENT DUPPLICATE DATA
  70092. * @param value defines the object to push in the array.
  70093. */
  70094. push(value: T): void;
  70095. /**
  70096. * Pushes a value at the end of the active data.
  70097. * If the data is already present, it won t be added again
  70098. * @param value defines the object to push in the array.
  70099. * @returns true if added false if it was already present
  70100. */
  70101. pushNoDuplicate(value: T): boolean;
  70102. /**
  70103. * Resets the active data to an empty array.
  70104. */
  70105. reset(): void;
  70106. /**
  70107. * Concats the active data with a given array.
  70108. * This ensures no dupplicate will be present in the result.
  70109. * @param array defines the data to concatenate with.
  70110. */
  70111. concatWithNoDuplicate(array: any): void;
  70112. }
  70113. }
  70114. declare module BABYLON {
  70115. /**
  70116. * Enum that determines the text-wrapping mode to use.
  70117. */
  70118. export enum InspectableType {
  70119. /**
  70120. * Checkbox for booleans
  70121. */
  70122. Checkbox = 0,
  70123. /**
  70124. * Sliders for numbers
  70125. */
  70126. Slider = 1,
  70127. /**
  70128. * Vector3
  70129. */
  70130. Vector3 = 2,
  70131. /**
  70132. * Quaternions
  70133. */
  70134. Quaternion = 3,
  70135. /**
  70136. * Color3
  70137. */
  70138. Color3 = 4
  70139. }
  70140. /**
  70141. * Interface used to define custom inspectable properties.
  70142. * This interface is used by the inspector to display custom property grids
  70143. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70144. */
  70145. export interface IInspectable {
  70146. /**
  70147. * Gets the label to display
  70148. */
  70149. label: string;
  70150. /**
  70151. * Gets the name of the property to edit
  70152. */
  70153. propertyName: string;
  70154. /**
  70155. * Gets the type of the editor to use
  70156. */
  70157. type: InspectableType;
  70158. /**
  70159. * Gets the minimum value of the property when using in "slider" mode
  70160. */
  70161. min?: number;
  70162. /**
  70163. * Gets the maximum value of the property when using in "slider" mode
  70164. */
  70165. max?: number;
  70166. /**
  70167. * Gets the setp to use when using in "slider" mode
  70168. */
  70169. step?: number;
  70170. }
  70171. }
  70172. declare module BABYLON {
  70173. /**
  70174. * This represents the required contract to create a new type of texture loader.
  70175. */
  70176. export interface IInternalTextureLoader {
  70177. /**
  70178. * Defines wether the loader supports cascade loading the different faces.
  70179. */
  70180. supportCascades: boolean;
  70181. /**
  70182. * This returns if the loader support the current file information.
  70183. * @param extension defines the file extension of the file being loaded
  70184. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70185. * @param fallback defines the fallback internal texture if any
  70186. * @param isBase64 defines whether the texture is encoded as a base64
  70187. * @param isBuffer defines whether the texture data are stored as a buffer
  70188. * @returns true if the loader can load the specified file
  70189. */
  70190. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  70191. /**
  70192. * Transform the url before loading if required.
  70193. * @param rootUrl the url of the texture
  70194. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70195. * @returns the transformed texture
  70196. */
  70197. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  70198. /**
  70199. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  70200. * @param rootUrl the url of the texture
  70201. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70202. * @returns the fallback texture
  70203. */
  70204. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  70205. /**
  70206. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  70207. * @param data contains the texture data
  70208. * @param texture defines the BabylonJS internal texture
  70209. * @param createPolynomials will be true if polynomials have been requested
  70210. * @param onLoad defines the callback to trigger once the texture is ready
  70211. * @param onError defines the callback to trigger in case of error
  70212. */
  70213. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  70214. /**
  70215. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  70216. * @param data contains the texture data
  70217. * @param texture defines the BabylonJS internal texture
  70218. * @param callback defines the method to call once ready to upload
  70219. */
  70220. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  70221. }
  70222. }
  70223. declare module BABYLON {
  70224. interface Engine {
  70225. /**
  70226. * Creates a depth stencil cube texture.
  70227. * This is only available in WebGL 2.
  70228. * @param size The size of face edge in the cube texture.
  70229. * @param options The options defining the cube texture.
  70230. * @returns The cube texture
  70231. */
  70232. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  70233. /**
  70234. * Creates a cube texture
  70235. * @param rootUrl defines the url where the files to load is located
  70236. * @param scene defines the current scene
  70237. * @param files defines the list of files to load (1 per face)
  70238. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70239. * @param onLoad defines an optional callback raised when the texture is loaded
  70240. * @param onError defines an optional callback raised if there is an issue to load the texture
  70241. * @param format defines the format of the data
  70242. * @param forcedExtension defines the extension to use to pick the right loader
  70243. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  70244. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70245. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70246. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  70247. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  70248. * @returns the cube texture as an InternalTexture
  70249. */
  70250. 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;
  70251. /**
  70252. * Creates a cube texture
  70253. * @param rootUrl defines the url where the files to load is located
  70254. * @param scene defines the current scene
  70255. * @param files defines the list of files to load (1 per face)
  70256. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70257. * @param onLoad defines an optional callback raised when the texture is loaded
  70258. * @param onError defines an optional callback raised if there is an issue to load the texture
  70259. * @param format defines the format of the data
  70260. * @param forcedExtension defines the extension to use to pick the right loader
  70261. * @returns the cube texture as an InternalTexture
  70262. */
  70263. 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;
  70264. /**
  70265. * Creates a cube texture
  70266. * @param rootUrl defines the url where the files to load is located
  70267. * @param scene defines the current scene
  70268. * @param files defines the list of files to load (1 per face)
  70269. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70270. * @param onLoad defines an optional callback raised when the texture is loaded
  70271. * @param onError defines an optional callback raised if there is an issue to load the texture
  70272. * @param format defines the format of the data
  70273. * @param forcedExtension defines the extension to use to pick the right loader
  70274. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  70275. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70276. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70277. * @returns the cube texture as an InternalTexture
  70278. */
  70279. 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;
  70280. /** @hidden */
  70281. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  70282. /** @hidden */
  70283. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  70284. /** @hidden */
  70285. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  70286. /** @hidden */
  70287. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  70288. }
  70289. }
  70290. declare module BABYLON {
  70291. /**
  70292. * Class for creating a cube texture
  70293. */
  70294. export class CubeTexture extends BaseTexture {
  70295. private _delayedOnLoad;
  70296. /**
  70297. * The url of the texture
  70298. */
  70299. url: string;
  70300. /**
  70301. * Gets or sets the center of the bounding box associated with the cube texture.
  70302. * It must define where the camera used to render the texture was set
  70303. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  70304. */
  70305. boundingBoxPosition: Vector3;
  70306. private _boundingBoxSize;
  70307. /**
  70308. * Gets or sets the size of the bounding box associated with the cube texture
  70309. * When defined, the cubemap will switch to local mode
  70310. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  70311. * @example https://www.babylonjs-playground.com/#RNASML
  70312. */
  70313. /**
  70314. * Returns the bounding box size
  70315. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  70316. */
  70317. boundingBoxSize: Vector3;
  70318. protected _rotationY: number;
  70319. /**
  70320. * Sets texture matrix rotation angle around Y axis in radians.
  70321. */
  70322. /**
  70323. * Gets texture matrix rotation angle around Y axis radians.
  70324. */
  70325. rotationY: number;
  70326. /**
  70327. * Are mip maps generated for this texture or not.
  70328. */
  70329. readonly noMipmap: boolean;
  70330. private _noMipmap;
  70331. private _files;
  70332. private _extensions;
  70333. private _textureMatrix;
  70334. private _format;
  70335. private _createPolynomials;
  70336. /** @hidden */
  70337. _prefiltered: boolean;
  70338. /**
  70339. * Creates a cube texture from an array of image urls
  70340. * @param files defines an array of image urls
  70341. * @param scene defines the hosting scene
  70342. * @param noMipmap specifies if mip maps are not used
  70343. * @returns a cube texture
  70344. */
  70345. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  70346. /**
  70347. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  70348. * @param url defines the url of the prefiltered texture
  70349. * @param scene defines the scene the texture is attached to
  70350. * @param forcedExtension defines the extension of the file if different from the url
  70351. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  70352. * @return the prefiltered texture
  70353. */
  70354. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  70355. /**
  70356. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  70357. * as prefiltered data.
  70358. * @param rootUrl defines the url of the texture or the root name of the six images
  70359. * @param scene defines the scene the texture is attached to
  70360. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  70361. * @param noMipmap defines if mipmaps should be created or not
  70362. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  70363. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  70364. * @param onError defines a callback triggered in case of error during load
  70365. * @param format defines the internal format to use for the texture once loaded
  70366. * @param prefiltered defines whether or not the texture is created from prefiltered data
  70367. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  70368. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  70369. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70370. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70371. * @return the cube texture
  70372. */
  70373. 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);
  70374. /**
  70375. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  70376. */
  70377. readonly isPrefiltered: boolean;
  70378. /**
  70379. * Get the current class name of the texture useful for serialization or dynamic coding.
  70380. * @returns "CubeTexture"
  70381. */
  70382. getClassName(): string;
  70383. /**
  70384. * Update the url (and optional buffer) of this texture if url was null during construction.
  70385. * @param url the url of the texture
  70386. * @param forcedExtension defines the extension to use
  70387. * @param onLoad callback called when the texture is loaded (defaults to null)
  70388. */
  70389. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  70390. /**
  70391. * Delays loading of the cube texture
  70392. * @param forcedExtension defines the extension to use
  70393. */
  70394. delayLoad(forcedExtension?: string): void;
  70395. /**
  70396. * Returns the reflection texture matrix
  70397. * @returns the reflection texture matrix
  70398. */
  70399. getReflectionTextureMatrix(): Matrix;
  70400. /**
  70401. * Sets the reflection texture matrix
  70402. * @param value Reflection texture matrix
  70403. */
  70404. setReflectionTextureMatrix(value: Matrix): void;
  70405. /**
  70406. * Parses text to create a cube texture
  70407. * @param parsedTexture define the serialized text to read from
  70408. * @param scene defines the hosting scene
  70409. * @param rootUrl defines the root url of the cube texture
  70410. * @returns a cube texture
  70411. */
  70412. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  70413. /**
  70414. * Makes a clone, or deep copy, of the cube texture
  70415. * @returns a new cube texture
  70416. */
  70417. clone(): CubeTexture;
  70418. }
  70419. }
  70420. declare module BABYLON {
  70421. /** @hidden */
  70422. export var postprocessVertexShader: {
  70423. name: string;
  70424. shader: string;
  70425. };
  70426. }
  70427. declare module BABYLON {
  70428. /**
  70429. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  70430. * This is the base of the follow, arc rotate cameras and Free camera
  70431. * @see http://doc.babylonjs.com/features/cameras
  70432. */
  70433. export class TargetCamera extends Camera {
  70434. private static _RigCamTransformMatrix;
  70435. private static _TargetTransformMatrix;
  70436. private static _TargetFocalPoint;
  70437. /**
  70438. * Define the current direction the camera is moving to
  70439. */
  70440. cameraDirection: Vector3;
  70441. /**
  70442. * Define the current rotation the camera is rotating to
  70443. */
  70444. cameraRotation: Vector2;
  70445. /**
  70446. * When set, the up vector of the camera will be updated by the rotation of the camera
  70447. */
  70448. updateUpVectorFromRotation: boolean;
  70449. private _tmpQuaternion;
  70450. /**
  70451. * Define the current rotation of the camera
  70452. */
  70453. rotation: Vector3;
  70454. /**
  70455. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  70456. */
  70457. rotationQuaternion: Quaternion;
  70458. /**
  70459. * Define the current speed of the camera
  70460. */
  70461. speed: number;
  70462. /**
  70463. * Add cconstraint to the camera to prevent it to move freely in all directions and
  70464. * around all axis.
  70465. */
  70466. noRotationConstraint: boolean;
  70467. /**
  70468. * Define the current target of the camera as an object or a position.
  70469. */
  70470. lockedTarget: any;
  70471. /** @hidden */
  70472. _currentTarget: Vector3;
  70473. /** @hidden */
  70474. _initialFocalDistance: number;
  70475. /** @hidden */
  70476. _viewMatrix: Matrix;
  70477. /** @hidden */
  70478. _camMatrix: Matrix;
  70479. /** @hidden */
  70480. _cameraTransformMatrix: Matrix;
  70481. /** @hidden */
  70482. _cameraRotationMatrix: Matrix;
  70483. /** @hidden */
  70484. _referencePoint: Vector3;
  70485. /** @hidden */
  70486. _transformedReferencePoint: Vector3;
  70487. protected _globalCurrentTarget: Vector3;
  70488. protected _globalCurrentUpVector: Vector3;
  70489. /** @hidden */
  70490. _reset: () => void;
  70491. private _defaultUp;
  70492. /**
  70493. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  70494. * This is the base of the follow, arc rotate cameras and Free camera
  70495. * @see http://doc.babylonjs.com/features/cameras
  70496. * @param name Defines the name of the camera in the scene
  70497. * @param position Defines the start position of the camera in the scene
  70498. * @param scene Defines the scene the camera belongs to
  70499. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  70500. */
  70501. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  70502. /**
  70503. * Gets the position in front of the camera at a given distance.
  70504. * @param distance The distance from the camera we want the position to be
  70505. * @returns the position
  70506. */
  70507. getFrontPosition(distance: number): Vector3;
  70508. /** @hidden */
  70509. _getLockedTargetPosition(): Nullable<Vector3>;
  70510. private _storedPosition;
  70511. private _storedRotation;
  70512. private _storedRotationQuaternion;
  70513. /**
  70514. * Store current camera state of the camera (fov, position, rotation, etc..)
  70515. * @returns the camera
  70516. */
  70517. storeState(): Camera;
  70518. /**
  70519. * Restored camera state. You must call storeState() first
  70520. * @returns whether it was successful or not
  70521. * @hidden
  70522. */
  70523. _restoreStateValues(): boolean;
  70524. /** @hidden */
  70525. _initCache(): void;
  70526. /** @hidden */
  70527. _updateCache(ignoreParentClass?: boolean): void;
  70528. /** @hidden */
  70529. _isSynchronizedViewMatrix(): boolean;
  70530. /** @hidden */
  70531. _computeLocalCameraSpeed(): number;
  70532. /**
  70533. * Defines the target the camera should look at.
  70534. * @param target Defines the new target as a Vector or a mesh
  70535. */
  70536. setTarget(target: Vector3): void;
  70537. /**
  70538. * Return the current target position of the camera. This value is expressed in local space.
  70539. * @returns the target position
  70540. */
  70541. getTarget(): Vector3;
  70542. /** @hidden */
  70543. _decideIfNeedsToMove(): boolean;
  70544. /** @hidden */
  70545. _updatePosition(): void;
  70546. /** @hidden */
  70547. _checkInputs(): void;
  70548. protected _updateCameraRotationMatrix(): void;
  70549. /**
  70550. * 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)
  70551. * @returns the current camera
  70552. */
  70553. private _rotateUpVectorWithCameraRotationMatrix;
  70554. private _cachedRotationZ;
  70555. private _cachedQuaternionRotationZ;
  70556. /** @hidden */
  70557. _getViewMatrix(): Matrix;
  70558. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  70559. /**
  70560. * @hidden
  70561. */
  70562. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  70563. /**
  70564. * @hidden
  70565. */
  70566. _updateRigCameras(): void;
  70567. private _getRigCamPositionAndTarget;
  70568. /**
  70569. * Gets the current object class name.
  70570. * @return the class name
  70571. */
  70572. getClassName(): string;
  70573. }
  70574. }
  70575. declare module BABYLON {
  70576. /**
  70577. * @ignore
  70578. * This is a list of all the different input types that are available in the application.
  70579. * Fo instance: ArcRotateCameraGamepadInput...
  70580. */
  70581. export var CameraInputTypes: {};
  70582. /**
  70583. * This is the contract to implement in order to create a new input class.
  70584. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  70585. */
  70586. export interface ICameraInput<TCamera extends Camera> {
  70587. /**
  70588. * Defines the camera the input is attached to.
  70589. */
  70590. camera: Nullable<TCamera>;
  70591. /**
  70592. * Gets the class name of the current intput.
  70593. * @returns the class name
  70594. */
  70595. getClassName(): string;
  70596. /**
  70597. * Get the friendly name associated with the input class.
  70598. * @returns the input friendly name
  70599. */
  70600. getSimpleName(): string;
  70601. /**
  70602. * Attach the input controls to a specific dom element to get the input from.
  70603. * @param element Defines the element the controls should be listened from
  70604. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70605. */
  70606. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70607. /**
  70608. * Detach the current controls from the specified dom element.
  70609. * @param element Defines the element to stop listening the inputs from
  70610. */
  70611. detachControl(element: Nullable<HTMLElement>): void;
  70612. /**
  70613. * Update the current camera state depending on the inputs that have been used this frame.
  70614. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70615. */
  70616. checkInputs?: () => void;
  70617. }
  70618. /**
  70619. * Represents a map of input types to input instance or input index to input instance.
  70620. */
  70621. export interface CameraInputsMap<TCamera extends Camera> {
  70622. /**
  70623. * Accessor to the input by input type.
  70624. */
  70625. [name: string]: ICameraInput<TCamera>;
  70626. /**
  70627. * Accessor to the input by input index.
  70628. */
  70629. [idx: number]: ICameraInput<TCamera>;
  70630. }
  70631. /**
  70632. * This represents the input manager used within a camera.
  70633. * It helps dealing with all the different kind of input attached to a camera.
  70634. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70635. */
  70636. export class CameraInputsManager<TCamera extends Camera> {
  70637. /**
  70638. * Defines the list of inputs attahed to the camera.
  70639. */
  70640. attached: CameraInputsMap<TCamera>;
  70641. /**
  70642. * Defines the dom element the camera is collecting inputs from.
  70643. * This is null if the controls have not been attached.
  70644. */
  70645. attachedElement: Nullable<HTMLElement>;
  70646. /**
  70647. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70648. */
  70649. noPreventDefault: boolean;
  70650. /**
  70651. * Defined the camera the input manager belongs to.
  70652. */
  70653. camera: TCamera;
  70654. /**
  70655. * Update the current camera state depending on the inputs that have been used this frame.
  70656. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70657. */
  70658. checkInputs: () => void;
  70659. /**
  70660. * Instantiate a new Camera Input Manager.
  70661. * @param camera Defines the camera the input manager blongs to
  70662. */
  70663. constructor(camera: TCamera);
  70664. /**
  70665. * Add an input method to a camera
  70666. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70667. * @param input camera input method
  70668. */
  70669. add(input: ICameraInput<TCamera>): void;
  70670. /**
  70671. * Remove a specific input method from a camera
  70672. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  70673. * @param inputToRemove camera input method
  70674. */
  70675. remove(inputToRemove: ICameraInput<TCamera>): void;
  70676. /**
  70677. * Remove a specific input type from a camera
  70678. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  70679. * @param inputType the type of the input to remove
  70680. */
  70681. removeByType(inputType: string): void;
  70682. private _addCheckInputs;
  70683. /**
  70684. * Attach the input controls to the currently attached dom element to listen the events from.
  70685. * @param input Defines the input to attach
  70686. */
  70687. attachInput(input: ICameraInput<TCamera>): void;
  70688. /**
  70689. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  70690. * @param element Defines the dom element to collect the events from
  70691. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70692. */
  70693. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  70694. /**
  70695. * Detach the current manager inputs controls from a specific dom element.
  70696. * @param element Defines the dom element to collect the events from
  70697. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  70698. */
  70699. detachElement(element: HTMLElement, disconnect?: boolean): void;
  70700. /**
  70701. * Rebuild the dynamic inputCheck function from the current list of
  70702. * defined inputs in the manager.
  70703. */
  70704. rebuildInputCheck(): void;
  70705. /**
  70706. * Remove all attached input methods from a camera
  70707. */
  70708. clear(): void;
  70709. /**
  70710. * Serialize the current input manager attached to a camera.
  70711. * This ensures than once parsed,
  70712. * the input associated to the camera will be identical to the current ones
  70713. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  70714. */
  70715. serialize(serializedCamera: any): void;
  70716. /**
  70717. * Parses an input manager serialized JSON to restore the previous list of inputs
  70718. * and states associated to a camera.
  70719. * @param parsedCamera Defines the JSON to parse
  70720. */
  70721. parse(parsedCamera: any): void;
  70722. }
  70723. }
  70724. declare module BABYLON {
  70725. /**
  70726. * Gather the list of keyboard event types as constants.
  70727. */
  70728. export class KeyboardEventTypes {
  70729. /**
  70730. * The keydown event is fired when a key becomes active (pressed).
  70731. */
  70732. static readonly KEYDOWN: number;
  70733. /**
  70734. * The keyup event is fired when a key has been released.
  70735. */
  70736. static readonly KEYUP: number;
  70737. }
  70738. /**
  70739. * This class is used to store keyboard related info for the onKeyboardObservable event.
  70740. */
  70741. export class KeyboardInfo {
  70742. /**
  70743. * Defines the type of event (KeyboardEventTypes)
  70744. */
  70745. type: number;
  70746. /**
  70747. * Defines the related dom event
  70748. */
  70749. event: KeyboardEvent;
  70750. /**
  70751. * Instantiates a new keyboard info.
  70752. * This class is used to store keyboard related info for the onKeyboardObservable event.
  70753. * @param type Defines the type of event (KeyboardEventTypes)
  70754. * @param event Defines the related dom event
  70755. */
  70756. constructor(
  70757. /**
  70758. * Defines the type of event (KeyboardEventTypes)
  70759. */
  70760. type: number,
  70761. /**
  70762. * Defines the related dom event
  70763. */
  70764. event: KeyboardEvent);
  70765. }
  70766. /**
  70767. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  70768. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  70769. */
  70770. export class KeyboardInfoPre extends KeyboardInfo {
  70771. /**
  70772. * Defines the type of event (KeyboardEventTypes)
  70773. */
  70774. type: number;
  70775. /**
  70776. * Defines the related dom event
  70777. */
  70778. event: KeyboardEvent;
  70779. /**
  70780. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  70781. */
  70782. skipOnPointerObservable: boolean;
  70783. /**
  70784. * Instantiates a new keyboard pre info.
  70785. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  70786. * @param type Defines the type of event (KeyboardEventTypes)
  70787. * @param event Defines the related dom event
  70788. */
  70789. constructor(
  70790. /**
  70791. * Defines the type of event (KeyboardEventTypes)
  70792. */
  70793. type: number,
  70794. /**
  70795. * Defines the related dom event
  70796. */
  70797. event: KeyboardEvent);
  70798. }
  70799. }
  70800. declare module BABYLON {
  70801. /**
  70802. * Manage the keyboard inputs to control the movement of a free camera.
  70803. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70804. */
  70805. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  70806. /**
  70807. * Defines the camera the input is attached to.
  70808. */
  70809. camera: FreeCamera;
  70810. /**
  70811. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  70812. */
  70813. keysUp: number[];
  70814. /**
  70815. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  70816. */
  70817. keysDown: number[];
  70818. /**
  70819. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  70820. */
  70821. keysLeft: number[];
  70822. /**
  70823. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  70824. */
  70825. keysRight: number[];
  70826. private _keys;
  70827. private _onCanvasBlurObserver;
  70828. private _onKeyboardObserver;
  70829. private _engine;
  70830. private _scene;
  70831. /**
  70832. * Attach the input controls to a specific dom element to get the input from.
  70833. * @param element Defines the element the controls should be listened from
  70834. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70835. */
  70836. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70837. /**
  70838. * Detach the current controls from the specified dom element.
  70839. * @param element Defines the element to stop listening the inputs from
  70840. */
  70841. detachControl(element: Nullable<HTMLElement>): void;
  70842. /**
  70843. * Update the current camera state depending on the inputs that have been used this frame.
  70844. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70845. */
  70846. checkInputs(): void;
  70847. /**
  70848. * Gets the class name of the current intput.
  70849. * @returns the class name
  70850. */
  70851. getClassName(): string;
  70852. /** @hidden */
  70853. _onLostFocus(): void;
  70854. /**
  70855. * Get the friendly name associated with the input class.
  70856. * @returns the input friendly name
  70857. */
  70858. getSimpleName(): string;
  70859. }
  70860. }
  70861. declare module BABYLON {
  70862. /**
  70863. * A multi-material is used to apply different materials to different parts of the same object without the need of
  70864. * separate meshes. This can be use to improve performances.
  70865. * @see http://doc.babylonjs.com/how_to/multi_materials
  70866. */
  70867. export class MultiMaterial extends Material {
  70868. private _subMaterials;
  70869. /**
  70870. * Gets or Sets the list of Materials used within the multi material.
  70871. * They need to be ordered according to the submeshes order in the associated mesh
  70872. */
  70873. subMaterials: Nullable<Material>[];
  70874. /**
  70875. * Function used to align with Node.getChildren()
  70876. * @returns the list of Materials used within the multi material
  70877. */
  70878. getChildren(): Nullable<Material>[];
  70879. /**
  70880. * Instantiates a new Multi Material
  70881. * A multi-material is used to apply different materials to different parts of the same object without the need of
  70882. * separate meshes. This can be use to improve performances.
  70883. * @see http://doc.babylonjs.com/how_to/multi_materials
  70884. * @param name Define the name in the scene
  70885. * @param scene Define the scene the material belongs to
  70886. */
  70887. constructor(name: string, scene: Scene);
  70888. private _hookArray;
  70889. /**
  70890. * Get one of the submaterial by its index in the submaterials array
  70891. * @param index The index to look the sub material at
  70892. * @returns The Material if the index has been defined
  70893. */
  70894. getSubMaterial(index: number): Nullable<Material>;
  70895. /**
  70896. * Get the list of active textures for the whole sub materials list.
  70897. * @returns All the textures that will be used during the rendering
  70898. */
  70899. getActiveTextures(): BaseTexture[];
  70900. /**
  70901. * Gets the current class name of the material e.g. "MultiMaterial"
  70902. * Mainly use in serialization.
  70903. * @returns the class name
  70904. */
  70905. getClassName(): string;
  70906. /**
  70907. * Checks if the material is ready to render the requested sub mesh
  70908. * @param mesh Define the mesh the submesh belongs to
  70909. * @param subMesh Define the sub mesh to look readyness for
  70910. * @param useInstances Define whether or not the material is used with instances
  70911. * @returns true if ready, otherwise false
  70912. */
  70913. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  70914. /**
  70915. * Clones the current material and its related sub materials
  70916. * @param name Define the name of the newly cloned material
  70917. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  70918. * @returns the cloned material
  70919. */
  70920. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  70921. /**
  70922. * Serializes the materials into a JSON representation.
  70923. * @returns the JSON representation
  70924. */
  70925. serialize(): any;
  70926. /**
  70927. * Dispose the material and release its associated resources
  70928. * @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)
  70929. * @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)
  70930. * @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)
  70931. */
  70932. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  70933. /**
  70934. * Creates a MultiMaterial from parsed MultiMaterial data.
  70935. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  70936. * @param scene defines the hosting scene
  70937. * @returns a new MultiMaterial
  70938. */
  70939. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  70940. }
  70941. }
  70942. declare module BABYLON {
  70943. /**
  70944. * Class used to represent data loading progression
  70945. */
  70946. export class SceneLoaderFlags {
  70947. private static _ForceFullSceneLoadingForIncremental;
  70948. private static _ShowLoadingScreen;
  70949. private static _CleanBoneMatrixWeights;
  70950. private static _loggingLevel;
  70951. /**
  70952. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  70953. */
  70954. static ForceFullSceneLoadingForIncremental: boolean;
  70955. /**
  70956. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  70957. */
  70958. static ShowLoadingScreen: boolean;
  70959. /**
  70960. * Defines the current logging level (while loading the scene)
  70961. * @ignorenaming
  70962. */
  70963. static loggingLevel: number;
  70964. /**
  70965. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  70966. */
  70967. static CleanBoneMatrixWeights: boolean;
  70968. }
  70969. }
  70970. declare module BABYLON {
  70971. /**
  70972. * 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.
  70973. * @see https://doc.babylonjs.com/how_to/transformnode
  70974. */
  70975. export class TransformNode extends Node {
  70976. /**
  70977. * Object will not rotate to face the camera
  70978. */
  70979. static BILLBOARDMODE_NONE: number;
  70980. /**
  70981. * Object will rotate to face the camera but only on the x axis
  70982. */
  70983. static BILLBOARDMODE_X: number;
  70984. /**
  70985. * Object will rotate to face the camera but only on the y axis
  70986. */
  70987. static BILLBOARDMODE_Y: number;
  70988. /**
  70989. * Object will rotate to face the camera but only on the z axis
  70990. */
  70991. static BILLBOARDMODE_Z: number;
  70992. /**
  70993. * Object will rotate to face the camera
  70994. */
  70995. static BILLBOARDMODE_ALL: number;
  70996. private _forward;
  70997. private _forwardInverted;
  70998. private _up;
  70999. private _right;
  71000. private _rightInverted;
  71001. private _position;
  71002. private _rotation;
  71003. private _rotationQuaternion;
  71004. protected _scaling: Vector3;
  71005. protected _isDirty: boolean;
  71006. private _transformToBoneReferal;
  71007. private _billboardMode;
  71008. /**
  71009. * Gets or sets the billboard mode. Default is 0.
  71010. *
  71011. * | Value | Type | Description |
  71012. * | --- | --- | --- |
  71013. * | 0 | BILLBOARDMODE_NONE | |
  71014. * | 1 | BILLBOARDMODE_X | |
  71015. * | 2 | BILLBOARDMODE_Y | |
  71016. * | 4 | BILLBOARDMODE_Z | |
  71017. * | 7 | BILLBOARDMODE_ALL | |
  71018. *
  71019. */
  71020. billboardMode: number;
  71021. private _preserveParentRotationForBillboard;
  71022. /**
  71023. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  71024. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  71025. */
  71026. preserveParentRotationForBillboard: boolean;
  71027. /**
  71028. * 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
  71029. */
  71030. scalingDeterminant: number;
  71031. private _infiniteDistance;
  71032. /**
  71033. * Gets or sets the distance of the object to max, often used by skybox
  71034. */
  71035. infiniteDistance: boolean;
  71036. /**
  71037. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  71038. * By default the system will update normals to compensate
  71039. */
  71040. ignoreNonUniformScaling: boolean;
  71041. /**
  71042. * 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
  71043. */
  71044. reIntegrateRotationIntoRotationQuaternion: boolean;
  71045. /** @hidden */
  71046. _poseMatrix: Nullable<Matrix>;
  71047. /** @hidden */
  71048. _localMatrix: Matrix;
  71049. private _usePivotMatrix;
  71050. private _absolutePosition;
  71051. private _pivotMatrix;
  71052. private _pivotMatrixInverse;
  71053. protected _postMultiplyPivotMatrix: boolean;
  71054. protected _isWorldMatrixFrozen: boolean;
  71055. /** @hidden */
  71056. _indexInSceneTransformNodesArray: number;
  71057. /**
  71058. * An event triggered after the world matrix is updated
  71059. */
  71060. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  71061. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  71062. /**
  71063. * Gets a string identifying the name of the class
  71064. * @returns "TransformNode" string
  71065. */
  71066. getClassName(): string;
  71067. /**
  71068. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  71069. */
  71070. position: Vector3;
  71071. /**
  71072. * 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)).
  71073. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  71074. */
  71075. rotation: Vector3;
  71076. /**
  71077. * 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)).
  71078. */
  71079. scaling: Vector3;
  71080. /**
  71081. * 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).
  71082. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  71083. */
  71084. rotationQuaternion: Nullable<Quaternion>;
  71085. /**
  71086. * The forward direction of that transform in world space.
  71087. */
  71088. readonly forward: Vector3;
  71089. /**
  71090. * The up direction of that transform in world space.
  71091. */
  71092. readonly up: Vector3;
  71093. /**
  71094. * The right direction of that transform in world space.
  71095. */
  71096. readonly right: Vector3;
  71097. /**
  71098. * Copies the parameter passed Matrix into the mesh Pose matrix.
  71099. * @param matrix the matrix to copy the pose from
  71100. * @returns this TransformNode.
  71101. */
  71102. updatePoseMatrix(matrix: Matrix): TransformNode;
  71103. /**
  71104. * Returns the mesh Pose matrix.
  71105. * @returns the pose matrix
  71106. */
  71107. getPoseMatrix(): Matrix;
  71108. /** @hidden */
  71109. _isSynchronized(): boolean;
  71110. /** @hidden */
  71111. _initCache(): void;
  71112. /**
  71113. * Flag the transform node as dirty (Forcing it to update everything)
  71114. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  71115. * @returns this transform node
  71116. */
  71117. markAsDirty(property: string): TransformNode;
  71118. /**
  71119. * Returns the current mesh absolute position.
  71120. * Returns a Vector3.
  71121. */
  71122. readonly absolutePosition: Vector3;
  71123. /**
  71124. * Sets a new matrix to apply before all other transformation
  71125. * @param matrix defines the transform matrix
  71126. * @returns the current TransformNode
  71127. */
  71128. setPreTransformMatrix(matrix: Matrix): TransformNode;
  71129. /**
  71130. * Sets a new pivot matrix to the current node
  71131. * @param matrix defines the new pivot matrix to use
  71132. * @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
  71133. * @returns the current TransformNode
  71134. */
  71135. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  71136. /**
  71137. * Returns the mesh pivot matrix.
  71138. * Default : Identity.
  71139. * @returns the matrix
  71140. */
  71141. getPivotMatrix(): Matrix;
  71142. /**
  71143. * Prevents the World matrix to be computed any longer.
  71144. * @returns the TransformNode.
  71145. */
  71146. freezeWorldMatrix(): TransformNode;
  71147. /**
  71148. * Allows back the World matrix computation.
  71149. * @returns the TransformNode.
  71150. */
  71151. unfreezeWorldMatrix(): this;
  71152. /**
  71153. * True if the World matrix has been frozen.
  71154. */
  71155. readonly isWorldMatrixFrozen: boolean;
  71156. /**
  71157. * Retuns the mesh absolute position in the World.
  71158. * @returns a Vector3.
  71159. */
  71160. getAbsolutePosition(): Vector3;
  71161. /**
  71162. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  71163. * @param absolutePosition the absolute position to set
  71164. * @returns the TransformNode.
  71165. */
  71166. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  71167. /**
  71168. * Sets the mesh position in its local space.
  71169. * @param vector3 the position to set in localspace
  71170. * @returns the TransformNode.
  71171. */
  71172. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  71173. /**
  71174. * Returns the mesh position in the local space from the current World matrix values.
  71175. * @returns a new Vector3.
  71176. */
  71177. getPositionExpressedInLocalSpace(): Vector3;
  71178. /**
  71179. * Translates the mesh along the passed Vector3 in its local space.
  71180. * @param vector3 the distance to translate in localspace
  71181. * @returns the TransformNode.
  71182. */
  71183. locallyTranslate(vector3: Vector3): TransformNode;
  71184. private static _lookAtVectorCache;
  71185. /**
  71186. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  71187. * @param targetPoint the position (must be in same space as current mesh) to look at
  71188. * @param yawCor optional yaw (y-axis) correction in radians
  71189. * @param pitchCor optional pitch (x-axis) correction in radians
  71190. * @param rollCor optional roll (z-axis) correction in radians
  71191. * @param space the choosen space of the target
  71192. * @returns the TransformNode.
  71193. */
  71194. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  71195. /**
  71196. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  71197. * This Vector3 is expressed in the World space.
  71198. * @param localAxis axis to rotate
  71199. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  71200. */
  71201. getDirection(localAxis: Vector3): Vector3;
  71202. /**
  71203. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  71204. * localAxis is expressed in the mesh local space.
  71205. * result is computed in the Wordl space from the mesh World matrix.
  71206. * @param localAxis axis to rotate
  71207. * @param result the resulting transformnode
  71208. * @returns this TransformNode.
  71209. */
  71210. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  71211. /**
  71212. * Sets this transform node rotation to the given local axis.
  71213. * @param localAxis the axis in local space
  71214. * @param yawCor optional yaw (y-axis) correction in radians
  71215. * @param pitchCor optional pitch (x-axis) correction in radians
  71216. * @param rollCor optional roll (z-axis) correction in radians
  71217. * @returns this TransformNode
  71218. */
  71219. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  71220. /**
  71221. * Sets a new pivot point to the current node
  71222. * @param point defines the new pivot point to use
  71223. * @param space defines if the point is in world or local space (local by default)
  71224. * @returns the current TransformNode
  71225. */
  71226. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  71227. /**
  71228. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  71229. * @returns the pivot point
  71230. */
  71231. getPivotPoint(): Vector3;
  71232. /**
  71233. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  71234. * @param result the vector3 to store the result
  71235. * @returns this TransformNode.
  71236. */
  71237. getPivotPointToRef(result: Vector3): TransformNode;
  71238. /**
  71239. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  71240. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  71241. */
  71242. getAbsolutePivotPoint(): Vector3;
  71243. /**
  71244. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  71245. * @param result vector3 to store the result
  71246. * @returns this TransformNode.
  71247. */
  71248. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  71249. /**
  71250. * Defines the passed node as the parent of the current node.
  71251. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  71252. * @see https://doc.babylonjs.com/how_to/parenting
  71253. * @param node the node ot set as the parent
  71254. * @returns this TransformNode.
  71255. */
  71256. setParent(node: Nullable<Node>): TransformNode;
  71257. private _nonUniformScaling;
  71258. /**
  71259. * True if the scaling property of this object is non uniform eg. (1,2,1)
  71260. */
  71261. readonly nonUniformScaling: boolean;
  71262. /** @hidden */
  71263. _updateNonUniformScalingState(value: boolean): boolean;
  71264. /**
  71265. * Attach the current TransformNode to another TransformNode associated with a bone
  71266. * @param bone Bone affecting the TransformNode
  71267. * @param affectedTransformNode TransformNode associated with the bone
  71268. * @returns this object
  71269. */
  71270. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  71271. /**
  71272. * Detach the transform node if its associated with a bone
  71273. * @returns this object
  71274. */
  71275. detachFromBone(): TransformNode;
  71276. private static _rotationAxisCache;
  71277. /**
  71278. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  71279. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  71280. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  71281. * The passed axis is also normalized.
  71282. * @param axis the axis to rotate around
  71283. * @param amount the amount to rotate in radians
  71284. * @param space Space to rotate in (Default: local)
  71285. * @returns the TransformNode.
  71286. */
  71287. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  71288. /**
  71289. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  71290. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  71291. * The passed axis is also normalized. .
  71292. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  71293. * @param point the point to rotate around
  71294. * @param axis the axis to rotate around
  71295. * @param amount the amount to rotate in radians
  71296. * @returns the TransformNode
  71297. */
  71298. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  71299. /**
  71300. * Translates the mesh along the axis vector for the passed distance in the given space.
  71301. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  71302. * @param axis the axis to translate in
  71303. * @param distance the distance to translate
  71304. * @param space Space to rotate in (Default: local)
  71305. * @returns the TransformNode.
  71306. */
  71307. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  71308. /**
  71309. * Adds a rotation step to the mesh current rotation.
  71310. * x, y, z are Euler angles expressed in radians.
  71311. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  71312. * This means this rotation is made in the mesh local space only.
  71313. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  71314. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  71315. * ```javascript
  71316. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  71317. * ```
  71318. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  71319. * 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.
  71320. * @param x Rotation to add
  71321. * @param y Rotation to add
  71322. * @param z Rotation to add
  71323. * @returns the TransformNode.
  71324. */
  71325. addRotation(x: number, y: number, z: number): TransformNode;
  71326. /**
  71327. * @hidden
  71328. */
  71329. protected _getEffectiveParent(): Nullable<Node>;
  71330. /**
  71331. * Computes the world matrix of the node
  71332. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  71333. * @returns the world matrix
  71334. */
  71335. computeWorldMatrix(force?: boolean): Matrix;
  71336. protected _afterComputeWorldMatrix(): void;
  71337. /**
  71338. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  71339. * @param func callback function to add
  71340. *
  71341. * @returns the TransformNode.
  71342. */
  71343. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  71344. /**
  71345. * Removes a registered callback function.
  71346. * @param func callback function to remove
  71347. * @returns the TransformNode.
  71348. */
  71349. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  71350. /**
  71351. * Gets the position of the current mesh in camera space
  71352. * @param camera defines the camera to use
  71353. * @returns a position
  71354. */
  71355. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  71356. /**
  71357. * Returns the distance from the mesh to the active camera
  71358. * @param camera defines the camera to use
  71359. * @returns the distance
  71360. */
  71361. getDistanceToCamera(camera?: Nullable<Camera>): number;
  71362. /**
  71363. * Clone the current transform node
  71364. * @param name Name of the new clone
  71365. * @param newParent New parent for the clone
  71366. * @param doNotCloneChildren Do not clone children hierarchy
  71367. * @returns the new transform node
  71368. */
  71369. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  71370. /**
  71371. * Serializes the objects information.
  71372. * @param currentSerializationObject defines the object to serialize in
  71373. * @returns the serialized object
  71374. */
  71375. serialize(currentSerializationObject?: any): any;
  71376. /**
  71377. * Returns a new TransformNode object parsed from the source provided.
  71378. * @param parsedTransformNode is the source.
  71379. * @param scene the scne the object belongs to
  71380. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  71381. * @returns a new TransformNode object parsed from the source provided.
  71382. */
  71383. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  71384. /**
  71385. * Get all child-transformNodes of this node
  71386. * @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
  71387. * @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
  71388. * @returns an array of TransformNode
  71389. */
  71390. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  71391. /**
  71392. * Releases resources associated with this transform node.
  71393. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  71394. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  71395. */
  71396. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  71397. /**
  71398. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  71399. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  71400. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  71401. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  71402. * @returns the current mesh
  71403. */
  71404. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  71405. }
  71406. }
  71407. declare module BABYLON {
  71408. /**
  71409. * Class used to override all child animations of a given target
  71410. */
  71411. export class AnimationPropertiesOverride {
  71412. /**
  71413. * Gets or sets a value indicating if animation blending must be used
  71414. */
  71415. enableBlending: boolean;
  71416. /**
  71417. * Gets or sets the blending speed to use when enableBlending is true
  71418. */
  71419. blendingSpeed: number;
  71420. /**
  71421. * Gets or sets the default loop mode to use
  71422. */
  71423. loopMode: number;
  71424. }
  71425. }
  71426. declare module BABYLON {
  71427. /**
  71428. * Class used to store bone information
  71429. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  71430. */
  71431. export class Bone extends Node {
  71432. /**
  71433. * defines the bone name
  71434. */
  71435. name: string;
  71436. private static _tmpVecs;
  71437. private static _tmpQuat;
  71438. private static _tmpMats;
  71439. /**
  71440. * Gets the list of child bones
  71441. */
  71442. children: Bone[];
  71443. /** Gets the animations associated with this bone */
  71444. animations: Animation[];
  71445. /**
  71446. * Gets or sets bone length
  71447. */
  71448. length: number;
  71449. /**
  71450. * @hidden Internal only
  71451. * Set this value to map this bone to a different index in the transform matrices
  71452. * Set this value to -1 to exclude the bone from the transform matrices
  71453. */
  71454. _index: Nullable<number>;
  71455. private _skeleton;
  71456. private _localMatrix;
  71457. private _restPose;
  71458. private _baseMatrix;
  71459. private _absoluteTransform;
  71460. private _invertedAbsoluteTransform;
  71461. private _parent;
  71462. private _scalingDeterminant;
  71463. private _worldTransform;
  71464. private _localScaling;
  71465. private _localRotation;
  71466. private _localPosition;
  71467. private _needToDecompose;
  71468. private _needToCompose;
  71469. /** @hidden */
  71470. _linkedTransformNode: Nullable<TransformNode>;
  71471. /** @hidden */
  71472. _waitingTransformNodeId: Nullable<string>;
  71473. /** @hidden */
  71474. /** @hidden */
  71475. _matrix: Matrix;
  71476. /**
  71477. * Create a new bone
  71478. * @param name defines the bone name
  71479. * @param skeleton defines the parent skeleton
  71480. * @param parentBone defines the parent (can be null if the bone is the root)
  71481. * @param localMatrix defines the local matrix
  71482. * @param restPose defines the rest pose matrix
  71483. * @param baseMatrix defines the base matrix
  71484. * @param index defines index of the bone in the hiearchy
  71485. */
  71486. constructor(
  71487. /**
  71488. * defines the bone name
  71489. */
  71490. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  71491. /**
  71492. * Gets the current object class name.
  71493. * @return the class name
  71494. */
  71495. getClassName(): string;
  71496. /**
  71497. * Gets the parent skeleton
  71498. * @returns a skeleton
  71499. */
  71500. getSkeleton(): Skeleton;
  71501. /**
  71502. * Gets parent bone
  71503. * @returns a bone or null if the bone is the root of the bone hierarchy
  71504. */
  71505. getParent(): Nullable<Bone>;
  71506. /**
  71507. * Returns an array containing the root bones
  71508. * @returns an array containing the root bones
  71509. */
  71510. getChildren(): Array<Bone>;
  71511. /**
  71512. * Sets the parent bone
  71513. * @param parent defines the parent (can be null if the bone is the root)
  71514. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  71515. */
  71516. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  71517. /**
  71518. * Gets the local matrix
  71519. * @returns a matrix
  71520. */
  71521. getLocalMatrix(): Matrix;
  71522. /**
  71523. * Gets the base matrix (initial matrix which remains unchanged)
  71524. * @returns a matrix
  71525. */
  71526. getBaseMatrix(): Matrix;
  71527. /**
  71528. * Gets the rest pose matrix
  71529. * @returns a matrix
  71530. */
  71531. getRestPose(): Matrix;
  71532. /**
  71533. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  71534. */
  71535. getWorldMatrix(): Matrix;
  71536. /**
  71537. * Sets the local matrix to rest pose matrix
  71538. */
  71539. returnToRest(): void;
  71540. /**
  71541. * Gets the inverse of the absolute transform matrix.
  71542. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  71543. * @returns a matrix
  71544. */
  71545. getInvertedAbsoluteTransform(): Matrix;
  71546. /**
  71547. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  71548. * @returns a matrix
  71549. */
  71550. getAbsoluteTransform(): Matrix;
  71551. /**
  71552. * Links with the given transform node.
  71553. * The local matrix of this bone is copied from the transform node every frame.
  71554. * @param transformNode defines the transform node to link to
  71555. */
  71556. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  71557. /** Gets or sets current position (in local space) */
  71558. position: Vector3;
  71559. /** Gets or sets current rotation (in local space) */
  71560. rotation: Vector3;
  71561. /** Gets or sets current rotation quaternion (in local space) */
  71562. rotationQuaternion: Quaternion;
  71563. /** Gets or sets current scaling (in local space) */
  71564. scaling: Vector3;
  71565. /**
  71566. * Gets the animation properties override
  71567. */
  71568. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  71569. private _decompose;
  71570. private _compose;
  71571. /**
  71572. * Update the base and local matrices
  71573. * @param matrix defines the new base or local matrix
  71574. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  71575. * @param updateLocalMatrix defines if the local matrix should be updated
  71576. */
  71577. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  71578. /** @hidden */
  71579. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  71580. /**
  71581. * Flag the bone as dirty (Forcing it to update everything)
  71582. */
  71583. markAsDirty(): void;
  71584. /** @hidden */
  71585. _markAsDirtyAndCompose(): void;
  71586. private _markAsDirtyAndDecompose;
  71587. /**
  71588. * Translate the bone in local or world space
  71589. * @param vec The amount to translate the bone
  71590. * @param space The space that the translation is in
  71591. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71592. */
  71593. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  71594. /**
  71595. * Set the postion of the bone in local or world space
  71596. * @param position The position to set the bone
  71597. * @param space The space that the position is in
  71598. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71599. */
  71600. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  71601. /**
  71602. * Set the absolute position of the bone (world space)
  71603. * @param position The position to set the bone
  71604. * @param mesh The mesh that this bone is attached to
  71605. */
  71606. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  71607. /**
  71608. * Scale the bone on the x, y and z axes (in local space)
  71609. * @param x The amount to scale the bone on the x axis
  71610. * @param y The amount to scale the bone on the y axis
  71611. * @param z The amount to scale the bone on the z axis
  71612. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  71613. */
  71614. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  71615. /**
  71616. * Set the bone scaling in local space
  71617. * @param scale defines the scaling vector
  71618. */
  71619. setScale(scale: Vector3): void;
  71620. /**
  71621. * Gets the current scaling in local space
  71622. * @returns the current scaling vector
  71623. */
  71624. getScale(): Vector3;
  71625. /**
  71626. * Gets the current scaling in local space and stores it in a target vector
  71627. * @param result defines the target vector
  71628. */
  71629. getScaleToRef(result: Vector3): void;
  71630. /**
  71631. * Set the yaw, pitch, and roll of the bone in local or world space
  71632. * @param yaw The rotation of the bone on the y axis
  71633. * @param pitch The rotation of the bone on the x axis
  71634. * @param roll The rotation of the bone on the z axis
  71635. * @param space The space that the axes of rotation are in
  71636. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71637. */
  71638. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  71639. /**
  71640. * Add a rotation to the bone on an axis in local or world space
  71641. * @param axis The axis to rotate the bone on
  71642. * @param amount The amount to rotate the bone
  71643. * @param space The space that the axis is in
  71644. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71645. */
  71646. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  71647. /**
  71648. * Set the rotation of the bone to a particular axis angle in local or world space
  71649. * @param axis The axis to rotate the bone on
  71650. * @param angle The angle that the bone should be rotated to
  71651. * @param space The space that the axis is in
  71652. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71653. */
  71654. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  71655. /**
  71656. * Set the euler rotation of the bone in local of world space
  71657. * @param rotation The euler rotation that the bone should be set to
  71658. * @param space The space that the rotation is in
  71659. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71660. */
  71661. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  71662. /**
  71663. * Set the quaternion rotation of the bone in local of world space
  71664. * @param quat The quaternion rotation that the bone should be set to
  71665. * @param space The space that the rotation is in
  71666. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71667. */
  71668. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  71669. /**
  71670. * Set the rotation matrix of the bone in local of world space
  71671. * @param rotMat The rotation matrix that the bone should be set to
  71672. * @param space The space that the rotation is in
  71673. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71674. */
  71675. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  71676. private _rotateWithMatrix;
  71677. private _getNegativeRotationToRef;
  71678. /**
  71679. * Get the position of the bone in local or world space
  71680. * @param space The space that the returned position is in
  71681. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71682. * @returns The position of the bone
  71683. */
  71684. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  71685. /**
  71686. * Copy the position of the bone to a vector3 in local or world space
  71687. * @param space The space that the returned position is in
  71688. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71689. * @param result The vector3 to copy the position to
  71690. */
  71691. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  71692. /**
  71693. * Get the absolute position of the bone (world space)
  71694. * @param mesh The mesh that this bone is attached to
  71695. * @returns The absolute position of the bone
  71696. */
  71697. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  71698. /**
  71699. * Copy the absolute position of the bone (world space) to the result param
  71700. * @param mesh The mesh that this bone is attached to
  71701. * @param result The vector3 to copy the absolute position to
  71702. */
  71703. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  71704. /**
  71705. * Compute the absolute transforms of this bone and its children
  71706. */
  71707. computeAbsoluteTransforms(): void;
  71708. /**
  71709. * Get the world direction from an axis that is in the local space of the bone
  71710. * @param localAxis The local direction that is used to compute the world direction
  71711. * @param mesh The mesh that this bone is attached to
  71712. * @returns The world direction
  71713. */
  71714. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  71715. /**
  71716. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  71717. * @param localAxis The local direction that is used to compute the world direction
  71718. * @param mesh The mesh that this bone is attached to
  71719. * @param result The vector3 that the world direction will be copied to
  71720. */
  71721. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  71722. /**
  71723. * Get the euler rotation of the bone in local or world space
  71724. * @param space The space that the rotation should be in
  71725. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71726. * @returns The euler rotation
  71727. */
  71728. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  71729. /**
  71730. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  71731. * @param space The space that the rotation should be in
  71732. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71733. * @param result The vector3 that the rotation should be copied to
  71734. */
  71735. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  71736. /**
  71737. * Get the quaternion rotation of the bone in either local or world space
  71738. * @param space The space that the rotation should be in
  71739. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71740. * @returns The quaternion rotation
  71741. */
  71742. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  71743. /**
  71744. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  71745. * @param space The space that the rotation should be in
  71746. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71747. * @param result The quaternion that the rotation should be copied to
  71748. */
  71749. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  71750. /**
  71751. * Get the rotation matrix of the bone in local or world space
  71752. * @param space The space that the rotation should be in
  71753. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71754. * @returns The rotation matrix
  71755. */
  71756. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  71757. /**
  71758. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  71759. * @param space The space that the rotation should be in
  71760. * @param mesh The mesh that this bone is attached to. This is only used in world space
  71761. * @param result The quaternion that the rotation should be copied to
  71762. */
  71763. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  71764. /**
  71765. * Get the world position of a point that is in the local space of the bone
  71766. * @param position The local position
  71767. * @param mesh The mesh that this bone is attached to
  71768. * @returns The world position
  71769. */
  71770. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  71771. /**
  71772. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  71773. * @param position The local position
  71774. * @param mesh The mesh that this bone is attached to
  71775. * @param result The vector3 that the world position should be copied to
  71776. */
  71777. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  71778. /**
  71779. * Get the local position of a point that is in world space
  71780. * @param position The world position
  71781. * @param mesh The mesh that this bone is attached to
  71782. * @returns The local position
  71783. */
  71784. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  71785. /**
  71786. * Get the local position of a point that is in world space and copy it to the result param
  71787. * @param position The world position
  71788. * @param mesh The mesh that this bone is attached to
  71789. * @param result The vector3 that the local position should be copied to
  71790. */
  71791. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  71792. }
  71793. }
  71794. declare module BABYLON {
  71795. interface Engine {
  71796. /**
  71797. * Creates a raw texture
  71798. * @param data defines the data to store in the texture
  71799. * @param width defines the width of the texture
  71800. * @param height defines the height of the texture
  71801. * @param format defines the format of the data
  71802. * @param generateMipMaps defines if the engine should generate the mip levels
  71803. * @param invertY defines if data must be stored with Y axis inverted
  71804. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  71805. * @param compression defines the compression used (null by default)
  71806. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71807. * @returns the raw texture inside an InternalTexture
  71808. */
  71809. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  71810. /**
  71811. * Update a raw texture
  71812. * @param texture defines the texture to update
  71813. * @param data defines the data to store in the texture
  71814. * @param format defines the format of the data
  71815. * @param invertY defines if data must be stored with Y axis inverted
  71816. */
  71817. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  71818. /**
  71819. * Update a raw texture
  71820. * @param texture defines the texture to update
  71821. * @param data defines the data to store in the texture
  71822. * @param format defines the format of the data
  71823. * @param invertY defines if data must be stored with Y axis inverted
  71824. * @param compression defines the compression used (null by default)
  71825. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71826. */
  71827. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  71828. /**
  71829. * Creates a new raw cube texture
  71830. * @param data defines the array of data to use to create each face
  71831. * @param size defines the size of the textures
  71832. * @param format defines the format of the data
  71833. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  71834. * @param generateMipMaps defines if the engine should generate the mip levels
  71835. * @param invertY defines if data must be stored with Y axis inverted
  71836. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  71837. * @param compression defines the compression used (null by default)
  71838. * @returns the cube texture as an InternalTexture
  71839. */
  71840. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  71841. /**
  71842. * Update a raw cube texture
  71843. * @param texture defines the texture to udpdate
  71844. * @param data defines the data to store
  71845. * @param format defines the data format
  71846. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71847. * @param invertY defines if data must be stored with Y axis inverted
  71848. */
  71849. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  71850. /**
  71851. * Update a raw cube texture
  71852. * @param texture defines the texture to udpdate
  71853. * @param data defines the data to store
  71854. * @param format defines the data format
  71855. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71856. * @param invertY defines if data must be stored with Y axis inverted
  71857. * @param compression defines the compression used (null by default)
  71858. */
  71859. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  71860. /**
  71861. * Update a raw cube texture
  71862. * @param texture defines the texture to udpdate
  71863. * @param data defines the data to store
  71864. * @param format defines the data format
  71865. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71866. * @param invertY defines if data must be stored with Y axis inverted
  71867. * @param compression defines the compression used (null by default)
  71868. * @param level defines which level of the texture to update
  71869. */
  71870. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  71871. /**
  71872. * Creates a new raw cube texture from a specified url
  71873. * @param url defines the url where the data is located
  71874. * @param scene defines the current scene
  71875. * @param size defines the size of the textures
  71876. * @param format defines the format of the data
  71877. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  71878. * @param noMipmap defines if the engine should avoid generating the mip levels
  71879. * @param callback defines a callback used to extract texture data from loaded data
  71880. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  71881. * @param onLoad defines a callback called when texture is loaded
  71882. * @param onError defines a callback called if there is an error
  71883. * @returns the cube texture as an InternalTexture
  71884. */
  71885. 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;
  71886. /**
  71887. * Creates a new raw cube texture from a specified url
  71888. * @param url defines the url where the data is located
  71889. * @param scene defines the current scene
  71890. * @param size defines the size of the textures
  71891. * @param format defines the format of the data
  71892. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  71893. * @param noMipmap defines if the engine should avoid generating the mip levels
  71894. * @param callback defines a callback used to extract texture data from loaded data
  71895. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  71896. * @param onLoad defines a callback called when texture is loaded
  71897. * @param onError defines a callback called if there is an error
  71898. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  71899. * @param invertY defines if data must be stored with Y axis inverted
  71900. * @returns the cube texture as an InternalTexture
  71901. */
  71902. 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;
  71903. /**
  71904. * Creates a new raw 3D texture
  71905. * @param data defines the data used to create the texture
  71906. * @param width defines the width of the texture
  71907. * @param height defines the height of the texture
  71908. * @param depth defines the depth of the texture
  71909. * @param format defines the format of the texture
  71910. * @param generateMipMaps defines if the engine must generate mip levels
  71911. * @param invertY defines if data must be stored with Y axis inverted
  71912. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  71913. * @param compression defines the compressed used (can be null)
  71914. * @param textureType defines the compressed used (can be null)
  71915. * @returns a new raw 3D texture (stored in an InternalTexture)
  71916. */
  71917. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  71918. /**
  71919. * Update a raw 3D texture
  71920. * @param texture defines the texture to update
  71921. * @param data defines the data to store
  71922. * @param format defines the data format
  71923. * @param invertY defines if data must be stored with Y axis inverted
  71924. */
  71925. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  71926. /**
  71927. * Update a raw 3D texture
  71928. * @param texture defines the texture to update
  71929. * @param data defines the data to store
  71930. * @param format defines the data format
  71931. * @param invertY defines if data must be stored with Y axis inverted
  71932. * @param compression defines the used compression (can be null)
  71933. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  71934. */
  71935. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  71936. }
  71937. }
  71938. declare module BABYLON {
  71939. /**
  71940. * Raw texture can help creating a texture directly from an array of data.
  71941. * This can be super useful if you either get the data from an uncompressed source or
  71942. * if you wish to create your texture pixel by pixel.
  71943. */
  71944. export class RawTexture extends Texture {
  71945. /**
  71946. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  71947. */
  71948. format: number;
  71949. private _engine;
  71950. /**
  71951. * Instantiates a new RawTexture.
  71952. * Raw texture can help creating a texture directly from an array of data.
  71953. * This can be super useful if you either get the data from an uncompressed source or
  71954. * if you wish to create your texture pixel by pixel.
  71955. * @param data define the array of data to use to create the texture
  71956. * @param width define the width of the texture
  71957. * @param height define the height of the texture
  71958. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  71959. * @param scene define the scene the texture belongs to
  71960. * @param generateMipMaps define whether mip maps should be generated or not
  71961. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  71962. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  71963. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  71964. */
  71965. constructor(data: ArrayBufferView, width: number, height: number,
  71966. /**
  71967. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  71968. */
  71969. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  71970. /**
  71971. * Updates the texture underlying data.
  71972. * @param data Define the new data of the texture
  71973. */
  71974. update(data: ArrayBufferView): void;
  71975. /**
  71976. * Creates a luminance texture from some data.
  71977. * @param data Define the texture data
  71978. * @param width Define the width of the texture
  71979. * @param height Define the height of the texture
  71980. * @param scene Define the scene the texture belongs to
  71981. * @param generateMipMaps Define whether or not to create mip maps for the texture
  71982. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  71983. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  71984. * @returns the luminance texture
  71985. */
  71986. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  71987. /**
  71988. * Creates a luminance alpha texture from some data.
  71989. * @param data Define the texture data
  71990. * @param width Define the width of the texture
  71991. * @param height Define the height of the texture
  71992. * @param scene Define the scene the texture belongs to
  71993. * @param generateMipMaps Define whether or not to create mip maps for the texture
  71994. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  71995. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  71996. * @returns the luminance alpha texture
  71997. */
  71998. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  71999. /**
  72000. * Creates an alpha texture from some data.
  72001. * @param data Define the texture data
  72002. * @param width Define the width of the texture
  72003. * @param height Define the height of the texture
  72004. * @param scene Define the scene the texture belongs to
  72005. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72006. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72007. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72008. * @returns the alpha texture
  72009. */
  72010. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  72011. /**
  72012. * Creates a RGB texture from some data.
  72013. * @param data Define the texture data
  72014. * @param width Define the width of the texture
  72015. * @param height Define the height of the texture
  72016. * @param scene Define the scene the texture belongs to
  72017. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72018. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72019. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72020. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72021. * @returns the RGB alpha texture
  72022. */
  72023. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72024. /**
  72025. * Creates a RGBA texture from some data.
  72026. * @param data Define the texture data
  72027. * @param width Define the width of the texture
  72028. * @param height Define the height of the texture
  72029. * @param scene Define the scene the texture belongs to
  72030. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72031. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72032. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72033. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72034. * @returns the RGBA texture
  72035. */
  72036. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72037. /**
  72038. * Creates a R texture from some data.
  72039. * @param data Define the texture data
  72040. * @param width Define the width of the texture
  72041. * @param height Define the height of the texture
  72042. * @param scene Define the scene the texture belongs to
  72043. * @param generateMipMaps Define whether or not to create mip maps for the texture
  72044. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  72045. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  72046. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  72047. * @returns the R texture
  72048. */
  72049. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  72050. }
  72051. }
  72052. declare module BABYLON {
  72053. /**
  72054. * Defines a runtime animation
  72055. */
  72056. export class RuntimeAnimation {
  72057. private _events;
  72058. /**
  72059. * The current frame of the runtime animation
  72060. */
  72061. private _currentFrame;
  72062. /**
  72063. * The animation used by the runtime animation
  72064. */
  72065. private _animation;
  72066. /**
  72067. * The target of the runtime animation
  72068. */
  72069. private _target;
  72070. /**
  72071. * The initiating animatable
  72072. */
  72073. private _host;
  72074. /**
  72075. * The original value of the runtime animation
  72076. */
  72077. private _originalValue;
  72078. /**
  72079. * The original blend value of the runtime animation
  72080. */
  72081. private _originalBlendValue;
  72082. /**
  72083. * The offsets cache of the runtime animation
  72084. */
  72085. private _offsetsCache;
  72086. /**
  72087. * The high limits cache of the runtime animation
  72088. */
  72089. private _highLimitsCache;
  72090. /**
  72091. * Specifies if the runtime animation has been stopped
  72092. */
  72093. private _stopped;
  72094. /**
  72095. * The blending factor of the runtime animation
  72096. */
  72097. private _blendingFactor;
  72098. /**
  72099. * The BabylonJS scene
  72100. */
  72101. private _scene;
  72102. /**
  72103. * The current value of the runtime animation
  72104. */
  72105. private _currentValue;
  72106. /** @hidden */
  72107. _animationState: _IAnimationState;
  72108. /**
  72109. * The active target of the runtime animation
  72110. */
  72111. private _activeTargets;
  72112. private _currentActiveTarget;
  72113. private _directTarget;
  72114. /**
  72115. * The target path of the runtime animation
  72116. */
  72117. private _targetPath;
  72118. /**
  72119. * The weight of the runtime animation
  72120. */
  72121. private _weight;
  72122. /**
  72123. * The ratio offset of the runtime animation
  72124. */
  72125. private _ratioOffset;
  72126. /**
  72127. * The previous delay of the runtime animation
  72128. */
  72129. private _previousDelay;
  72130. /**
  72131. * The previous ratio of the runtime animation
  72132. */
  72133. private _previousRatio;
  72134. private _enableBlending;
  72135. private _keys;
  72136. private _minFrame;
  72137. private _maxFrame;
  72138. private _minValue;
  72139. private _maxValue;
  72140. private _targetIsArray;
  72141. /**
  72142. * Gets the current frame of the runtime animation
  72143. */
  72144. readonly currentFrame: number;
  72145. /**
  72146. * Gets the weight of the runtime animation
  72147. */
  72148. readonly weight: number;
  72149. /**
  72150. * Gets the current value of the runtime animation
  72151. */
  72152. readonly currentValue: any;
  72153. /**
  72154. * Gets the target path of the runtime animation
  72155. */
  72156. readonly targetPath: string;
  72157. /**
  72158. * Gets the actual target of the runtime animation
  72159. */
  72160. readonly target: any;
  72161. /** @hidden */
  72162. _onLoop: () => void;
  72163. /**
  72164. * Create a new RuntimeAnimation object
  72165. * @param target defines the target of the animation
  72166. * @param animation defines the source animation object
  72167. * @param scene defines the hosting scene
  72168. * @param host defines the initiating Animatable
  72169. */
  72170. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  72171. private _preparePath;
  72172. /**
  72173. * Gets the animation from the runtime animation
  72174. */
  72175. readonly animation: Animation;
  72176. /**
  72177. * Resets the runtime animation to the beginning
  72178. * @param restoreOriginal defines whether to restore the target property to the original value
  72179. */
  72180. reset(restoreOriginal?: boolean): void;
  72181. /**
  72182. * Specifies if the runtime animation is stopped
  72183. * @returns Boolean specifying if the runtime animation is stopped
  72184. */
  72185. isStopped(): boolean;
  72186. /**
  72187. * Disposes of the runtime animation
  72188. */
  72189. dispose(): void;
  72190. /**
  72191. * Apply the interpolated value to the target
  72192. * @param currentValue defines the value computed by the animation
  72193. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  72194. */
  72195. setValue(currentValue: any, weight: number): void;
  72196. private _getOriginalValues;
  72197. private _setValue;
  72198. /**
  72199. * Gets the loop pmode of the runtime animation
  72200. * @returns Loop Mode
  72201. */
  72202. private _getCorrectLoopMode;
  72203. /**
  72204. * Move the current animation to a given frame
  72205. * @param frame defines the frame to move to
  72206. */
  72207. goToFrame(frame: number): void;
  72208. /**
  72209. * @hidden Internal use only
  72210. */
  72211. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  72212. /**
  72213. * Execute the current animation
  72214. * @param delay defines the delay to add to the current frame
  72215. * @param from defines the lower bound of the animation range
  72216. * @param to defines the upper bound of the animation range
  72217. * @param loop defines if the current animation must loop
  72218. * @param speedRatio defines the current speed ratio
  72219. * @param weight defines the weight of the animation (default is -1 so no weight)
  72220. * @param onLoop optional callback called when animation loops
  72221. * @returns a boolean indicating if the animation is running
  72222. */
  72223. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  72224. }
  72225. }
  72226. declare module BABYLON {
  72227. /**
  72228. * Class used to store an actual running animation
  72229. */
  72230. export class Animatable {
  72231. /** defines the target object */
  72232. target: any;
  72233. /** defines the starting frame number (default is 0) */
  72234. fromFrame: number;
  72235. /** defines the ending frame number (default is 100) */
  72236. toFrame: number;
  72237. /** defines if the animation must loop (default is false) */
  72238. loopAnimation: boolean;
  72239. /** defines a callback to call when animation ends if it is not looping */
  72240. onAnimationEnd?: (() => void) | null | undefined;
  72241. /** defines a callback to call when animation loops */
  72242. onAnimationLoop?: (() => void) | null | undefined;
  72243. private _localDelayOffset;
  72244. private _pausedDelay;
  72245. private _runtimeAnimations;
  72246. private _paused;
  72247. private _scene;
  72248. private _speedRatio;
  72249. private _weight;
  72250. private _syncRoot;
  72251. /**
  72252. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  72253. * This will only apply for non looping animation (default is true)
  72254. */
  72255. disposeOnEnd: boolean;
  72256. /**
  72257. * Gets a boolean indicating if the animation has started
  72258. */
  72259. animationStarted: boolean;
  72260. /**
  72261. * Observer raised when the animation ends
  72262. */
  72263. onAnimationEndObservable: Observable<Animatable>;
  72264. /**
  72265. * Observer raised when the animation loops
  72266. */
  72267. onAnimationLoopObservable: Observable<Animatable>;
  72268. /**
  72269. * Gets the root Animatable used to synchronize and normalize animations
  72270. */
  72271. readonly syncRoot: Nullable<Animatable>;
  72272. /**
  72273. * Gets the current frame of the first RuntimeAnimation
  72274. * Used to synchronize Animatables
  72275. */
  72276. readonly masterFrame: number;
  72277. /**
  72278. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  72279. */
  72280. weight: number;
  72281. /**
  72282. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  72283. */
  72284. speedRatio: number;
  72285. /**
  72286. * Creates a new Animatable
  72287. * @param scene defines the hosting scene
  72288. * @param target defines the target object
  72289. * @param fromFrame defines the starting frame number (default is 0)
  72290. * @param toFrame defines the ending frame number (default is 100)
  72291. * @param loopAnimation defines if the animation must loop (default is false)
  72292. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  72293. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  72294. * @param animations defines a group of animation to add to the new Animatable
  72295. * @param onAnimationLoop defines a callback to call when animation loops
  72296. */
  72297. constructor(scene: Scene,
  72298. /** defines the target object */
  72299. target: any,
  72300. /** defines the starting frame number (default is 0) */
  72301. fromFrame?: number,
  72302. /** defines the ending frame number (default is 100) */
  72303. toFrame?: number,
  72304. /** defines if the animation must loop (default is false) */
  72305. loopAnimation?: boolean, speedRatio?: number,
  72306. /** defines a callback to call when animation ends if it is not looping */
  72307. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  72308. /** defines a callback to call when animation loops */
  72309. onAnimationLoop?: (() => void) | null | undefined);
  72310. /**
  72311. * Synchronize and normalize current Animatable with a source Animatable
  72312. * This is useful when using animation weights and when animations are not of the same length
  72313. * @param root defines the root Animatable to synchronize with
  72314. * @returns the current Animatable
  72315. */
  72316. syncWith(root: Animatable): Animatable;
  72317. /**
  72318. * Gets the list of runtime animations
  72319. * @returns an array of RuntimeAnimation
  72320. */
  72321. getAnimations(): RuntimeAnimation[];
  72322. /**
  72323. * Adds more animations to the current animatable
  72324. * @param target defines the target of the animations
  72325. * @param animations defines the new animations to add
  72326. */
  72327. appendAnimations(target: any, animations: Animation[]): void;
  72328. /**
  72329. * Gets the source animation for a specific property
  72330. * @param property defines the propertyu to look for
  72331. * @returns null or the source animation for the given property
  72332. */
  72333. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  72334. /**
  72335. * Gets the runtime animation for a specific property
  72336. * @param property defines the propertyu to look for
  72337. * @returns null or the runtime animation for the given property
  72338. */
  72339. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  72340. /**
  72341. * Resets the animatable to its original state
  72342. */
  72343. reset(): void;
  72344. /**
  72345. * Allows the animatable to blend with current running animations
  72346. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  72347. * @param blendingSpeed defines the blending speed to use
  72348. */
  72349. enableBlending(blendingSpeed: number): void;
  72350. /**
  72351. * Disable animation blending
  72352. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  72353. */
  72354. disableBlending(): void;
  72355. /**
  72356. * Jump directly to a given frame
  72357. * @param frame defines the frame to jump to
  72358. */
  72359. goToFrame(frame: number): void;
  72360. /**
  72361. * Pause the animation
  72362. */
  72363. pause(): void;
  72364. /**
  72365. * Restart the animation
  72366. */
  72367. restart(): void;
  72368. private _raiseOnAnimationEnd;
  72369. /**
  72370. * Stop and delete the current animation
  72371. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  72372. * @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)
  72373. */
  72374. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  72375. /**
  72376. * Wait asynchronously for the animation to end
  72377. * @returns a promise which will be fullfilled when the animation ends
  72378. */
  72379. waitAsync(): Promise<Animatable>;
  72380. /** @hidden */
  72381. _animate(delay: number): boolean;
  72382. }
  72383. interface Scene {
  72384. /** @hidden */
  72385. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  72386. /** @hidden */
  72387. _processLateAnimationBindingsForMatrices(holder: {
  72388. totalWeight: number;
  72389. animations: RuntimeAnimation[];
  72390. originalValue: Matrix;
  72391. }): any;
  72392. /** @hidden */
  72393. _processLateAnimationBindingsForQuaternions(holder: {
  72394. totalWeight: number;
  72395. animations: RuntimeAnimation[];
  72396. originalValue: Quaternion;
  72397. }, refQuaternion: Quaternion): Quaternion;
  72398. /** @hidden */
  72399. _processLateAnimationBindings(): void;
  72400. /**
  72401. * Will start the animation sequence of a given target
  72402. * @param target defines the target
  72403. * @param from defines from which frame should animation start
  72404. * @param to defines until which frame should animation run.
  72405. * @param weight defines the weight to apply to the animation (1.0 by default)
  72406. * @param loop defines if the animation loops
  72407. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72408. * @param onAnimationEnd defines the function to be executed when the animation ends
  72409. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72410. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  72411. * @param onAnimationLoop defines the callback to call when an animation loops
  72412. * @returns the animatable object created for this animation
  72413. */
  72414. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  72415. /**
  72416. * Will start the animation sequence of a given target
  72417. * @param target defines the target
  72418. * @param from defines from which frame should animation start
  72419. * @param to defines until which frame should animation run.
  72420. * @param loop defines if the animation loops
  72421. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72422. * @param onAnimationEnd defines the function to be executed when the animation ends
  72423. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72424. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  72425. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  72426. * @param onAnimationLoop defines the callback to call when an animation loops
  72427. * @returns the animatable object created for this animation
  72428. */
  72429. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  72430. /**
  72431. * Will start the animation sequence of a given target and its hierarchy
  72432. * @param target defines the target
  72433. * @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.
  72434. * @param from defines from which frame should animation start
  72435. * @param to defines until which frame should animation run.
  72436. * @param loop defines if the animation loops
  72437. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  72438. * @param onAnimationEnd defines the function to be executed when the animation ends
  72439. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  72440. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  72441. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  72442. * @param onAnimationLoop defines the callback to call when an animation loops
  72443. * @returns the list of created animatables
  72444. */
  72445. 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[];
  72446. /**
  72447. * Begin a new animation on a given node
  72448. * @param target defines the target where the animation will take place
  72449. * @param animations defines the list of animations to start
  72450. * @param from defines the initial value
  72451. * @param to defines the final value
  72452. * @param loop defines if you want animation to loop (off by default)
  72453. * @param speedRatio defines the speed ratio to apply to all animations
  72454. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  72455. * @param onAnimationLoop defines the callback to call when an animation loops
  72456. * @returns the list of created animatables
  72457. */
  72458. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  72459. /**
  72460. * Begin a new animation on a given node and its hierarchy
  72461. * @param target defines the root node where the animation will take place
  72462. * @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.
  72463. * @param animations defines the list of animations to start
  72464. * @param from defines the initial value
  72465. * @param to defines the final value
  72466. * @param loop defines if you want animation to loop (off by default)
  72467. * @param speedRatio defines the speed ratio to apply to all animations
  72468. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  72469. * @param onAnimationLoop defines the callback to call when an animation loops
  72470. * @returns the list of animatables created for all nodes
  72471. */
  72472. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  72473. /**
  72474. * Gets the animatable associated with a specific target
  72475. * @param target defines the target of the animatable
  72476. * @returns the required animatable if found
  72477. */
  72478. getAnimatableByTarget(target: any): Nullable<Animatable>;
  72479. /**
  72480. * Gets all animatables associated with a given target
  72481. * @param target defines the target to look animatables for
  72482. * @returns an array of Animatables
  72483. */
  72484. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  72485. /**
  72486. * Stops and removes all animations that have been applied to the scene
  72487. */
  72488. stopAllAnimations(): void;
  72489. }
  72490. interface Bone {
  72491. /**
  72492. * Copy an animation range from another bone
  72493. * @param source defines the source bone
  72494. * @param rangeName defines the range name to copy
  72495. * @param frameOffset defines the frame offset
  72496. * @param rescaleAsRequired defines if rescaling must be applied if required
  72497. * @param skelDimensionsRatio defines the scaling ratio
  72498. * @returns true if operation was successful
  72499. */
  72500. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  72501. }
  72502. }
  72503. declare module BABYLON {
  72504. /**
  72505. * Class used to handle skinning animations
  72506. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  72507. */
  72508. export class Skeleton implements IAnimatable {
  72509. /** defines the skeleton name */
  72510. name: string;
  72511. /** defines the skeleton Id */
  72512. id: string;
  72513. /**
  72514. * Defines the list of child bones
  72515. */
  72516. bones: Bone[];
  72517. /**
  72518. * Defines an estimate of the dimension of the skeleton at rest
  72519. */
  72520. dimensionsAtRest: Vector3;
  72521. /**
  72522. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  72523. */
  72524. needInitialSkinMatrix: boolean;
  72525. /**
  72526. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  72527. */
  72528. overrideMesh: Nullable<AbstractMesh>;
  72529. /**
  72530. * Gets the list of animations attached to this skeleton
  72531. */
  72532. animations: Array<Animation>;
  72533. private _scene;
  72534. private _isDirty;
  72535. private _transformMatrices;
  72536. private _transformMatrixTexture;
  72537. private _meshesWithPoseMatrix;
  72538. private _animatables;
  72539. private _identity;
  72540. private _synchronizedWithMesh;
  72541. private _ranges;
  72542. private _lastAbsoluteTransformsUpdateId;
  72543. private _canUseTextureForBones;
  72544. private _uniqueId;
  72545. /** @hidden */
  72546. _numBonesWithLinkedTransformNode: number;
  72547. /** @hidden */
  72548. _hasWaitingData: Nullable<boolean>;
  72549. /**
  72550. * Specifies if the skeleton should be serialized
  72551. */
  72552. doNotSerialize: boolean;
  72553. private _useTextureToStoreBoneMatrices;
  72554. /**
  72555. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  72556. * Please note that this option is not available if the hardware does not support it
  72557. */
  72558. useTextureToStoreBoneMatrices: boolean;
  72559. private _animationPropertiesOverride;
  72560. /**
  72561. * Gets or sets the animation properties override
  72562. */
  72563. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  72564. /**
  72565. * List of inspectable custom properties (used by the Inspector)
  72566. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72567. */
  72568. inspectableCustomProperties: IInspectable[];
  72569. /**
  72570. * An observable triggered before computing the skeleton's matrices
  72571. */
  72572. onBeforeComputeObservable: Observable<Skeleton>;
  72573. /**
  72574. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  72575. */
  72576. readonly isUsingTextureForMatrices: boolean;
  72577. /**
  72578. * Gets the unique ID of this skeleton
  72579. */
  72580. readonly uniqueId: number;
  72581. /**
  72582. * Creates a new skeleton
  72583. * @param name defines the skeleton name
  72584. * @param id defines the skeleton Id
  72585. * @param scene defines the hosting scene
  72586. */
  72587. constructor(
  72588. /** defines the skeleton name */
  72589. name: string,
  72590. /** defines the skeleton Id */
  72591. id: string, scene: Scene);
  72592. /**
  72593. * Gets the current object class name.
  72594. * @return the class name
  72595. */
  72596. getClassName(): string;
  72597. /**
  72598. * Returns an array containing the root bones
  72599. * @returns an array containing the root bones
  72600. */
  72601. getChildren(): Array<Bone>;
  72602. /**
  72603. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  72604. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  72605. * @returns a Float32Array containing matrices data
  72606. */
  72607. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  72608. /**
  72609. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  72610. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  72611. * @returns a raw texture containing the data
  72612. */
  72613. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  72614. /**
  72615. * Gets the current hosting scene
  72616. * @returns a scene object
  72617. */
  72618. getScene(): Scene;
  72619. /**
  72620. * Gets a string representing the current skeleton data
  72621. * @param fullDetails defines a boolean indicating if we want a verbose version
  72622. * @returns a string representing the current skeleton data
  72623. */
  72624. toString(fullDetails?: boolean): string;
  72625. /**
  72626. * Get bone's index searching by name
  72627. * @param name defines bone's name to search for
  72628. * @return the indice of the bone. Returns -1 if not found
  72629. */
  72630. getBoneIndexByName(name: string): number;
  72631. /**
  72632. * Creater a new animation range
  72633. * @param name defines the name of the range
  72634. * @param from defines the start key
  72635. * @param to defines the end key
  72636. */
  72637. createAnimationRange(name: string, from: number, to: number): void;
  72638. /**
  72639. * Delete a specific animation range
  72640. * @param name defines the name of the range
  72641. * @param deleteFrames defines if frames must be removed as well
  72642. */
  72643. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  72644. /**
  72645. * Gets a specific animation range
  72646. * @param name defines the name of the range to look for
  72647. * @returns the requested animation range or null if not found
  72648. */
  72649. getAnimationRange(name: string): Nullable<AnimationRange>;
  72650. /**
  72651. * Gets the list of all animation ranges defined on this skeleton
  72652. * @returns an array
  72653. */
  72654. getAnimationRanges(): Nullable<AnimationRange>[];
  72655. /**
  72656. * Copy animation range from a source skeleton.
  72657. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  72658. * @param source defines the source skeleton
  72659. * @param name defines the name of the range to copy
  72660. * @param rescaleAsRequired defines if rescaling must be applied if required
  72661. * @returns true if operation was successful
  72662. */
  72663. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  72664. /**
  72665. * Forces the skeleton to go to rest pose
  72666. */
  72667. returnToRest(): void;
  72668. private _getHighestAnimationFrame;
  72669. /**
  72670. * Begin a specific animation range
  72671. * @param name defines the name of the range to start
  72672. * @param loop defines if looping must be turned on (false by default)
  72673. * @param speedRatio defines the speed ratio to apply (1 by default)
  72674. * @param onAnimationEnd defines a callback which will be called when animation will end
  72675. * @returns a new animatable
  72676. */
  72677. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  72678. /** @hidden */
  72679. _markAsDirty(): void;
  72680. /** @hidden */
  72681. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  72682. /** @hidden */
  72683. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  72684. private _computeTransformMatrices;
  72685. /**
  72686. * Build all resources required to render a skeleton
  72687. */
  72688. prepare(): void;
  72689. /**
  72690. * Gets the list of animatables currently running for this skeleton
  72691. * @returns an array of animatables
  72692. */
  72693. getAnimatables(): IAnimatable[];
  72694. /**
  72695. * Clone the current skeleton
  72696. * @param name defines the name of the new skeleton
  72697. * @param id defines the id of the new skeleton
  72698. * @returns the new skeleton
  72699. */
  72700. clone(name: string, id: string): Skeleton;
  72701. /**
  72702. * Enable animation blending for this skeleton
  72703. * @param blendingSpeed defines the blending speed to apply
  72704. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  72705. */
  72706. enableBlending(blendingSpeed?: number): void;
  72707. /**
  72708. * Releases all resources associated with the current skeleton
  72709. */
  72710. dispose(): void;
  72711. /**
  72712. * Serialize the skeleton in a JSON object
  72713. * @returns a JSON object
  72714. */
  72715. serialize(): any;
  72716. /**
  72717. * Creates a new skeleton from serialized data
  72718. * @param parsedSkeleton defines the serialized data
  72719. * @param scene defines the hosting scene
  72720. * @returns a new skeleton
  72721. */
  72722. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  72723. /**
  72724. * Compute all node absolute transforms
  72725. * @param forceUpdate defines if computation must be done even if cache is up to date
  72726. */
  72727. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  72728. /**
  72729. * Gets the root pose matrix
  72730. * @returns a matrix
  72731. */
  72732. getPoseMatrix(): Nullable<Matrix>;
  72733. /**
  72734. * Sorts bones per internal index
  72735. */
  72736. sortBones(): void;
  72737. private _sortBones;
  72738. }
  72739. }
  72740. declare module BABYLON {
  72741. /**
  72742. * Defines a target to use with MorphTargetManager
  72743. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  72744. */
  72745. export class MorphTarget implements IAnimatable {
  72746. /** defines the name of the target */
  72747. name: string;
  72748. /**
  72749. * Gets or sets the list of animations
  72750. */
  72751. animations: Animation[];
  72752. private _scene;
  72753. private _positions;
  72754. private _normals;
  72755. private _tangents;
  72756. private _uvs;
  72757. private _influence;
  72758. /**
  72759. * Observable raised when the influence changes
  72760. */
  72761. onInfluenceChanged: Observable<boolean>;
  72762. /** @hidden */
  72763. _onDataLayoutChanged: Observable<void>;
  72764. /**
  72765. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  72766. */
  72767. influence: number;
  72768. /**
  72769. * Gets or sets the id of the morph Target
  72770. */
  72771. id: string;
  72772. private _animationPropertiesOverride;
  72773. /**
  72774. * Gets or sets the animation properties override
  72775. */
  72776. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  72777. /**
  72778. * Creates a new MorphTarget
  72779. * @param name defines the name of the target
  72780. * @param influence defines the influence to use
  72781. * @param scene defines the scene the morphtarget belongs to
  72782. */
  72783. constructor(
  72784. /** defines the name of the target */
  72785. name: string, influence?: number, scene?: Nullable<Scene>);
  72786. /**
  72787. * Gets a boolean defining if the target contains position data
  72788. */
  72789. readonly hasPositions: boolean;
  72790. /**
  72791. * Gets a boolean defining if the target contains normal data
  72792. */
  72793. readonly hasNormals: boolean;
  72794. /**
  72795. * Gets a boolean defining if the target contains tangent data
  72796. */
  72797. readonly hasTangents: boolean;
  72798. /**
  72799. * Gets a boolean defining if the target contains texture coordinates data
  72800. */
  72801. readonly hasUVs: boolean;
  72802. /**
  72803. * Affects position data to this target
  72804. * @param data defines the position data to use
  72805. */
  72806. setPositions(data: Nullable<FloatArray>): void;
  72807. /**
  72808. * Gets the position data stored in this target
  72809. * @returns a FloatArray containing the position data (or null if not present)
  72810. */
  72811. getPositions(): Nullable<FloatArray>;
  72812. /**
  72813. * Affects normal data to this target
  72814. * @param data defines the normal data to use
  72815. */
  72816. setNormals(data: Nullable<FloatArray>): void;
  72817. /**
  72818. * Gets the normal data stored in this target
  72819. * @returns a FloatArray containing the normal data (or null if not present)
  72820. */
  72821. getNormals(): Nullable<FloatArray>;
  72822. /**
  72823. * Affects tangent data to this target
  72824. * @param data defines the tangent data to use
  72825. */
  72826. setTangents(data: Nullable<FloatArray>): void;
  72827. /**
  72828. * Gets the tangent data stored in this target
  72829. * @returns a FloatArray containing the tangent data (or null if not present)
  72830. */
  72831. getTangents(): Nullable<FloatArray>;
  72832. /**
  72833. * Affects texture coordinates data to this target
  72834. * @param data defines the texture coordinates data to use
  72835. */
  72836. setUVs(data: Nullable<FloatArray>): void;
  72837. /**
  72838. * Gets the texture coordinates data stored in this target
  72839. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  72840. */
  72841. getUVs(): Nullable<FloatArray>;
  72842. /**
  72843. * Serializes the current target into a Serialization object
  72844. * @returns the serialized object
  72845. */
  72846. serialize(): any;
  72847. /**
  72848. * Returns the string "MorphTarget"
  72849. * @returns "MorphTarget"
  72850. */
  72851. getClassName(): string;
  72852. /**
  72853. * Creates a new target from serialized data
  72854. * @param serializationObject defines the serialized data to use
  72855. * @returns a new MorphTarget
  72856. */
  72857. static Parse(serializationObject: any): MorphTarget;
  72858. /**
  72859. * Creates a MorphTarget from mesh data
  72860. * @param mesh defines the source mesh
  72861. * @param name defines the name to use for the new target
  72862. * @param influence defines the influence to attach to the target
  72863. * @returns a new MorphTarget
  72864. */
  72865. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  72866. }
  72867. }
  72868. declare module BABYLON {
  72869. /**
  72870. * This class is used to deform meshes using morphing between different targets
  72871. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  72872. */
  72873. export class MorphTargetManager {
  72874. private _targets;
  72875. private _targetInfluenceChangedObservers;
  72876. private _targetDataLayoutChangedObservers;
  72877. private _activeTargets;
  72878. private _scene;
  72879. private _influences;
  72880. private _supportsNormals;
  72881. private _supportsTangents;
  72882. private _supportsUVs;
  72883. private _vertexCount;
  72884. private _uniqueId;
  72885. private _tempInfluences;
  72886. /**
  72887. * Gets or sets a boolean indicating if normals must be morphed
  72888. */
  72889. enableNormalMorphing: boolean;
  72890. /**
  72891. * Gets or sets a boolean indicating if tangents must be morphed
  72892. */
  72893. enableTangentMorphing: boolean;
  72894. /**
  72895. * Gets or sets a boolean indicating if UV must be morphed
  72896. */
  72897. enableUVMorphing: boolean;
  72898. /**
  72899. * Creates a new MorphTargetManager
  72900. * @param scene defines the current scene
  72901. */
  72902. constructor(scene?: Nullable<Scene>);
  72903. /**
  72904. * Gets the unique ID of this manager
  72905. */
  72906. readonly uniqueId: number;
  72907. /**
  72908. * Gets the number of vertices handled by this manager
  72909. */
  72910. readonly vertexCount: number;
  72911. /**
  72912. * Gets a boolean indicating if this manager supports morphing of normals
  72913. */
  72914. readonly supportsNormals: boolean;
  72915. /**
  72916. * Gets a boolean indicating if this manager supports morphing of tangents
  72917. */
  72918. readonly supportsTangents: boolean;
  72919. /**
  72920. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  72921. */
  72922. readonly supportsUVs: boolean;
  72923. /**
  72924. * Gets the number of targets stored in this manager
  72925. */
  72926. readonly numTargets: number;
  72927. /**
  72928. * Gets the number of influencers (ie. the number of targets with influences > 0)
  72929. */
  72930. readonly numInfluencers: number;
  72931. /**
  72932. * Gets the list of influences (one per target)
  72933. */
  72934. readonly influences: Float32Array;
  72935. /**
  72936. * Gets the active target at specified index. An active target is a target with an influence > 0
  72937. * @param index defines the index to check
  72938. * @returns the requested target
  72939. */
  72940. getActiveTarget(index: number): MorphTarget;
  72941. /**
  72942. * Gets the target at specified index
  72943. * @param index defines the index to check
  72944. * @returns the requested target
  72945. */
  72946. getTarget(index: number): MorphTarget;
  72947. /**
  72948. * Add a new target to this manager
  72949. * @param target defines the target to add
  72950. */
  72951. addTarget(target: MorphTarget): void;
  72952. /**
  72953. * Removes a target from the manager
  72954. * @param target defines the target to remove
  72955. */
  72956. removeTarget(target: MorphTarget): void;
  72957. /**
  72958. * Serializes the current manager into a Serialization object
  72959. * @returns the serialized object
  72960. */
  72961. serialize(): any;
  72962. private _syncActiveTargets;
  72963. /**
  72964. * Syncrhonize the targets with all the meshes using this morph target manager
  72965. */
  72966. synchronize(): void;
  72967. /**
  72968. * Creates a new MorphTargetManager from serialized data
  72969. * @param serializationObject defines the serialized data
  72970. * @param scene defines the hosting scene
  72971. * @returns the new MorphTargetManager
  72972. */
  72973. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  72974. }
  72975. }
  72976. declare module BABYLON {
  72977. /**
  72978. * Groups all the scene component constants in one place to ease maintenance.
  72979. * @hidden
  72980. */
  72981. export class SceneComponentConstants {
  72982. static readonly NAME_EFFECTLAYER: string;
  72983. static readonly NAME_LAYER: string;
  72984. static readonly NAME_LENSFLARESYSTEM: string;
  72985. static readonly NAME_BOUNDINGBOXRENDERER: string;
  72986. static readonly NAME_PARTICLESYSTEM: string;
  72987. static readonly NAME_GAMEPAD: string;
  72988. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  72989. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  72990. static readonly NAME_DEPTHRENDERER: string;
  72991. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  72992. static readonly NAME_SPRITE: string;
  72993. static readonly NAME_OUTLINERENDERER: string;
  72994. static readonly NAME_PROCEDURALTEXTURE: string;
  72995. static readonly NAME_SHADOWGENERATOR: string;
  72996. static readonly NAME_OCTREE: string;
  72997. static readonly NAME_PHYSICSENGINE: string;
  72998. static readonly NAME_AUDIO: string;
  72999. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  73000. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  73001. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  73002. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  73003. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  73004. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  73005. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  73006. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  73007. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  73008. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  73009. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  73010. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  73011. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  73012. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  73013. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  73014. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  73015. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  73016. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  73017. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  73018. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  73019. static readonly STEP_AFTERRENDER_AUDIO: number;
  73020. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  73021. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  73022. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  73023. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  73024. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  73025. static readonly STEP_POINTERMOVE_SPRITE: number;
  73026. static readonly STEP_POINTERDOWN_SPRITE: number;
  73027. static readonly STEP_POINTERUP_SPRITE: number;
  73028. }
  73029. /**
  73030. * This represents a scene component.
  73031. *
  73032. * This is used to decouple the dependency the scene is having on the different workloads like
  73033. * layers, post processes...
  73034. */
  73035. export interface ISceneComponent {
  73036. /**
  73037. * The name of the component. Each component must have a unique name.
  73038. */
  73039. name: string;
  73040. /**
  73041. * The scene the component belongs to.
  73042. */
  73043. scene: Scene;
  73044. /**
  73045. * Register the component to one instance of a scene.
  73046. */
  73047. register(): void;
  73048. /**
  73049. * Rebuilds the elements related to this component in case of
  73050. * context lost for instance.
  73051. */
  73052. rebuild(): void;
  73053. /**
  73054. * Disposes the component and the associated ressources.
  73055. */
  73056. dispose(): void;
  73057. }
  73058. /**
  73059. * This represents a SERIALIZABLE scene component.
  73060. *
  73061. * This extends Scene Component to add Serialization methods on top.
  73062. */
  73063. export interface ISceneSerializableComponent extends ISceneComponent {
  73064. /**
  73065. * Adds all the elements from the container to the scene
  73066. * @param container the container holding the elements
  73067. */
  73068. addFromContainer(container: AbstractScene): void;
  73069. /**
  73070. * Removes all the elements in the container from the scene
  73071. * @param container contains the elements to remove
  73072. * @param dispose if the removed element should be disposed (default: false)
  73073. */
  73074. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  73075. /**
  73076. * Serializes the component data to the specified json object
  73077. * @param serializationObject The object to serialize to
  73078. */
  73079. serialize(serializationObject: any): void;
  73080. }
  73081. /**
  73082. * Strong typing of a Mesh related stage step action
  73083. */
  73084. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  73085. /**
  73086. * Strong typing of a Evaluate Sub Mesh related stage step action
  73087. */
  73088. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  73089. /**
  73090. * Strong typing of a Active Mesh related stage step action
  73091. */
  73092. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  73093. /**
  73094. * Strong typing of a Camera related stage step action
  73095. */
  73096. export type CameraStageAction = (camera: Camera) => void;
  73097. /**
  73098. * Strong typing of a Camera Frame buffer related stage step action
  73099. */
  73100. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  73101. /**
  73102. * Strong typing of a Render Target related stage step action
  73103. */
  73104. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  73105. /**
  73106. * Strong typing of a RenderingGroup related stage step action
  73107. */
  73108. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  73109. /**
  73110. * Strong typing of a Mesh Render related stage step action
  73111. */
  73112. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  73113. /**
  73114. * Strong typing of a simple stage step action
  73115. */
  73116. export type SimpleStageAction = () => void;
  73117. /**
  73118. * Strong typing of a render target action.
  73119. */
  73120. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  73121. /**
  73122. * Strong typing of a pointer move action.
  73123. */
  73124. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  73125. /**
  73126. * Strong typing of a pointer up/down action.
  73127. */
  73128. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  73129. /**
  73130. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  73131. * @hidden
  73132. */
  73133. export class Stage<T extends Function> extends Array<{
  73134. index: number;
  73135. component: ISceneComponent;
  73136. action: T;
  73137. }> {
  73138. /**
  73139. * Hide ctor from the rest of the world.
  73140. * @param items The items to add.
  73141. */
  73142. private constructor();
  73143. /**
  73144. * Creates a new Stage.
  73145. * @returns A new instance of a Stage
  73146. */
  73147. static Create<T extends Function>(): Stage<T>;
  73148. /**
  73149. * Registers a step in an ordered way in the targeted stage.
  73150. * @param index Defines the position to register the step in
  73151. * @param component Defines the component attached to the step
  73152. * @param action Defines the action to launch during the step
  73153. */
  73154. registerStep(index: number, component: ISceneComponent, action: T): void;
  73155. /**
  73156. * Clears all the steps from the stage.
  73157. */
  73158. clear(): void;
  73159. }
  73160. }
  73161. declare module BABYLON {
  73162. /**
  73163. * Class used to represent a specific level of detail of a mesh
  73164. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  73165. */
  73166. export class MeshLODLevel {
  73167. /** Defines the distance where this level should star being displayed */
  73168. distance: number;
  73169. /** Defines the mesh to use to render this level */
  73170. mesh: Nullable<Mesh>;
  73171. /**
  73172. * Creates a new LOD level
  73173. * @param distance defines the distance where this level should star being displayed
  73174. * @param mesh defines the mesh to use to render this level
  73175. */
  73176. constructor(
  73177. /** Defines the distance where this level should star being displayed */
  73178. distance: number,
  73179. /** Defines the mesh to use to render this level */
  73180. mesh: Nullable<Mesh>);
  73181. }
  73182. }
  73183. declare module BABYLON {
  73184. /**
  73185. * Interface describing all the common properties and methods a shadow light needs to implement.
  73186. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  73187. * as well as binding the different shadow properties to the effects.
  73188. */
  73189. export interface IShadowLight extends Light {
  73190. /**
  73191. * The light id in the scene (used in scene.findLighById for instance)
  73192. */
  73193. id: string;
  73194. /**
  73195. * The position the shdow will be casted from.
  73196. */
  73197. position: Vector3;
  73198. /**
  73199. * In 2d mode (needCube being false), the direction used to cast the shadow.
  73200. */
  73201. direction: Vector3;
  73202. /**
  73203. * The transformed position. Position of the light in world space taking parenting in account.
  73204. */
  73205. transformedPosition: Vector3;
  73206. /**
  73207. * The transformed direction. Direction of the light in world space taking parenting in account.
  73208. */
  73209. transformedDirection: Vector3;
  73210. /**
  73211. * The friendly name of the light in the scene.
  73212. */
  73213. name: string;
  73214. /**
  73215. * Defines the shadow projection clipping minimum z value.
  73216. */
  73217. shadowMinZ: number;
  73218. /**
  73219. * Defines the shadow projection clipping maximum z value.
  73220. */
  73221. shadowMaxZ: number;
  73222. /**
  73223. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73224. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73225. */
  73226. computeTransformedInformation(): boolean;
  73227. /**
  73228. * Gets the scene the light belongs to.
  73229. * @returns The scene
  73230. */
  73231. getScene(): Scene;
  73232. /**
  73233. * Callback defining a custom Projection Matrix Builder.
  73234. * This can be used to override the default projection matrix computation.
  73235. */
  73236. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73237. /**
  73238. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73239. * @param matrix The materix to updated with the projection information
  73240. * @param viewMatrix The transform matrix of the light
  73241. * @param renderList The list of mesh to render in the map
  73242. * @returns The current light
  73243. */
  73244. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73245. /**
  73246. * Gets the current depth scale used in ESM.
  73247. * @returns The scale
  73248. */
  73249. getDepthScale(): number;
  73250. /**
  73251. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73252. * @returns true if a cube texture needs to be use
  73253. */
  73254. needCube(): boolean;
  73255. /**
  73256. * Detects if the projection matrix requires to be recomputed this frame.
  73257. * @returns true if it requires to be recomputed otherwise, false.
  73258. */
  73259. needProjectionMatrixCompute(): boolean;
  73260. /**
  73261. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73262. */
  73263. forceProjectionMatrixCompute(): void;
  73264. /**
  73265. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73266. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73267. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73268. */
  73269. getShadowDirection(faceIndex?: number): Vector3;
  73270. /**
  73271. * Gets the minZ used for shadow according to both the scene and the light.
  73272. * @param activeCamera The camera we are returning the min for
  73273. * @returns the depth min z
  73274. */
  73275. getDepthMinZ(activeCamera: Camera): number;
  73276. /**
  73277. * Gets the maxZ used for shadow according to both the scene and the light.
  73278. * @param activeCamera The camera we are returning the max for
  73279. * @returns the depth max z
  73280. */
  73281. getDepthMaxZ(activeCamera: Camera): number;
  73282. }
  73283. /**
  73284. * Base implementation IShadowLight
  73285. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  73286. */
  73287. export abstract class ShadowLight extends Light implements IShadowLight {
  73288. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  73289. protected _position: Vector3;
  73290. protected _setPosition(value: Vector3): void;
  73291. /**
  73292. * Sets the position the shadow will be casted from. Also use as the light position for both
  73293. * point and spot lights.
  73294. */
  73295. /**
  73296. * Sets the position the shadow will be casted from. Also use as the light position for both
  73297. * point and spot lights.
  73298. */
  73299. position: Vector3;
  73300. protected _direction: Vector3;
  73301. protected _setDirection(value: Vector3): void;
  73302. /**
  73303. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  73304. * Also use as the light direction on spot and directional lights.
  73305. */
  73306. /**
  73307. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  73308. * Also use as the light direction on spot and directional lights.
  73309. */
  73310. direction: Vector3;
  73311. private _shadowMinZ;
  73312. /**
  73313. * Gets the shadow projection clipping minimum z value.
  73314. */
  73315. /**
  73316. * Sets the shadow projection clipping minimum z value.
  73317. */
  73318. shadowMinZ: number;
  73319. private _shadowMaxZ;
  73320. /**
  73321. * Sets the shadow projection clipping maximum z value.
  73322. */
  73323. /**
  73324. * Gets the shadow projection clipping maximum z value.
  73325. */
  73326. shadowMaxZ: number;
  73327. /**
  73328. * Callback defining a custom Projection Matrix Builder.
  73329. * This can be used to override the default projection matrix computation.
  73330. */
  73331. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  73332. /**
  73333. * The transformed position. Position of the light in world space taking parenting in account.
  73334. */
  73335. transformedPosition: Vector3;
  73336. /**
  73337. * The transformed direction. Direction of the light in world space taking parenting in account.
  73338. */
  73339. transformedDirection: Vector3;
  73340. private _needProjectionMatrixCompute;
  73341. /**
  73342. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  73343. * @returns true if the information has been computed, false if it does not need to (no parenting)
  73344. */
  73345. computeTransformedInformation(): boolean;
  73346. /**
  73347. * Return the depth scale used for the shadow map.
  73348. * @returns the depth scale.
  73349. */
  73350. getDepthScale(): number;
  73351. /**
  73352. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  73353. * @param faceIndex The index of the face we are computed the direction to generate shadow
  73354. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  73355. */
  73356. getShadowDirection(faceIndex?: number): Vector3;
  73357. /**
  73358. * Returns the ShadowLight absolute position in the World.
  73359. * @returns the position vector in world space
  73360. */
  73361. getAbsolutePosition(): Vector3;
  73362. /**
  73363. * Sets the ShadowLight direction toward the passed target.
  73364. * @param target The point to target in local space
  73365. * @returns the updated ShadowLight direction
  73366. */
  73367. setDirectionToTarget(target: Vector3): Vector3;
  73368. /**
  73369. * Returns the light rotation in euler definition.
  73370. * @returns the x y z rotation in local space.
  73371. */
  73372. getRotation(): Vector3;
  73373. /**
  73374. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  73375. * @returns true if a cube texture needs to be use
  73376. */
  73377. needCube(): boolean;
  73378. /**
  73379. * Detects if the projection matrix requires to be recomputed this frame.
  73380. * @returns true if it requires to be recomputed otherwise, false.
  73381. */
  73382. needProjectionMatrixCompute(): boolean;
  73383. /**
  73384. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  73385. */
  73386. forceProjectionMatrixCompute(): void;
  73387. /** @hidden */
  73388. _initCache(): void;
  73389. /** @hidden */
  73390. _isSynchronized(): boolean;
  73391. /**
  73392. * Computes the world matrix of the node
  73393. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  73394. * @returns the world matrix
  73395. */
  73396. computeWorldMatrix(force?: boolean): Matrix;
  73397. /**
  73398. * Gets the minZ used for shadow according to both the scene and the light.
  73399. * @param activeCamera The camera we are returning the min for
  73400. * @returns the depth min z
  73401. */
  73402. getDepthMinZ(activeCamera: Camera): number;
  73403. /**
  73404. * Gets the maxZ used for shadow according to both the scene and the light.
  73405. * @param activeCamera The camera we are returning the max for
  73406. * @returns the depth max z
  73407. */
  73408. getDepthMaxZ(activeCamera: Camera): number;
  73409. /**
  73410. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  73411. * @param matrix The materix to updated with the projection information
  73412. * @param viewMatrix The transform matrix of the light
  73413. * @param renderList The list of mesh to render in the map
  73414. * @returns The current light
  73415. */
  73416. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  73417. }
  73418. }
  73419. declare module BABYLON {
  73420. /**
  73421. * "Static Class" containing the most commonly used helper while dealing with material for
  73422. * rendering purpose.
  73423. *
  73424. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  73425. *
  73426. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  73427. */
  73428. export class MaterialHelper {
  73429. /**
  73430. * Bind the current view position to an effect.
  73431. * @param effect The effect to be bound
  73432. * @param scene The scene the eyes position is used from
  73433. */
  73434. static BindEyePosition(effect: Effect, scene: Scene): void;
  73435. /**
  73436. * Helps preparing the defines values about the UVs in used in the effect.
  73437. * UVs are shared as much as we can accross channels in the shaders.
  73438. * @param texture The texture we are preparing the UVs for
  73439. * @param defines The defines to update
  73440. * @param key The channel key "diffuse", "specular"... used in the shader
  73441. */
  73442. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  73443. /**
  73444. * Binds a texture matrix value to its corrsponding uniform
  73445. * @param texture The texture to bind the matrix for
  73446. * @param uniformBuffer The uniform buffer receivin the data
  73447. * @param key The channel key "diffuse", "specular"... used in the shader
  73448. */
  73449. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  73450. /**
  73451. * Gets the current status of the fog (should it be enabled?)
  73452. * @param mesh defines the mesh to evaluate for fog support
  73453. * @param scene defines the hosting scene
  73454. * @returns true if fog must be enabled
  73455. */
  73456. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  73457. /**
  73458. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  73459. * @param mesh defines the current mesh
  73460. * @param scene defines the current scene
  73461. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  73462. * @param pointsCloud defines if point cloud rendering has to be turned on
  73463. * @param fogEnabled defines if fog has to be turned on
  73464. * @param alphaTest defines if alpha testing has to be turned on
  73465. * @param defines defines the current list of defines
  73466. */
  73467. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  73468. /**
  73469. * Helper used to prepare the list of defines associated with frame values for shader compilation
  73470. * @param scene defines the current scene
  73471. * @param engine defines the current engine
  73472. * @param defines specifies the list of active defines
  73473. * @param useInstances defines if instances have to be turned on
  73474. * @param useClipPlane defines if clip plane have to be turned on
  73475. */
  73476. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  73477. /**
  73478. * Prepares the defines for bones
  73479. * @param mesh The mesh containing the geometry data we will draw
  73480. * @param defines The defines to update
  73481. */
  73482. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  73483. /**
  73484. * Prepares the defines for morph targets
  73485. * @param mesh The mesh containing the geometry data we will draw
  73486. * @param defines The defines to update
  73487. */
  73488. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  73489. /**
  73490. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  73491. * @param mesh The mesh containing the geometry data we will draw
  73492. * @param defines The defines to update
  73493. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  73494. * @param useBones Precise whether bones should be used or not (override mesh info)
  73495. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  73496. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  73497. * @returns false if defines are considered not dirty and have not been checked
  73498. */
  73499. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  73500. /**
  73501. * Prepares the defines related to multiview
  73502. * @param scene The scene we are intending to draw
  73503. * @param defines The defines to update
  73504. */
  73505. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  73506. /**
  73507. * Prepares the defines related to the light information passed in parameter
  73508. * @param scene The scene we are intending to draw
  73509. * @param mesh The mesh the effect is compiling for
  73510. * @param light The light the effect is compiling for
  73511. * @param lightIndex The index of the light
  73512. * @param defines The defines to update
  73513. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73514. * @param state Defines the current state regarding what is needed (normals, etc...)
  73515. */
  73516. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  73517. needNormals: boolean;
  73518. needRebuild: boolean;
  73519. shadowEnabled: boolean;
  73520. specularEnabled: boolean;
  73521. lightmapMode: boolean;
  73522. }): void;
  73523. /**
  73524. * Prepares the defines related to the light information passed in parameter
  73525. * @param scene The scene we are intending to draw
  73526. * @param mesh The mesh the effect is compiling for
  73527. * @param defines The defines to update
  73528. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  73529. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  73530. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  73531. * @returns true if normals will be required for the rest of the effect
  73532. */
  73533. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  73534. /**
  73535. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  73536. * @param lightIndex defines the light index
  73537. * @param uniformsList The uniform list
  73538. * @param samplersList The sampler list
  73539. * @param projectedLightTexture defines if projected texture must be used
  73540. * @param uniformBuffersList defines an optional list of uniform buffers
  73541. */
  73542. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  73543. /**
  73544. * Prepares the uniforms and samplers list to be used in the effect
  73545. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  73546. * @param samplersList The sampler list
  73547. * @param defines The defines helping in the list generation
  73548. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  73549. */
  73550. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  73551. /**
  73552. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  73553. * @param defines The defines to update while falling back
  73554. * @param fallbacks The authorized effect fallbacks
  73555. * @param maxSimultaneousLights The maximum number of lights allowed
  73556. * @param rank the current rank of the Effect
  73557. * @returns The newly affected rank
  73558. */
  73559. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  73560. private static _TmpMorphInfluencers;
  73561. /**
  73562. * Prepares the list of attributes required for morph targets according to the effect defines.
  73563. * @param attribs The current list of supported attribs
  73564. * @param mesh The mesh to prepare the morph targets attributes for
  73565. * @param influencers The number of influencers
  73566. */
  73567. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  73568. /**
  73569. * Prepares the list of attributes required for morph targets according to the effect defines.
  73570. * @param attribs The current list of supported attribs
  73571. * @param mesh The mesh to prepare the morph targets attributes for
  73572. * @param defines The current Defines of the effect
  73573. */
  73574. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  73575. /**
  73576. * Prepares the list of attributes required for bones according to the effect defines.
  73577. * @param attribs The current list of supported attribs
  73578. * @param mesh The mesh to prepare the bones attributes for
  73579. * @param defines The current Defines of the effect
  73580. * @param fallbacks The current efffect fallback strategy
  73581. */
  73582. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  73583. /**
  73584. * Check and prepare the list of attributes required for instances according to the effect defines.
  73585. * @param attribs The current list of supported attribs
  73586. * @param defines The current MaterialDefines of the effect
  73587. */
  73588. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  73589. /**
  73590. * Add the list of attributes required for instances to the attribs array.
  73591. * @param attribs The current list of supported attribs
  73592. */
  73593. static PushAttributesForInstances(attribs: string[]): void;
  73594. /**
  73595. * Binds the light shadow information to the effect for the given mesh.
  73596. * @param light The light containing the generator
  73597. * @param scene The scene the lights belongs to
  73598. * @param mesh The mesh we are binding the information to render
  73599. * @param lightIndex The light index in the effect used to render the mesh
  73600. * @param effect The effect we are binding the data to
  73601. */
  73602. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  73603. /**
  73604. * Binds the light information to the effect.
  73605. * @param light The light containing the generator
  73606. * @param effect The effect we are binding the data to
  73607. * @param lightIndex The light index in the effect used to render
  73608. */
  73609. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  73610. /**
  73611. * Binds the lights information from the scene to the effect for the given mesh.
  73612. * @param light Light to bind
  73613. * @param lightIndex Light index
  73614. * @param scene The scene where the light belongs to
  73615. * @param mesh The mesh we are binding the information to render
  73616. * @param effect The effect we are binding the data to
  73617. * @param useSpecular Defines if specular is supported
  73618. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  73619. */
  73620. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  73621. /**
  73622. * Binds the lights information from the scene to the effect for the given mesh.
  73623. * @param scene The scene the lights belongs to
  73624. * @param mesh The mesh we are binding the information to render
  73625. * @param effect The effect we are binding the data to
  73626. * @param defines The generated defines for the effect
  73627. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  73628. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  73629. */
  73630. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  73631. private static _tempFogColor;
  73632. /**
  73633. * Binds the fog information from the scene to the effect for the given mesh.
  73634. * @param scene The scene the lights belongs to
  73635. * @param mesh The mesh we are binding the information to render
  73636. * @param effect The effect we are binding the data to
  73637. * @param linearSpace Defines if the fog effect is applied in linear space
  73638. */
  73639. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  73640. /**
  73641. * Binds the bones information from the mesh to the effect.
  73642. * @param mesh The mesh we are binding the information to render
  73643. * @param effect The effect we are binding the data to
  73644. */
  73645. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  73646. /**
  73647. * Binds the morph targets information from the mesh to the effect.
  73648. * @param abstractMesh The mesh we are binding the information to render
  73649. * @param effect The effect we are binding the data to
  73650. */
  73651. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  73652. /**
  73653. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  73654. * @param defines The generated defines used in the effect
  73655. * @param effect The effect we are binding the data to
  73656. * @param scene The scene we are willing to render with logarithmic scale for
  73657. */
  73658. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  73659. /**
  73660. * Binds the clip plane information from the scene to the effect.
  73661. * @param scene The scene the clip plane information are extracted from
  73662. * @param effect The effect we are binding the data to
  73663. */
  73664. static BindClipPlane(effect: Effect, scene: Scene): void;
  73665. }
  73666. }
  73667. declare module BABYLON {
  73668. /** @hidden */
  73669. export var shadowMapPixelShader: {
  73670. name: string;
  73671. shader: string;
  73672. };
  73673. }
  73674. declare module BABYLON {
  73675. /** @hidden */
  73676. export var bonesDeclaration: {
  73677. name: string;
  73678. shader: string;
  73679. };
  73680. }
  73681. declare module BABYLON {
  73682. /** @hidden */
  73683. export var morphTargetsVertexGlobalDeclaration: {
  73684. name: string;
  73685. shader: string;
  73686. };
  73687. }
  73688. declare module BABYLON {
  73689. /** @hidden */
  73690. export var morphTargetsVertexDeclaration: {
  73691. name: string;
  73692. shader: string;
  73693. };
  73694. }
  73695. declare module BABYLON {
  73696. /** @hidden */
  73697. export var instancesDeclaration: {
  73698. name: string;
  73699. shader: string;
  73700. };
  73701. }
  73702. declare module BABYLON {
  73703. /** @hidden */
  73704. export var helperFunctions: {
  73705. name: string;
  73706. shader: string;
  73707. };
  73708. }
  73709. declare module BABYLON {
  73710. /** @hidden */
  73711. export var morphTargetsVertex: {
  73712. name: string;
  73713. shader: string;
  73714. };
  73715. }
  73716. declare module BABYLON {
  73717. /** @hidden */
  73718. export var instancesVertex: {
  73719. name: string;
  73720. shader: string;
  73721. };
  73722. }
  73723. declare module BABYLON {
  73724. /** @hidden */
  73725. export var bonesVertex: {
  73726. name: string;
  73727. shader: string;
  73728. };
  73729. }
  73730. declare module BABYLON {
  73731. /** @hidden */
  73732. export var shadowMapVertexShader: {
  73733. name: string;
  73734. shader: string;
  73735. };
  73736. }
  73737. declare module BABYLON {
  73738. /** @hidden */
  73739. export var depthBoxBlurPixelShader: {
  73740. name: string;
  73741. shader: string;
  73742. };
  73743. }
  73744. declare module BABYLON {
  73745. /**
  73746. * Defines the options associated with the creation of a custom shader for a shadow generator.
  73747. */
  73748. export interface ICustomShaderOptions {
  73749. /**
  73750. * Gets or sets the custom shader name to use
  73751. */
  73752. shaderName: string;
  73753. /**
  73754. * The list of attribute names used in the shader
  73755. */
  73756. attributes?: string[];
  73757. /**
  73758. * The list of unifrom names used in the shader
  73759. */
  73760. uniforms?: string[];
  73761. /**
  73762. * The list of sampler names used in the shader
  73763. */
  73764. samplers?: string[];
  73765. /**
  73766. * The list of defines used in the shader
  73767. */
  73768. defines?: string[];
  73769. }
  73770. /**
  73771. * Interface to implement to create a shadow generator compatible with BJS.
  73772. */
  73773. export interface IShadowGenerator {
  73774. /**
  73775. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  73776. * @returns The render target texture if present otherwise, null
  73777. */
  73778. getShadowMap(): Nullable<RenderTargetTexture>;
  73779. /**
  73780. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  73781. * @returns The render target texture if the shadow map is present otherwise, null
  73782. */
  73783. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  73784. /**
  73785. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  73786. * @param subMesh The submesh we want to render in the shadow map
  73787. * @param useInstances Defines wether will draw in the map using instances
  73788. * @returns true if ready otherwise, false
  73789. */
  73790. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73791. /**
  73792. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  73793. * @param defines Defines of the material we want to update
  73794. * @param lightIndex Index of the light in the enabled light list of the material
  73795. */
  73796. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  73797. /**
  73798. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  73799. * defined in the generator but impacting the effect).
  73800. * It implies the unifroms available on the materials are the standard BJS ones.
  73801. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  73802. * @param effect The effect we are binfing the information for
  73803. */
  73804. bindShadowLight(lightIndex: string, effect: Effect): void;
  73805. /**
  73806. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  73807. * (eq to shadow prjection matrix * light transform matrix)
  73808. * @returns The transform matrix used to create the shadow map
  73809. */
  73810. getTransformMatrix(): Matrix;
  73811. /**
  73812. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  73813. * Cube and 2D textures for instance.
  73814. */
  73815. recreateShadowMap(): void;
  73816. /**
  73817. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73818. * @param onCompiled Callback triggered at the and of the effects compilation
  73819. * @param options Sets of optional options forcing the compilation with different modes
  73820. */
  73821. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  73822. useInstances: boolean;
  73823. }>): void;
  73824. /**
  73825. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  73826. * @param options Sets of optional options forcing the compilation with different modes
  73827. * @returns A promise that resolves when the compilation completes
  73828. */
  73829. forceCompilationAsync(options?: Partial<{
  73830. useInstances: boolean;
  73831. }>): Promise<void>;
  73832. /**
  73833. * Serializes the shadow generator setup to a json object.
  73834. * @returns The serialized JSON object
  73835. */
  73836. serialize(): any;
  73837. /**
  73838. * Disposes the Shadow map and related Textures and effects.
  73839. */
  73840. dispose(): void;
  73841. }
  73842. /**
  73843. * Default implementation IShadowGenerator.
  73844. * This is the main object responsible of generating shadows in the framework.
  73845. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  73846. */
  73847. export class ShadowGenerator implements IShadowGenerator {
  73848. /**
  73849. * Shadow generator mode None: no filtering applied.
  73850. */
  73851. static readonly FILTER_NONE: number;
  73852. /**
  73853. * Shadow generator mode ESM: Exponential Shadow Mapping.
  73854. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73855. */
  73856. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  73857. /**
  73858. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  73859. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  73860. */
  73861. static readonly FILTER_POISSONSAMPLING: number;
  73862. /**
  73863. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  73864. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73865. */
  73866. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  73867. /**
  73868. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  73869. * edge artifacts on steep falloff.
  73870. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73871. */
  73872. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  73873. /**
  73874. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  73875. * edge artifacts on steep falloff.
  73876. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  73877. */
  73878. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  73879. /**
  73880. * Shadow generator mode PCF: Percentage Closer Filtering
  73881. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  73882. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  73883. */
  73884. static readonly FILTER_PCF: number;
  73885. /**
  73886. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  73887. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  73888. * Contact Hardening
  73889. */
  73890. static readonly FILTER_PCSS: number;
  73891. /**
  73892. * Reserved for PCF and PCSS
  73893. * Highest Quality.
  73894. *
  73895. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  73896. *
  73897. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  73898. */
  73899. static readonly QUALITY_HIGH: number;
  73900. /**
  73901. * Reserved for PCF and PCSS
  73902. * Good tradeoff for quality/perf cross devices
  73903. *
  73904. * Execute PCF on a 3*3 kernel.
  73905. *
  73906. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  73907. */
  73908. static readonly QUALITY_MEDIUM: number;
  73909. /**
  73910. * Reserved for PCF and PCSS
  73911. * The lowest quality but the fastest.
  73912. *
  73913. * Execute PCF on a 1*1 kernel.
  73914. *
  73915. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  73916. */
  73917. static readonly QUALITY_LOW: number;
  73918. /** Gets or sets the custom shader name to use */
  73919. customShaderOptions: ICustomShaderOptions;
  73920. /**
  73921. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  73922. */
  73923. onBeforeShadowMapRenderObservable: Observable<Effect>;
  73924. /**
  73925. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  73926. */
  73927. onAfterShadowMapRenderObservable: Observable<Effect>;
  73928. /**
  73929. * Observable triggered before a mesh is rendered in the shadow map.
  73930. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  73931. */
  73932. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  73933. /**
  73934. * Observable triggered after a mesh is rendered in the shadow map.
  73935. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  73936. */
  73937. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  73938. private _bias;
  73939. /**
  73940. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  73941. */
  73942. /**
  73943. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  73944. */
  73945. bias: number;
  73946. private _normalBias;
  73947. /**
  73948. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  73949. */
  73950. /**
  73951. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  73952. */
  73953. normalBias: number;
  73954. private _blurBoxOffset;
  73955. /**
  73956. * Gets the blur box offset: offset applied during the blur pass.
  73957. * Only useful if useKernelBlur = false
  73958. */
  73959. /**
  73960. * Sets the blur box offset: offset applied during the blur pass.
  73961. * Only useful if useKernelBlur = false
  73962. */
  73963. blurBoxOffset: number;
  73964. private _blurScale;
  73965. /**
  73966. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  73967. * 2 means half of the size.
  73968. */
  73969. /**
  73970. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  73971. * 2 means half of the size.
  73972. */
  73973. blurScale: number;
  73974. private _blurKernel;
  73975. /**
  73976. * Gets the blur kernel: kernel size of the blur pass.
  73977. * Only useful if useKernelBlur = true
  73978. */
  73979. /**
  73980. * Sets the blur kernel: kernel size of the blur pass.
  73981. * Only useful if useKernelBlur = true
  73982. */
  73983. blurKernel: number;
  73984. private _useKernelBlur;
  73985. /**
  73986. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  73987. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  73988. */
  73989. /**
  73990. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  73991. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  73992. */
  73993. useKernelBlur: boolean;
  73994. private _depthScale;
  73995. /**
  73996. * Gets the depth scale used in ESM mode.
  73997. */
  73998. /**
  73999. * Sets the depth scale used in ESM mode.
  74000. * This can override the scale stored on the light.
  74001. */
  74002. depthScale: number;
  74003. private _filter;
  74004. /**
  74005. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  74006. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  74007. */
  74008. /**
  74009. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  74010. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  74011. */
  74012. filter: number;
  74013. /**
  74014. * Gets if the current filter is set to Poisson Sampling.
  74015. */
  74016. /**
  74017. * Sets the current filter to Poisson Sampling.
  74018. */
  74019. usePoissonSampling: boolean;
  74020. /**
  74021. * Gets if the current filter is set to ESM.
  74022. */
  74023. /**
  74024. * Sets the current filter is to ESM.
  74025. */
  74026. useExponentialShadowMap: boolean;
  74027. /**
  74028. * Gets if the current filter is set to filtered ESM.
  74029. */
  74030. /**
  74031. * Gets if the current filter is set to filtered ESM.
  74032. */
  74033. useBlurExponentialShadowMap: boolean;
  74034. /**
  74035. * Gets if the current filter is set to "close ESM" (using the inverse of the
  74036. * exponential to prevent steep falloff artifacts).
  74037. */
  74038. /**
  74039. * Sets the current filter to "close ESM" (using the inverse of the
  74040. * exponential to prevent steep falloff artifacts).
  74041. */
  74042. useCloseExponentialShadowMap: boolean;
  74043. /**
  74044. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  74045. * exponential to prevent steep falloff artifacts).
  74046. */
  74047. /**
  74048. * Sets the current filter to filtered "close ESM" (using the inverse of the
  74049. * exponential to prevent steep falloff artifacts).
  74050. */
  74051. useBlurCloseExponentialShadowMap: boolean;
  74052. /**
  74053. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  74054. */
  74055. /**
  74056. * Sets the current filter to "PCF" (percentage closer filtering).
  74057. */
  74058. usePercentageCloserFiltering: boolean;
  74059. private _filteringQuality;
  74060. /**
  74061. * Gets the PCF or PCSS Quality.
  74062. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  74063. */
  74064. /**
  74065. * Sets the PCF or PCSS Quality.
  74066. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  74067. */
  74068. filteringQuality: number;
  74069. /**
  74070. * Gets if the current filter is set to "PCSS" (contact hardening).
  74071. */
  74072. /**
  74073. * Sets the current filter to "PCSS" (contact hardening).
  74074. */
  74075. useContactHardeningShadow: boolean;
  74076. private _contactHardeningLightSizeUVRatio;
  74077. /**
  74078. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74079. * Using a ratio helps keeping shape stability independently of the map size.
  74080. *
  74081. * It does not account for the light projection as it was having too much
  74082. * instability during the light setup or during light position changes.
  74083. *
  74084. * Only valid if useContactHardeningShadow is true.
  74085. */
  74086. /**
  74087. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  74088. * Using a ratio helps keeping shape stability independently of the map size.
  74089. *
  74090. * It does not account for the light projection as it was having too much
  74091. * instability during the light setup or during light position changes.
  74092. *
  74093. * Only valid if useContactHardeningShadow is true.
  74094. */
  74095. contactHardeningLightSizeUVRatio: number;
  74096. private _darkness;
  74097. /** Gets or sets the actual darkness of a shadow */
  74098. darkness: number;
  74099. /**
  74100. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  74101. * 0 means strongest and 1 would means no shadow.
  74102. * @returns the darkness.
  74103. */
  74104. getDarkness(): number;
  74105. /**
  74106. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  74107. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  74108. * @returns the shadow generator allowing fluent coding.
  74109. */
  74110. setDarkness(darkness: number): ShadowGenerator;
  74111. private _transparencyShadow;
  74112. /** Gets or sets the ability to have transparent shadow */
  74113. transparencyShadow: boolean;
  74114. /**
  74115. * Sets the ability to have transparent shadow (boolean).
  74116. * @param transparent True if transparent else False
  74117. * @returns the shadow generator allowing fluent coding
  74118. */
  74119. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  74120. private _shadowMap;
  74121. private _shadowMap2;
  74122. /**
  74123. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  74124. * @returns The render target texture if present otherwise, null
  74125. */
  74126. getShadowMap(): Nullable<RenderTargetTexture>;
  74127. /**
  74128. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  74129. * @returns The render target texture if the shadow map is present otherwise, null
  74130. */
  74131. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  74132. /**
  74133. * Gets the class name of that object
  74134. * @returns "ShadowGenerator"
  74135. */
  74136. getClassName(): string;
  74137. /**
  74138. * Helper function to add a mesh and its descendants to the list of shadow casters.
  74139. * @param mesh Mesh to add
  74140. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  74141. * @returns the Shadow Generator itself
  74142. */
  74143. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74144. /**
  74145. * Helper function to remove a mesh and its descendants from the list of shadow casters
  74146. * @param mesh Mesh to remove
  74147. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  74148. * @returns the Shadow Generator itself
  74149. */
  74150. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  74151. /**
  74152. * Controls the extent to which the shadows fade out at the edge of the frustum
  74153. * Used only by directionals and spots
  74154. */
  74155. frustumEdgeFalloff: number;
  74156. private _light;
  74157. /**
  74158. * Returns the associated light object.
  74159. * @returns the light generating the shadow
  74160. */
  74161. getLight(): IShadowLight;
  74162. /**
  74163. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  74164. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  74165. * It might on the other hand introduce peter panning.
  74166. */
  74167. forceBackFacesOnly: boolean;
  74168. private _scene;
  74169. private _lightDirection;
  74170. private _effect;
  74171. private _viewMatrix;
  74172. private _projectionMatrix;
  74173. private _transformMatrix;
  74174. private _cachedPosition;
  74175. private _cachedDirection;
  74176. private _cachedDefines;
  74177. private _currentRenderID;
  74178. private _boxBlurPostprocess;
  74179. private _kernelBlurXPostprocess;
  74180. private _kernelBlurYPostprocess;
  74181. private _blurPostProcesses;
  74182. private _mapSize;
  74183. private _currentFaceIndex;
  74184. private _currentFaceIndexCache;
  74185. private _textureType;
  74186. private _defaultTextureMatrix;
  74187. /** @hidden */
  74188. static _SceneComponentInitialization: (scene: Scene) => void;
  74189. /**
  74190. * Creates a ShadowGenerator object.
  74191. * A ShadowGenerator is the required tool to use the shadows.
  74192. * Each light casting shadows needs to use its own ShadowGenerator.
  74193. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  74194. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  74195. * @param light The light object generating the shadows.
  74196. * @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.
  74197. */
  74198. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  74199. private _initializeGenerator;
  74200. private _initializeShadowMap;
  74201. private _initializeBlurRTTAndPostProcesses;
  74202. private _renderForShadowMap;
  74203. private _renderSubMeshForShadowMap;
  74204. private _applyFilterValues;
  74205. /**
  74206. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74207. * @param onCompiled Callback triggered at the and of the effects compilation
  74208. * @param options Sets of optional options forcing the compilation with different modes
  74209. */
  74210. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  74211. useInstances: boolean;
  74212. }>): void;
  74213. /**
  74214. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  74215. * @param options Sets of optional options forcing the compilation with different modes
  74216. * @returns A promise that resolves when the compilation completes
  74217. */
  74218. forceCompilationAsync(options?: Partial<{
  74219. useInstances: boolean;
  74220. }>): Promise<void>;
  74221. /**
  74222. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  74223. * @param subMesh The submesh we want to render in the shadow map
  74224. * @param useInstances Defines wether will draw in the map using instances
  74225. * @returns true if ready otherwise, false
  74226. */
  74227. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  74228. /**
  74229. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  74230. * @param defines Defines of the material we want to update
  74231. * @param lightIndex Index of the light in the enabled light list of the material
  74232. */
  74233. prepareDefines(defines: any, lightIndex: number): void;
  74234. /**
  74235. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  74236. * defined in the generator but impacting the effect).
  74237. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  74238. * @param effect The effect we are binfing the information for
  74239. */
  74240. bindShadowLight(lightIndex: string, effect: Effect): void;
  74241. /**
  74242. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  74243. * (eq to shadow prjection matrix * light transform matrix)
  74244. * @returns The transform matrix used to create the shadow map
  74245. */
  74246. getTransformMatrix(): Matrix;
  74247. /**
  74248. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  74249. * Cube and 2D textures for instance.
  74250. */
  74251. recreateShadowMap(): void;
  74252. private _disposeBlurPostProcesses;
  74253. private _disposeRTTandPostProcesses;
  74254. /**
  74255. * Disposes the ShadowGenerator.
  74256. * Returns nothing.
  74257. */
  74258. dispose(): void;
  74259. /**
  74260. * Serializes the shadow generator setup to a json object.
  74261. * @returns The serialized JSON object
  74262. */
  74263. serialize(): any;
  74264. /**
  74265. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  74266. * @param parsedShadowGenerator The JSON object to parse
  74267. * @param scene The scene to create the shadow map for
  74268. * @returns The parsed shadow generator
  74269. */
  74270. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  74271. }
  74272. }
  74273. declare module BABYLON {
  74274. /**
  74275. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  74276. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  74277. * 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.
  74278. */
  74279. export abstract class Light extends Node {
  74280. /**
  74281. * Falloff Default: light is falling off following the material specification:
  74282. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  74283. */
  74284. static readonly FALLOFF_DEFAULT: number;
  74285. /**
  74286. * Falloff Physical: light is falling off following the inverse squared distance law.
  74287. */
  74288. static readonly FALLOFF_PHYSICAL: number;
  74289. /**
  74290. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  74291. * to enhance interoperability with other engines.
  74292. */
  74293. static readonly FALLOFF_GLTF: number;
  74294. /**
  74295. * Falloff Standard: light is falling off like in the standard material
  74296. * to enhance interoperability with other materials.
  74297. */
  74298. static readonly FALLOFF_STANDARD: number;
  74299. /**
  74300. * If every light affecting the material is in this lightmapMode,
  74301. * material.lightmapTexture adds or multiplies
  74302. * (depends on material.useLightmapAsShadowmap)
  74303. * after every other light calculations.
  74304. */
  74305. static readonly LIGHTMAP_DEFAULT: number;
  74306. /**
  74307. * material.lightmapTexture as only diffuse lighting from this light
  74308. * adds only specular lighting from this light
  74309. * adds dynamic shadows
  74310. */
  74311. static readonly LIGHTMAP_SPECULAR: number;
  74312. /**
  74313. * material.lightmapTexture as only lighting
  74314. * no light calculation from this light
  74315. * only adds dynamic shadows from this light
  74316. */
  74317. static readonly LIGHTMAP_SHADOWSONLY: number;
  74318. /**
  74319. * Each light type uses the default quantity according to its type:
  74320. * point/spot lights use luminous intensity
  74321. * directional lights use illuminance
  74322. */
  74323. static readonly INTENSITYMODE_AUTOMATIC: number;
  74324. /**
  74325. * lumen (lm)
  74326. */
  74327. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  74328. /**
  74329. * candela (lm/sr)
  74330. */
  74331. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  74332. /**
  74333. * lux (lm/m^2)
  74334. */
  74335. static readonly INTENSITYMODE_ILLUMINANCE: number;
  74336. /**
  74337. * nit (cd/m^2)
  74338. */
  74339. static readonly INTENSITYMODE_LUMINANCE: number;
  74340. /**
  74341. * Light type const id of the point light.
  74342. */
  74343. static readonly LIGHTTYPEID_POINTLIGHT: number;
  74344. /**
  74345. * Light type const id of the directional light.
  74346. */
  74347. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  74348. /**
  74349. * Light type const id of the spot light.
  74350. */
  74351. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  74352. /**
  74353. * Light type const id of the hemispheric light.
  74354. */
  74355. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  74356. /**
  74357. * Diffuse gives the basic color to an object.
  74358. */
  74359. diffuse: Color3;
  74360. /**
  74361. * Specular produces a highlight color on an object.
  74362. * Note: This is note affecting PBR materials.
  74363. */
  74364. specular: Color3;
  74365. /**
  74366. * Defines the falloff type for this light. This lets overrriding how punctual light are
  74367. * falling off base on range or angle.
  74368. * This can be set to any values in Light.FALLOFF_x.
  74369. *
  74370. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  74371. * other types of materials.
  74372. */
  74373. falloffType: number;
  74374. /**
  74375. * Strength of the light.
  74376. * Note: By default it is define in the framework own unit.
  74377. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  74378. */
  74379. intensity: number;
  74380. private _range;
  74381. protected _inverseSquaredRange: number;
  74382. /**
  74383. * Defines how far from the source the light is impacting in scene units.
  74384. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74385. */
  74386. /**
  74387. * Defines how far from the source the light is impacting in scene units.
  74388. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  74389. */
  74390. range: number;
  74391. /**
  74392. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  74393. * of light.
  74394. */
  74395. private _photometricScale;
  74396. private _intensityMode;
  74397. /**
  74398. * Gets the photometric scale used to interpret the intensity.
  74399. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74400. */
  74401. /**
  74402. * Sets the photometric scale used to interpret the intensity.
  74403. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  74404. */
  74405. intensityMode: number;
  74406. private _radius;
  74407. /**
  74408. * Gets the light radius used by PBR Materials to simulate soft area lights.
  74409. */
  74410. /**
  74411. * sets the light radius used by PBR Materials to simulate soft area lights.
  74412. */
  74413. radius: number;
  74414. private _renderPriority;
  74415. /**
  74416. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  74417. * exceeding the number allowed of the materials.
  74418. */
  74419. renderPriority: number;
  74420. private _shadowEnabled;
  74421. /**
  74422. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74423. * the current shadow generator.
  74424. */
  74425. /**
  74426. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  74427. * the current shadow generator.
  74428. */
  74429. shadowEnabled: boolean;
  74430. private _includedOnlyMeshes;
  74431. /**
  74432. * Gets the only meshes impacted by this light.
  74433. */
  74434. /**
  74435. * Sets the only meshes impacted by this light.
  74436. */
  74437. includedOnlyMeshes: AbstractMesh[];
  74438. private _excludedMeshes;
  74439. /**
  74440. * Gets the meshes not impacted by this light.
  74441. */
  74442. /**
  74443. * Sets the meshes not impacted by this light.
  74444. */
  74445. excludedMeshes: AbstractMesh[];
  74446. private _excludeWithLayerMask;
  74447. /**
  74448. * Gets the layer id use to find what meshes are not impacted by the light.
  74449. * Inactive if 0
  74450. */
  74451. /**
  74452. * Sets the layer id use to find what meshes are not impacted by the light.
  74453. * Inactive if 0
  74454. */
  74455. excludeWithLayerMask: number;
  74456. private _includeOnlyWithLayerMask;
  74457. /**
  74458. * Gets the layer id use to find what meshes are impacted by the light.
  74459. * Inactive if 0
  74460. */
  74461. /**
  74462. * Sets the layer id use to find what meshes are impacted by the light.
  74463. * Inactive if 0
  74464. */
  74465. includeOnlyWithLayerMask: number;
  74466. private _lightmapMode;
  74467. /**
  74468. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74469. */
  74470. /**
  74471. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  74472. */
  74473. lightmapMode: number;
  74474. /**
  74475. * Shadow generator associted to the light.
  74476. * @hidden Internal use only.
  74477. */
  74478. _shadowGenerator: Nullable<IShadowGenerator>;
  74479. /**
  74480. * @hidden Internal use only.
  74481. */
  74482. _excludedMeshesIds: string[];
  74483. /**
  74484. * @hidden Internal use only.
  74485. */
  74486. _includedOnlyMeshesIds: string[];
  74487. /**
  74488. * The current light unifom buffer.
  74489. * @hidden Internal use only.
  74490. */
  74491. _uniformBuffer: UniformBuffer;
  74492. /**
  74493. * Creates a Light object in the scene.
  74494. * Documentation : https://doc.babylonjs.com/babylon101/lights
  74495. * @param name The firendly name of the light
  74496. * @param scene The scene the light belongs too
  74497. */
  74498. constructor(name: string, scene: Scene);
  74499. protected abstract _buildUniformLayout(): void;
  74500. /**
  74501. * Sets the passed Effect "effect" with the Light information.
  74502. * @param effect The effect to update
  74503. * @param lightIndex The index of the light in the effect to update
  74504. * @returns The light
  74505. */
  74506. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  74507. /**
  74508. * Returns the string "Light".
  74509. * @returns the class name
  74510. */
  74511. getClassName(): string;
  74512. /** @hidden */
  74513. readonly _isLight: boolean;
  74514. /**
  74515. * Converts the light information to a readable string for debug purpose.
  74516. * @param fullDetails Supports for multiple levels of logging within scene loading
  74517. * @returns the human readable light info
  74518. */
  74519. toString(fullDetails?: boolean): string;
  74520. /** @hidden */
  74521. protected _syncParentEnabledState(): void;
  74522. /**
  74523. * Set the enabled state of this node.
  74524. * @param value - the new enabled state
  74525. */
  74526. setEnabled(value: boolean): void;
  74527. /**
  74528. * Returns the Light associated shadow generator if any.
  74529. * @return the associated shadow generator.
  74530. */
  74531. getShadowGenerator(): Nullable<IShadowGenerator>;
  74532. /**
  74533. * Returns a Vector3, the absolute light position in the World.
  74534. * @returns the world space position of the light
  74535. */
  74536. getAbsolutePosition(): Vector3;
  74537. /**
  74538. * Specifies if the light will affect the passed mesh.
  74539. * @param mesh The mesh to test against the light
  74540. * @return true the mesh is affected otherwise, false.
  74541. */
  74542. canAffectMesh(mesh: AbstractMesh): boolean;
  74543. /**
  74544. * Sort function to order lights for rendering.
  74545. * @param a First Light object to compare to second.
  74546. * @param b Second Light object to compare first.
  74547. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  74548. */
  74549. static CompareLightsPriority(a: Light, b: Light): number;
  74550. /**
  74551. * Releases resources associated with this node.
  74552. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  74553. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  74554. */
  74555. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74556. /**
  74557. * Returns the light type ID (integer).
  74558. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  74559. */
  74560. getTypeID(): number;
  74561. /**
  74562. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  74563. * @returns the scaled intensity in intensity mode unit
  74564. */
  74565. getScaledIntensity(): number;
  74566. /**
  74567. * Returns a new Light object, named "name", from the current one.
  74568. * @param name The name of the cloned light
  74569. * @returns the new created light
  74570. */
  74571. clone(name: string): Nullable<Light>;
  74572. /**
  74573. * Serializes the current light into a Serialization object.
  74574. * @returns the serialized object.
  74575. */
  74576. serialize(): any;
  74577. /**
  74578. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  74579. * This new light is named "name" and added to the passed scene.
  74580. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  74581. * @param name The friendly name of the light
  74582. * @param scene The scene the new light will belong to
  74583. * @returns the constructor function
  74584. */
  74585. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  74586. /**
  74587. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  74588. * @param parsedLight The JSON representation of the light
  74589. * @param scene The scene to create the parsed light in
  74590. * @returns the created light after parsing
  74591. */
  74592. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  74593. private _hookArrayForExcluded;
  74594. private _hookArrayForIncludedOnly;
  74595. private _resyncMeshes;
  74596. /**
  74597. * Forces the meshes to update their light related information in their rendering used effects
  74598. * @hidden Internal Use Only
  74599. */
  74600. _markMeshesAsLightDirty(): void;
  74601. /**
  74602. * Recomputes the cached photometric scale if needed.
  74603. */
  74604. private _computePhotometricScale;
  74605. /**
  74606. * Returns the Photometric Scale according to the light type and intensity mode.
  74607. */
  74608. private _getPhotometricScale;
  74609. /**
  74610. * Reorder the light in the scene according to their defined priority.
  74611. * @hidden Internal Use Only
  74612. */
  74613. _reorderLightsInScene(): void;
  74614. /**
  74615. * Prepares the list of defines specific to the light type.
  74616. * @param defines the list of defines
  74617. * @param lightIndex defines the index of the light for the effect
  74618. */
  74619. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  74620. }
  74621. }
  74622. declare module BABYLON {
  74623. /**
  74624. * Creates an instance based on a source mesh.
  74625. */
  74626. export class InstancedMesh extends AbstractMesh {
  74627. private _sourceMesh;
  74628. private _currentLOD;
  74629. /** @hidden */
  74630. _indexInSourceMeshInstanceArray: number;
  74631. constructor(name: string, source: Mesh);
  74632. /**
  74633. * Returns the string "InstancedMesh".
  74634. */
  74635. getClassName(): string;
  74636. /** Gets the list of lights affecting that mesh */
  74637. readonly lightSources: Light[];
  74638. _resyncLightSources(): void;
  74639. _resyncLighSource(light: Light): void;
  74640. _removeLightSource(light: Light): void;
  74641. /**
  74642. * If the source mesh receives shadows
  74643. */
  74644. readonly receiveShadows: boolean;
  74645. /**
  74646. * The material of the source mesh
  74647. */
  74648. readonly material: Nullable<Material>;
  74649. /**
  74650. * Visibility of the source mesh
  74651. */
  74652. readonly visibility: number;
  74653. /**
  74654. * Skeleton of the source mesh
  74655. */
  74656. readonly skeleton: Nullable<Skeleton>;
  74657. /**
  74658. * Rendering ground id of the source mesh
  74659. */
  74660. renderingGroupId: number;
  74661. /**
  74662. * Returns the total number of vertices (integer).
  74663. */
  74664. getTotalVertices(): number;
  74665. /**
  74666. * Returns a positive integer : the total number of indices in this mesh geometry.
  74667. * @returns the numner of indices or zero if the mesh has no geometry.
  74668. */
  74669. getTotalIndices(): number;
  74670. /**
  74671. * The source mesh of the instance
  74672. */
  74673. readonly sourceMesh: Mesh;
  74674. /**
  74675. * Is this node ready to be used/rendered
  74676. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  74677. * @return {boolean} is it ready
  74678. */
  74679. isReady(completeCheck?: boolean): boolean;
  74680. /**
  74681. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  74682. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  74683. * @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.
  74684. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  74685. */
  74686. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  74687. /**
  74688. * Sets the vertex data of the mesh geometry for the requested `kind`.
  74689. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  74690. * The `data` are either a numeric array either a Float32Array.
  74691. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  74692. * 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).
  74693. * Note that a new underlying VertexBuffer object is created each call.
  74694. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  74695. *
  74696. * Possible `kind` values :
  74697. * - VertexBuffer.PositionKind
  74698. * - VertexBuffer.UVKind
  74699. * - VertexBuffer.UV2Kind
  74700. * - VertexBuffer.UV3Kind
  74701. * - VertexBuffer.UV4Kind
  74702. * - VertexBuffer.UV5Kind
  74703. * - VertexBuffer.UV6Kind
  74704. * - VertexBuffer.ColorKind
  74705. * - VertexBuffer.MatricesIndicesKind
  74706. * - VertexBuffer.MatricesIndicesExtraKind
  74707. * - VertexBuffer.MatricesWeightsKind
  74708. * - VertexBuffer.MatricesWeightsExtraKind
  74709. *
  74710. * Returns the Mesh.
  74711. */
  74712. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  74713. /**
  74714. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  74715. * If the mesh has no geometry, it is simply returned as it is.
  74716. * The `data` are either a numeric array either a Float32Array.
  74717. * No new underlying VertexBuffer object is created.
  74718. * 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.
  74719. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  74720. *
  74721. * Possible `kind` values :
  74722. * - VertexBuffer.PositionKind
  74723. * - VertexBuffer.UVKind
  74724. * - VertexBuffer.UV2Kind
  74725. * - VertexBuffer.UV3Kind
  74726. * - VertexBuffer.UV4Kind
  74727. * - VertexBuffer.UV5Kind
  74728. * - VertexBuffer.UV6Kind
  74729. * - VertexBuffer.ColorKind
  74730. * - VertexBuffer.MatricesIndicesKind
  74731. * - VertexBuffer.MatricesIndicesExtraKind
  74732. * - VertexBuffer.MatricesWeightsKind
  74733. * - VertexBuffer.MatricesWeightsExtraKind
  74734. *
  74735. * Returns the Mesh.
  74736. */
  74737. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  74738. /**
  74739. * Sets the mesh indices.
  74740. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  74741. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  74742. * This method creates a new index buffer each call.
  74743. * Returns the Mesh.
  74744. */
  74745. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  74746. /**
  74747. * Boolean : True if the mesh owns the requested kind of data.
  74748. */
  74749. isVerticesDataPresent(kind: string): boolean;
  74750. /**
  74751. * Returns an array of indices (IndicesArray).
  74752. */
  74753. getIndices(): Nullable<IndicesArray>;
  74754. readonly _positions: Nullable<Vector3[]>;
  74755. /**
  74756. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  74757. * This means the mesh underlying bounding box and sphere are recomputed.
  74758. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  74759. * @returns the current mesh
  74760. */
  74761. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  74762. /** @hidden */
  74763. _preActivate(): InstancedMesh;
  74764. /** @hidden */
  74765. _activate(renderId: number, intermediateRendering: boolean): boolean;
  74766. /** @hidden */
  74767. _postActivate(): void;
  74768. getWorldMatrix(): Matrix;
  74769. readonly isAnInstance: boolean;
  74770. /**
  74771. * Returns the current associated LOD AbstractMesh.
  74772. */
  74773. getLOD(camera: Camera): AbstractMesh;
  74774. /** @hidden */
  74775. _syncSubMeshes(): InstancedMesh;
  74776. /** @hidden */
  74777. _generatePointsArray(): boolean;
  74778. /**
  74779. * Creates a new InstancedMesh from the current mesh.
  74780. * - name (string) : the cloned mesh name
  74781. * - newParent (optional Node) : the optional Node to parent the clone to.
  74782. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  74783. *
  74784. * Returns the clone.
  74785. */
  74786. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  74787. /**
  74788. * Disposes the InstancedMesh.
  74789. * Returns nothing.
  74790. */
  74791. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  74792. }
  74793. }
  74794. declare module BABYLON {
  74795. /**
  74796. * Defines the options associated with the creation of a shader material.
  74797. */
  74798. export interface IShaderMaterialOptions {
  74799. /**
  74800. * Does the material work in alpha blend mode
  74801. */
  74802. needAlphaBlending: boolean;
  74803. /**
  74804. * Does the material work in alpha test mode
  74805. */
  74806. needAlphaTesting: boolean;
  74807. /**
  74808. * The list of attribute names used in the shader
  74809. */
  74810. attributes: string[];
  74811. /**
  74812. * The list of unifrom names used in the shader
  74813. */
  74814. uniforms: string[];
  74815. /**
  74816. * The list of UBO names used in the shader
  74817. */
  74818. uniformBuffers: string[];
  74819. /**
  74820. * The list of sampler names used in the shader
  74821. */
  74822. samplers: string[];
  74823. /**
  74824. * The list of defines used in the shader
  74825. */
  74826. defines: string[];
  74827. }
  74828. /**
  74829. * 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.
  74830. *
  74831. * This returned material effects how the mesh will look based on the code in the shaders.
  74832. *
  74833. * @see http://doc.babylonjs.com/how_to/shader_material
  74834. */
  74835. export class ShaderMaterial extends Material {
  74836. private _shaderPath;
  74837. private _options;
  74838. private _textures;
  74839. private _textureArrays;
  74840. private _floats;
  74841. private _ints;
  74842. private _floatsArrays;
  74843. private _colors3;
  74844. private _colors3Arrays;
  74845. private _colors4;
  74846. private _colors4Arrays;
  74847. private _vectors2;
  74848. private _vectors3;
  74849. private _vectors4;
  74850. private _matrices;
  74851. private _matrices3x3;
  74852. private _matrices2x2;
  74853. private _vectors2Arrays;
  74854. private _vectors3Arrays;
  74855. private _vectors4Arrays;
  74856. private _cachedWorldViewMatrix;
  74857. private _cachedWorldViewProjectionMatrix;
  74858. private _renderId;
  74859. /**
  74860. * Instantiate a new shader material.
  74861. * 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.
  74862. * This returned material effects how the mesh will look based on the code in the shaders.
  74863. * @see http://doc.babylonjs.com/how_to/shader_material
  74864. * @param name Define the name of the material in the scene
  74865. * @param scene Define the scene the material belongs to
  74866. * @param shaderPath Defines the route to the shader code in one of three ways:
  74867. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  74868. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  74869. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  74870. * @param options Define the options used to create the shader
  74871. */
  74872. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  74873. /**
  74874. * Gets the options used to compile the shader.
  74875. * They can be modified to trigger a new compilation
  74876. */
  74877. readonly options: IShaderMaterialOptions;
  74878. /**
  74879. * Gets the current class name of the material e.g. "ShaderMaterial"
  74880. * Mainly use in serialization.
  74881. * @returns the class name
  74882. */
  74883. getClassName(): string;
  74884. /**
  74885. * Specifies if the material will require alpha blending
  74886. * @returns a boolean specifying if alpha blending is needed
  74887. */
  74888. needAlphaBlending(): boolean;
  74889. /**
  74890. * Specifies if this material should be rendered in alpha test mode
  74891. * @returns a boolean specifying if an alpha test is needed.
  74892. */
  74893. needAlphaTesting(): boolean;
  74894. private _checkUniform;
  74895. /**
  74896. * Set a texture in the shader.
  74897. * @param name Define the name of the uniform samplers as defined in the shader
  74898. * @param texture Define the texture to bind to this sampler
  74899. * @return the material itself allowing "fluent" like uniform updates
  74900. */
  74901. setTexture(name: string, texture: Texture): ShaderMaterial;
  74902. /**
  74903. * Set a texture array in the shader.
  74904. * @param name Define the name of the uniform sampler array as defined in the shader
  74905. * @param textures Define the list of textures to bind to this sampler
  74906. * @return the material itself allowing "fluent" like uniform updates
  74907. */
  74908. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  74909. /**
  74910. * Set a float in the shader.
  74911. * @param name Define the name of the uniform as defined in the shader
  74912. * @param value Define the value to give to the uniform
  74913. * @return the material itself allowing "fluent" like uniform updates
  74914. */
  74915. setFloat(name: string, value: number): ShaderMaterial;
  74916. /**
  74917. * Set a int in the shader.
  74918. * @param name Define the name of the uniform as defined in the shader
  74919. * @param value Define the value to give to the uniform
  74920. * @return the material itself allowing "fluent" like uniform updates
  74921. */
  74922. setInt(name: string, value: number): ShaderMaterial;
  74923. /**
  74924. * Set an array of floats in the shader.
  74925. * @param name Define the name of the uniform as defined in the shader
  74926. * @param value Define the value to give to the uniform
  74927. * @return the material itself allowing "fluent" like uniform updates
  74928. */
  74929. setFloats(name: string, value: number[]): ShaderMaterial;
  74930. /**
  74931. * Set a vec3 in the shader from a Color3.
  74932. * @param name Define the name of the uniform as defined in the shader
  74933. * @param value Define the value to give to the uniform
  74934. * @return the material itself allowing "fluent" like uniform updates
  74935. */
  74936. setColor3(name: string, value: Color3): ShaderMaterial;
  74937. /**
  74938. * Set a vec3 array in the shader from a Color3 array.
  74939. * @param name Define the name of the uniform as defined in the shader
  74940. * @param value Define the value to give to the uniform
  74941. * @return the material itself allowing "fluent" like uniform updates
  74942. */
  74943. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  74944. /**
  74945. * Set a vec4 in the shader from a Color4.
  74946. * @param name Define the name of the uniform as defined in the shader
  74947. * @param value Define the value to give to the uniform
  74948. * @return the material itself allowing "fluent" like uniform updates
  74949. */
  74950. setColor4(name: string, value: Color4): ShaderMaterial;
  74951. /**
  74952. * Set a vec4 array in the shader from a Color4 array.
  74953. * @param name Define the name of the uniform as defined in the shader
  74954. * @param value Define the value to give to the uniform
  74955. * @return the material itself allowing "fluent" like uniform updates
  74956. */
  74957. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  74958. /**
  74959. * Set a vec2 in the shader from a Vector2.
  74960. * @param name Define the name of the uniform as defined in the shader
  74961. * @param value Define the value to give to the uniform
  74962. * @return the material itself allowing "fluent" like uniform updates
  74963. */
  74964. setVector2(name: string, value: Vector2): ShaderMaterial;
  74965. /**
  74966. * Set a vec3 in the shader from a Vector3.
  74967. * @param name Define the name of the uniform as defined in the shader
  74968. * @param value Define the value to give to the uniform
  74969. * @return the material itself allowing "fluent" like uniform updates
  74970. */
  74971. setVector3(name: string, value: Vector3): ShaderMaterial;
  74972. /**
  74973. * Set a vec4 in the shader from a Vector4.
  74974. * @param name Define the name of the uniform as defined in the shader
  74975. * @param value Define the value to give to the uniform
  74976. * @return the material itself allowing "fluent" like uniform updates
  74977. */
  74978. setVector4(name: string, value: Vector4): ShaderMaterial;
  74979. /**
  74980. * Set a mat4 in the shader from a Matrix.
  74981. * @param name Define the name of the uniform as defined in the shader
  74982. * @param value Define the value to give to the uniform
  74983. * @return the material itself allowing "fluent" like uniform updates
  74984. */
  74985. setMatrix(name: string, value: Matrix): ShaderMaterial;
  74986. /**
  74987. * Set a mat3 in the shader from a Float32Array.
  74988. * @param name Define the name of the uniform as defined in the shader
  74989. * @param value Define the value to give to the uniform
  74990. * @return the material itself allowing "fluent" like uniform updates
  74991. */
  74992. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  74993. /**
  74994. * Set a mat2 in the shader from a Float32Array.
  74995. * @param name Define the name of the uniform as defined in the shader
  74996. * @param value Define the value to give to the uniform
  74997. * @return the material itself allowing "fluent" like uniform updates
  74998. */
  74999. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  75000. /**
  75001. * Set a vec2 array in the shader from a number array.
  75002. * @param name Define the name of the uniform as defined in the shader
  75003. * @param value Define the value to give to the uniform
  75004. * @return the material itself allowing "fluent" like uniform updates
  75005. */
  75006. setArray2(name: string, value: number[]): ShaderMaterial;
  75007. /**
  75008. * Set a vec3 array in the shader from a number array.
  75009. * @param name Define the name of the uniform as defined in the shader
  75010. * @param value Define the value to give to the uniform
  75011. * @return the material itself allowing "fluent" like uniform updates
  75012. */
  75013. setArray3(name: string, value: number[]): ShaderMaterial;
  75014. /**
  75015. * Set a vec4 array in the shader from a number array.
  75016. * @param name Define the name of the uniform as defined in the shader
  75017. * @param value Define the value to give to the uniform
  75018. * @return the material itself allowing "fluent" like uniform updates
  75019. */
  75020. setArray4(name: string, value: number[]): ShaderMaterial;
  75021. private _checkCache;
  75022. /**
  75023. * Specifies that the submesh is ready to be used
  75024. * @param mesh defines the mesh to check
  75025. * @param subMesh defines which submesh to check
  75026. * @param useInstances specifies that instances should be used
  75027. * @returns a boolean indicating that the submesh is ready or not
  75028. */
  75029. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  75030. /**
  75031. * Checks if the material is ready to render the requested mesh
  75032. * @param mesh Define the mesh to render
  75033. * @param useInstances Define whether or not the material is used with instances
  75034. * @returns true if ready, otherwise false
  75035. */
  75036. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  75037. /**
  75038. * Binds the world matrix to the material
  75039. * @param world defines the world transformation matrix
  75040. */
  75041. bindOnlyWorldMatrix(world: Matrix): void;
  75042. /**
  75043. * Binds the material to the mesh
  75044. * @param world defines the world transformation matrix
  75045. * @param mesh defines the mesh to bind the material to
  75046. */
  75047. bind(world: Matrix, mesh?: Mesh): void;
  75048. /**
  75049. * Gets the active textures from the material
  75050. * @returns an array of textures
  75051. */
  75052. getActiveTextures(): BaseTexture[];
  75053. /**
  75054. * Specifies if the material uses a texture
  75055. * @param texture defines the texture to check against the material
  75056. * @returns a boolean specifying if the material uses the texture
  75057. */
  75058. hasTexture(texture: BaseTexture): boolean;
  75059. /**
  75060. * Makes a duplicate of the material, and gives it a new name
  75061. * @param name defines the new name for the duplicated material
  75062. * @returns the cloned material
  75063. */
  75064. clone(name: string): ShaderMaterial;
  75065. /**
  75066. * Disposes the material
  75067. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  75068. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  75069. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  75070. */
  75071. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  75072. /**
  75073. * Serializes this material in a JSON representation
  75074. * @returns the serialized material object
  75075. */
  75076. serialize(): any;
  75077. /**
  75078. * Creates a shader material from parsed shader material data
  75079. * @param source defines the JSON represnetation of the material
  75080. * @param scene defines the hosting scene
  75081. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  75082. * @returns a new material
  75083. */
  75084. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  75085. }
  75086. }
  75087. declare module BABYLON {
  75088. /** @hidden */
  75089. export var clipPlaneFragmentDeclaration: {
  75090. name: string;
  75091. shader: string;
  75092. };
  75093. }
  75094. declare module BABYLON {
  75095. /** @hidden */
  75096. export var clipPlaneFragment: {
  75097. name: string;
  75098. shader: string;
  75099. };
  75100. }
  75101. declare module BABYLON {
  75102. /** @hidden */
  75103. export var colorPixelShader: {
  75104. name: string;
  75105. shader: string;
  75106. };
  75107. }
  75108. declare module BABYLON {
  75109. /** @hidden */
  75110. export var clipPlaneVertexDeclaration: {
  75111. name: string;
  75112. shader: string;
  75113. };
  75114. }
  75115. declare module BABYLON {
  75116. /** @hidden */
  75117. export var clipPlaneVertex: {
  75118. name: string;
  75119. shader: string;
  75120. };
  75121. }
  75122. declare module BABYLON {
  75123. /** @hidden */
  75124. export var colorVertexShader: {
  75125. name: string;
  75126. shader: string;
  75127. };
  75128. }
  75129. declare module BABYLON {
  75130. /**
  75131. * Line mesh
  75132. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  75133. */
  75134. export class LinesMesh extends Mesh {
  75135. /**
  75136. * If vertex color should be applied to the mesh
  75137. */
  75138. readonly useVertexColor?: boolean | undefined;
  75139. /**
  75140. * If vertex alpha should be applied to the mesh
  75141. */
  75142. readonly useVertexAlpha?: boolean | undefined;
  75143. /**
  75144. * Color of the line (Default: White)
  75145. */
  75146. color: Color3;
  75147. /**
  75148. * Alpha of the line (Default: 1)
  75149. */
  75150. alpha: number;
  75151. /**
  75152. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75153. * This margin is expressed in world space coordinates, so its value may vary.
  75154. * Default value is 0.1
  75155. */
  75156. intersectionThreshold: number;
  75157. private _colorShader;
  75158. private color4;
  75159. /**
  75160. * Creates a new LinesMesh
  75161. * @param name defines the name
  75162. * @param scene defines the hosting scene
  75163. * @param parent defines the parent mesh if any
  75164. * @param source defines the optional source LinesMesh used to clone data from
  75165. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  75166. * When false, achieved by calling a clone(), also passing False.
  75167. * This will make creation of children, recursive.
  75168. * @param useVertexColor defines if this LinesMesh supports vertex color
  75169. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  75170. */
  75171. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  75172. /**
  75173. * If vertex color should be applied to the mesh
  75174. */
  75175. useVertexColor?: boolean | undefined,
  75176. /**
  75177. * If vertex alpha should be applied to the mesh
  75178. */
  75179. useVertexAlpha?: boolean | undefined);
  75180. private _addClipPlaneDefine;
  75181. private _removeClipPlaneDefine;
  75182. isReady(): boolean;
  75183. /**
  75184. * Returns the string "LineMesh"
  75185. */
  75186. getClassName(): string;
  75187. /**
  75188. * @hidden
  75189. */
  75190. /**
  75191. * @hidden
  75192. */
  75193. material: Material;
  75194. /**
  75195. * @hidden
  75196. */
  75197. readonly checkCollisions: boolean;
  75198. /** @hidden */
  75199. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  75200. /** @hidden */
  75201. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  75202. /**
  75203. * Disposes of the line mesh
  75204. * @param doNotRecurse If children should be disposed
  75205. */
  75206. dispose(doNotRecurse?: boolean): void;
  75207. /**
  75208. * Returns a new LineMesh object cloned from the current one.
  75209. */
  75210. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  75211. /**
  75212. * Creates a new InstancedLinesMesh object from the mesh model.
  75213. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  75214. * @param name defines the name of the new instance
  75215. * @returns a new InstancedLinesMesh
  75216. */
  75217. createInstance(name: string): InstancedLinesMesh;
  75218. }
  75219. /**
  75220. * Creates an instance based on a source LinesMesh
  75221. */
  75222. export class InstancedLinesMesh extends InstancedMesh {
  75223. /**
  75224. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  75225. * This margin is expressed in world space coordinates, so its value may vary.
  75226. * Initilized with the intersectionThreshold value of the source LinesMesh
  75227. */
  75228. intersectionThreshold: number;
  75229. constructor(name: string, source: LinesMesh);
  75230. /**
  75231. * Returns the string "InstancedLinesMesh".
  75232. */
  75233. getClassName(): string;
  75234. }
  75235. }
  75236. declare module BABYLON {
  75237. /**
  75238. * Mesh representing the gorund
  75239. */
  75240. export class GroundMesh extends Mesh {
  75241. /** If octree should be generated */
  75242. generateOctree: boolean;
  75243. private _heightQuads;
  75244. /** @hidden */
  75245. _subdivisionsX: number;
  75246. /** @hidden */
  75247. _subdivisionsY: number;
  75248. /** @hidden */
  75249. _width: number;
  75250. /** @hidden */
  75251. _height: number;
  75252. /** @hidden */
  75253. _minX: number;
  75254. /** @hidden */
  75255. _maxX: number;
  75256. /** @hidden */
  75257. _minZ: number;
  75258. /** @hidden */
  75259. _maxZ: number;
  75260. constructor(name: string, scene: Scene);
  75261. /**
  75262. * "GroundMesh"
  75263. * @returns "GroundMesh"
  75264. */
  75265. getClassName(): string;
  75266. /**
  75267. * The minimum of x and y subdivisions
  75268. */
  75269. readonly subdivisions: number;
  75270. /**
  75271. * X subdivisions
  75272. */
  75273. readonly subdivisionsX: number;
  75274. /**
  75275. * Y subdivisions
  75276. */
  75277. readonly subdivisionsY: number;
  75278. /**
  75279. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  75280. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  75281. * @param chunksCount the number of subdivisions for x and y
  75282. * @param octreeBlocksSize (Default: 32)
  75283. */
  75284. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  75285. /**
  75286. * Returns a height (y) value in the Worl system :
  75287. * the ground altitude at the coordinates (x, z) expressed in the World system.
  75288. * @param x x coordinate
  75289. * @param z z coordinate
  75290. * @returns the ground y position if (x, z) are outside the ground surface.
  75291. */
  75292. getHeightAtCoordinates(x: number, z: number): number;
  75293. /**
  75294. * Returns a normalized vector (Vector3) orthogonal to the ground
  75295. * at the ground coordinates (x, z) expressed in the World system.
  75296. * @param x x coordinate
  75297. * @param z z coordinate
  75298. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  75299. */
  75300. getNormalAtCoordinates(x: number, z: number): Vector3;
  75301. /**
  75302. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  75303. * at the ground coordinates (x, z) expressed in the World system.
  75304. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  75305. * @param x x coordinate
  75306. * @param z z coordinate
  75307. * @param ref vector to store the result
  75308. * @returns the GroundMesh.
  75309. */
  75310. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  75311. /**
  75312. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  75313. * if the ground has been updated.
  75314. * This can be used in the render loop.
  75315. * @returns the GroundMesh.
  75316. */
  75317. updateCoordinateHeights(): GroundMesh;
  75318. private _getFacetAt;
  75319. private _initHeightQuads;
  75320. private _computeHeightQuads;
  75321. /**
  75322. * Serializes this ground mesh
  75323. * @param serializationObject object to write serialization to
  75324. */
  75325. serialize(serializationObject: any): void;
  75326. /**
  75327. * Parses a serialized ground mesh
  75328. * @param parsedMesh the serialized mesh
  75329. * @param scene the scene to create the ground mesh in
  75330. * @returns the created ground mesh
  75331. */
  75332. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  75333. }
  75334. }
  75335. declare module BABYLON {
  75336. /**
  75337. * Interface for Physics-Joint data
  75338. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75339. */
  75340. export interface PhysicsJointData {
  75341. /**
  75342. * The main pivot of the joint
  75343. */
  75344. mainPivot?: Vector3;
  75345. /**
  75346. * The connected pivot of the joint
  75347. */
  75348. connectedPivot?: Vector3;
  75349. /**
  75350. * The main axis of the joint
  75351. */
  75352. mainAxis?: Vector3;
  75353. /**
  75354. * The connected axis of the joint
  75355. */
  75356. connectedAxis?: Vector3;
  75357. /**
  75358. * The collision of the joint
  75359. */
  75360. collision?: boolean;
  75361. /**
  75362. * Native Oimo/Cannon/Energy data
  75363. */
  75364. nativeParams?: any;
  75365. }
  75366. /**
  75367. * This is a holder class for the physics joint created by the physics plugin
  75368. * It holds a set of functions to control the underlying joint
  75369. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75370. */
  75371. export class PhysicsJoint {
  75372. /**
  75373. * The type of the physics joint
  75374. */
  75375. type: number;
  75376. /**
  75377. * The data for the physics joint
  75378. */
  75379. jointData: PhysicsJointData;
  75380. private _physicsJoint;
  75381. protected _physicsPlugin: IPhysicsEnginePlugin;
  75382. /**
  75383. * Initializes the physics joint
  75384. * @param type The type of the physics joint
  75385. * @param jointData The data for the physics joint
  75386. */
  75387. constructor(
  75388. /**
  75389. * The type of the physics joint
  75390. */
  75391. type: number,
  75392. /**
  75393. * The data for the physics joint
  75394. */
  75395. jointData: PhysicsJointData);
  75396. /**
  75397. * Gets the physics joint
  75398. */
  75399. /**
  75400. * Sets the physics joint
  75401. */
  75402. physicsJoint: any;
  75403. /**
  75404. * Sets the physics plugin
  75405. */
  75406. physicsPlugin: IPhysicsEnginePlugin;
  75407. /**
  75408. * Execute a function that is physics-plugin specific.
  75409. * @param {Function} func the function that will be executed.
  75410. * It accepts two parameters: the physics world and the physics joint
  75411. */
  75412. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  75413. /**
  75414. * Distance-Joint type
  75415. */
  75416. static DistanceJoint: number;
  75417. /**
  75418. * Hinge-Joint type
  75419. */
  75420. static HingeJoint: number;
  75421. /**
  75422. * Ball-and-Socket joint type
  75423. */
  75424. static BallAndSocketJoint: number;
  75425. /**
  75426. * Wheel-Joint type
  75427. */
  75428. static WheelJoint: number;
  75429. /**
  75430. * Slider-Joint type
  75431. */
  75432. static SliderJoint: number;
  75433. /**
  75434. * Prismatic-Joint type
  75435. */
  75436. static PrismaticJoint: number;
  75437. /**
  75438. * Universal-Joint type
  75439. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  75440. */
  75441. static UniversalJoint: number;
  75442. /**
  75443. * Hinge-Joint 2 type
  75444. */
  75445. static Hinge2Joint: number;
  75446. /**
  75447. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  75448. */
  75449. static PointToPointJoint: number;
  75450. /**
  75451. * Spring-Joint type
  75452. */
  75453. static SpringJoint: number;
  75454. /**
  75455. * Lock-Joint type
  75456. */
  75457. static LockJoint: number;
  75458. }
  75459. /**
  75460. * A class representing a physics distance joint
  75461. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75462. */
  75463. export class DistanceJoint extends PhysicsJoint {
  75464. /**
  75465. *
  75466. * @param jointData The data for the Distance-Joint
  75467. */
  75468. constructor(jointData: DistanceJointData);
  75469. /**
  75470. * Update the predefined distance.
  75471. * @param maxDistance The maximum preferred distance
  75472. * @param minDistance The minimum preferred distance
  75473. */
  75474. updateDistance(maxDistance: number, minDistance?: number): void;
  75475. }
  75476. /**
  75477. * Represents a Motor-Enabled Joint
  75478. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75479. */
  75480. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  75481. /**
  75482. * Initializes the Motor-Enabled Joint
  75483. * @param type The type of the joint
  75484. * @param jointData The physica joint data for the joint
  75485. */
  75486. constructor(type: number, jointData: PhysicsJointData);
  75487. /**
  75488. * Set the motor values.
  75489. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75490. * @param force the force to apply
  75491. * @param maxForce max force for this motor.
  75492. */
  75493. setMotor(force?: number, maxForce?: number): void;
  75494. /**
  75495. * Set the motor's limits.
  75496. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75497. * @param upperLimit The upper limit of the motor
  75498. * @param lowerLimit The lower limit of the motor
  75499. */
  75500. setLimit(upperLimit: number, lowerLimit?: number): void;
  75501. }
  75502. /**
  75503. * This class represents a single physics Hinge-Joint
  75504. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75505. */
  75506. export class HingeJoint extends MotorEnabledJoint {
  75507. /**
  75508. * Initializes the Hinge-Joint
  75509. * @param jointData The joint data for the Hinge-Joint
  75510. */
  75511. constructor(jointData: PhysicsJointData);
  75512. /**
  75513. * Set the motor values.
  75514. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75515. * @param {number} force the force to apply
  75516. * @param {number} maxForce max force for this motor.
  75517. */
  75518. setMotor(force?: number, maxForce?: number): void;
  75519. /**
  75520. * Set the motor's limits.
  75521. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75522. * @param upperLimit The upper limit of the motor
  75523. * @param lowerLimit The lower limit of the motor
  75524. */
  75525. setLimit(upperLimit: number, lowerLimit?: number): void;
  75526. }
  75527. /**
  75528. * This class represents a dual hinge physics joint (same as wheel joint)
  75529. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75530. */
  75531. export class Hinge2Joint extends MotorEnabledJoint {
  75532. /**
  75533. * Initializes the Hinge2-Joint
  75534. * @param jointData The joint data for the Hinge2-Joint
  75535. */
  75536. constructor(jointData: PhysicsJointData);
  75537. /**
  75538. * Set the motor values.
  75539. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75540. * @param {number} targetSpeed the speed the motor is to reach
  75541. * @param {number} maxForce max force for this motor.
  75542. * @param {motorIndex} the motor's index, 0 or 1.
  75543. */
  75544. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  75545. /**
  75546. * Set the motor limits.
  75547. * Attention, this function is plugin specific. Engines won't react 100% the same.
  75548. * @param {number} upperLimit the upper limit
  75549. * @param {number} lowerLimit lower limit
  75550. * @param {motorIndex} the motor's index, 0 or 1.
  75551. */
  75552. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  75553. }
  75554. /**
  75555. * Interface for a motor enabled joint
  75556. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75557. */
  75558. export interface IMotorEnabledJoint {
  75559. /**
  75560. * Physics joint
  75561. */
  75562. physicsJoint: any;
  75563. /**
  75564. * Sets the motor of the motor-enabled joint
  75565. * @param force The force of the motor
  75566. * @param maxForce The maximum force of the motor
  75567. * @param motorIndex The index of the motor
  75568. */
  75569. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  75570. /**
  75571. * Sets the limit of the motor
  75572. * @param upperLimit The upper limit of the motor
  75573. * @param lowerLimit The lower limit of the motor
  75574. * @param motorIndex The index of the motor
  75575. */
  75576. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  75577. }
  75578. /**
  75579. * Joint data for a Distance-Joint
  75580. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75581. */
  75582. export interface DistanceJointData extends PhysicsJointData {
  75583. /**
  75584. * Max distance the 2 joint objects can be apart
  75585. */
  75586. maxDistance: number;
  75587. }
  75588. /**
  75589. * Joint data from a spring joint
  75590. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75591. */
  75592. export interface SpringJointData extends PhysicsJointData {
  75593. /**
  75594. * Length of the spring
  75595. */
  75596. length: number;
  75597. /**
  75598. * Stiffness of the spring
  75599. */
  75600. stiffness: number;
  75601. /**
  75602. * Damping of the spring
  75603. */
  75604. damping: number;
  75605. /** this callback will be called when applying the force to the impostors. */
  75606. forceApplicationCallback: () => void;
  75607. }
  75608. }
  75609. declare module BABYLON {
  75610. /**
  75611. * Holds the data for the raycast result
  75612. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75613. */
  75614. export class PhysicsRaycastResult {
  75615. private _hasHit;
  75616. private _hitDistance;
  75617. private _hitNormalWorld;
  75618. private _hitPointWorld;
  75619. private _rayFromWorld;
  75620. private _rayToWorld;
  75621. /**
  75622. * Gets if there was a hit
  75623. */
  75624. readonly hasHit: boolean;
  75625. /**
  75626. * Gets the distance from the hit
  75627. */
  75628. readonly hitDistance: number;
  75629. /**
  75630. * Gets the hit normal/direction in the world
  75631. */
  75632. readonly hitNormalWorld: Vector3;
  75633. /**
  75634. * Gets the hit point in the world
  75635. */
  75636. readonly hitPointWorld: Vector3;
  75637. /**
  75638. * Gets the ray "start point" of the ray in the world
  75639. */
  75640. readonly rayFromWorld: Vector3;
  75641. /**
  75642. * Gets the ray "end point" of the ray in the world
  75643. */
  75644. readonly rayToWorld: Vector3;
  75645. /**
  75646. * Sets the hit data (normal & point in world space)
  75647. * @param hitNormalWorld defines the normal in world space
  75648. * @param hitPointWorld defines the point in world space
  75649. */
  75650. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  75651. /**
  75652. * Sets the distance from the start point to the hit point
  75653. * @param distance
  75654. */
  75655. setHitDistance(distance: number): void;
  75656. /**
  75657. * Calculates the distance manually
  75658. */
  75659. calculateHitDistance(): void;
  75660. /**
  75661. * Resets all the values to default
  75662. * @param from The from point on world space
  75663. * @param to The to point on world space
  75664. */
  75665. reset(from?: Vector3, to?: Vector3): void;
  75666. }
  75667. /**
  75668. * Interface for the size containing width and height
  75669. */
  75670. interface IXYZ {
  75671. /**
  75672. * X
  75673. */
  75674. x: number;
  75675. /**
  75676. * Y
  75677. */
  75678. y: number;
  75679. /**
  75680. * Z
  75681. */
  75682. z: number;
  75683. }
  75684. }
  75685. declare module BABYLON {
  75686. /**
  75687. * Interface used to describe a physics joint
  75688. */
  75689. export interface PhysicsImpostorJoint {
  75690. /** Defines the main impostor to which the joint is linked */
  75691. mainImpostor: PhysicsImpostor;
  75692. /** Defines the impostor that is connected to the main impostor using this joint */
  75693. connectedImpostor: PhysicsImpostor;
  75694. /** Defines the joint itself */
  75695. joint: PhysicsJoint;
  75696. }
  75697. /** @hidden */
  75698. export interface IPhysicsEnginePlugin {
  75699. world: any;
  75700. name: string;
  75701. setGravity(gravity: Vector3): void;
  75702. setTimeStep(timeStep: number): void;
  75703. getTimeStep(): number;
  75704. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  75705. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  75706. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  75707. generatePhysicsBody(impostor: PhysicsImpostor): void;
  75708. removePhysicsBody(impostor: PhysicsImpostor): void;
  75709. generateJoint(joint: PhysicsImpostorJoint): void;
  75710. removeJoint(joint: PhysicsImpostorJoint): void;
  75711. isSupported(): boolean;
  75712. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  75713. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  75714. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  75715. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  75716. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  75717. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  75718. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  75719. getBodyMass(impostor: PhysicsImpostor): number;
  75720. getBodyFriction(impostor: PhysicsImpostor): number;
  75721. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  75722. getBodyRestitution(impostor: PhysicsImpostor): number;
  75723. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  75724. getBodyPressure?(impostor: PhysicsImpostor): number;
  75725. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  75726. getBodyStiffness?(impostor: PhysicsImpostor): number;
  75727. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  75728. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  75729. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  75730. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  75731. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  75732. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  75733. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  75734. sleepBody(impostor: PhysicsImpostor): void;
  75735. wakeUpBody(impostor: PhysicsImpostor): void;
  75736. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  75737. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  75738. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  75739. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  75740. getRadius(impostor: PhysicsImpostor): number;
  75741. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  75742. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  75743. dispose(): void;
  75744. }
  75745. /**
  75746. * Interface used to define a physics engine
  75747. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  75748. */
  75749. export interface IPhysicsEngine {
  75750. /**
  75751. * Gets the gravity vector used by the simulation
  75752. */
  75753. gravity: Vector3;
  75754. /**
  75755. * Sets the gravity vector used by the simulation
  75756. * @param gravity defines the gravity vector to use
  75757. */
  75758. setGravity(gravity: Vector3): void;
  75759. /**
  75760. * Set the time step of the physics engine.
  75761. * Default is 1/60.
  75762. * To slow it down, enter 1/600 for example.
  75763. * To speed it up, 1/30
  75764. * @param newTimeStep the new timestep to apply to this world.
  75765. */
  75766. setTimeStep(newTimeStep: number): void;
  75767. /**
  75768. * Get the time step of the physics engine.
  75769. * @returns the current time step
  75770. */
  75771. getTimeStep(): number;
  75772. /**
  75773. * Release all resources
  75774. */
  75775. dispose(): void;
  75776. /**
  75777. * Gets the name of the current physics plugin
  75778. * @returns the name of the plugin
  75779. */
  75780. getPhysicsPluginName(): string;
  75781. /**
  75782. * Adding a new impostor for the impostor tracking.
  75783. * This will be done by the impostor itself.
  75784. * @param impostor the impostor to add
  75785. */
  75786. addImpostor(impostor: PhysicsImpostor): void;
  75787. /**
  75788. * Remove an impostor from the engine.
  75789. * This impostor and its mesh will not longer be updated by the physics engine.
  75790. * @param impostor the impostor to remove
  75791. */
  75792. removeImpostor(impostor: PhysicsImpostor): void;
  75793. /**
  75794. * Add a joint to the physics engine
  75795. * @param mainImpostor defines the main impostor to which the joint is added.
  75796. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  75797. * @param joint defines the joint that will connect both impostors.
  75798. */
  75799. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  75800. /**
  75801. * Removes a joint from the simulation
  75802. * @param mainImpostor defines the impostor used with the joint
  75803. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  75804. * @param joint defines the joint to remove
  75805. */
  75806. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  75807. /**
  75808. * Gets the current plugin used to run the simulation
  75809. * @returns current plugin
  75810. */
  75811. getPhysicsPlugin(): IPhysicsEnginePlugin;
  75812. /**
  75813. * Gets the list of physic impostors
  75814. * @returns an array of PhysicsImpostor
  75815. */
  75816. getImpostors(): Array<PhysicsImpostor>;
  75817. /**
  75818. * Gets the impostor for a physics enabled object
  75819. * @param object defines the object impersonated by the impostor
  75820. * @returns the PhysicsImpostor or null if not found
  75821. */
  75822. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  75823. /**
  75824. * Gets the impostor for a physics body object
  75825. * @param body defines physics body used by the impostor
  75826. * @returns the PhysicsImpostor or null if not found
  75827. */
  75828. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  75829. /**
  75830. * Does a raycast in the physics world
  75831. * @param from when should the ray start?
  75832. * @param to when should the ray end?
  75833. * @returns PhysicsRaycastResult
  75834. */
  75835. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  75836. /**
  75837. * Called by the scene. No need to call it.
  75838. * @param delta defines the timespam between frames
  75839. */
  75840. _step(delta: number): void;
  75841. }
  75842. }
  75843. declare module BABYLON {
  75844. /**
  75845. * The interface for the physics imposter parameters
  75846. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75847. */
  75848. export interface PhysicsImpostorParameters {
  75849. /**
  75850. * The mass of the physics imposter
  75851. */
  75852. mass: number;
  75853. /**
  75854. * The friction of the physics imposter
  75855. */
  75856. friction?: number;
  75857. /**
  75858. * The coefficient of restitution of the physics imposter
  75859. */
  75860. restitution?: number;
  75861. /**
  75862. * The native options of the physics imposter
  75863. */
  75864. nativeOptions?: any;
  75865. /**
  75866. * Specifies if the parent should be ignored
  75867. */
  75868. ignoreParent?: boolean;
  75869. /**
  75870. * Specifies if bi-directional transformations should be disabled
  75871. */
  75872. disableBidirectionalTransformation?: boolean;
  75873. /**
  75874. * The pressure inside the physics imposter, soft object only
  75875. */
  75876. pressure?: number;
  75877. /**
  75878. * The stiffness the physics imposter, soft object only
  75879. */
  75880. stiffness?: number;
  75881. /**
  75882. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  75883. */
  75884. velocityIterations?: number;
  75885. /**
  75886. * The number of iterations used in maintaining consistent vertex positions, soft object only
  75887. */
  75888. positionIterations?: number;
  75889. /**
  75890. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  75891. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  75892. * Add to fix multiple points
  75893. */
  75894. fixedPoints?: number;
  75895. /**
  75896. * The collision margin around a soft object
  75897. */
  75898. margin?: number;
  75899. /**
  75900. * The collision margin around a soft object
  75901. */
  75902. damping?: number;
  75903. /**
  75904. * The path for a rope based on an extrusion
  75905. */
  75906. path?: any;
  75907. /**
  75908. * The shape of an extrusion used for a rope based on an extrusion
  75909. */
  75910. shape?: any;
  75911. }
  75912. /**
  75913. * Interface for a physics-enabled object
  75914. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  75915. */
  75916. export interface IPhysicsEnabledObject {
  75917. /**
  75918. * The position of the physics-enabled object
  75919. */
  75920. position: Vector3;
  75921. /**
  75922. * The rotation of the physics-enabled object
  75923. */
  75924. rotationQuaternion: Nullable<Quaternion>;
  75925. /**
  75926. * The scale of the physics-enabled object
  75927. */
  75928. scaling: Vector3;
  75929. /**
  75930. * The rotation of the physics-enabled object
  75931. */
  75932. rotation?: Vector3;
  75933. /**
  75934. * The parent of the physics-enabled object
  75935. */
  75936. parent?: any;
  75937. /**
  75938. * The bounding info of the physics-enabled object
  75939. * @returns The bounding info of the physics-enabled object
  75940. */
  75941. getBoundingInfo(): BoundingInfo;
  75942. /**
  75943. * Computes the world matrix
  75944. * @param force Specifies if the world matrix should be computed by force
  75945. * @returns A world matrix
  75946. */
  75947. computeWorldMatrix(force: boolean): Matrix;
  75948. /**
  75949. * Gets the world matrix
  75950. * @returns A world matrix
  75951. */
  75952. getWorldMatrix?(): Matrix;
  75953. /**
  75954. * Gets the child meshes
  75955. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  75956. * @returns An array of abstract meshes
  75957. */
  75958. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  75959. /**
  75960. * Gets the vertex data
  75961. * @param kind The type of vertex data
  75962. * @returns A nullable array of numbers, or a float32 array
  75963. */
  75964. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  75965. /**
  75966. * Gets the indices from the mesh
  75967. * @returns A nullable array of index arrays
  75968. */
  75969. getIndices?(): Nullable<IndicesArray>;
  75970. /**
  75971. * Gets the scene from the mesh
  75972. * @returns the indices array or null
  75973. */
  75974. getScene?(): Scene;
  75975. /**
  75976. * Gets the absolute position from the mesh
  75977. * @returns the absolute position
  75978. */
  75979. getAbsolutePosition(): Vector3;
  75980. /**
  75981. * Gets the absolute pivot point from the mesh
  75982. * @returns the absolute pivot point
  75983. */
  75984. getAbsolutePivotPoint(): Vector3;
  75985. /**
  75986. * Rotates the mesh
  75987. * @param axis The axis of rotation
  75988. * @param amount The amount of rotation
  75989. * @param space The space of the rotation
  75990. * @returns The rotation transform node
  75991. */
  75992. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  75993. /**
  75994. * Translates the mesh
  75995. * @param axis The axis of translation
  75996. * @param distance The distance of translation
  75997. * @param space The space of the translation
  75998. * @returns The transform node
  75999. */
  76000. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  76001. /**
  76002. * Sets the absolute position of the mesh
  76003. * @param absolutePosition The absolute position of the mesh
  76004. * @returns The transform node
  76005. */
  76006. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  76007. /**
  76008. * Gets the class name of the mesh
  76009. * @returns The class name
  76010. */
  76011. getClassName(): string;
  76012. }
  76013. /**
  76014. * Represents a physics imposter
  76015. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  76016. */
  76017. export class PhysicsImpostor {
  76018. /**
  76019. * The physics-enabled object used as the physics imposter
  76020. */
  76021. object: IPhysicsEnabledObject;
  76022. /**
  76023. * The type of the physics imposter
  76024. */
  76025. type: number;
  76026. private _options;
  76027. private _scene?;
  76028. /**
  76029. * The default object size of the imposter
  76030. */
  76031. static DEFAULT_OBJECT_SIZE: Vector3;
  76032. /**
  76033. * The identity quaternion of the imposter
  76034. */
  76035. static IDENTITY_QUATERNION: Quaternion;
  76036. /** @hidden */
  76037. _pluginData: any;
  76038. private _physicsEngine;
  76039. private _physicsBody;
  76040. private _bodyUpdateRequired;
  76041. private _onBeforePhysicsStepCallbacks;
  76042. private _onAfterPhysicsStepCallbacks;
  76043. /** @hidden */
  76044. _onPhysicsCollideCallbacks: Array<{
  76045. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  76046. otherImpostors: Array<PhysicsImpostor>;
  76047. }>;
  76048. private _deltaPosition;
  76049. private _deltaRotation;
  76050. private _deltaRotationConjugated;
  76051. /** @hidden */
  76052. _isFromLine: boolean;
  76053. private _parent;
  76054. private _isDisposed;
  76055. private static _tmpVecs;
  76056. private static _tmpQuat;
  76057. /**
  76058. * Specifies if the physics imposter is disposed
  76059. */
  76060. readonly isDisposed: boolean;
  76061. /**
  76062. * Gets the mass of the physics imposter
  76063. */
  76064. mass: number;
  76065. /**
  76066. * Gets the coefficient of friction
  76067. */
  76068. /**
  76069. * Sets the coefficient of friction
  76070. */
  76071. friction: number;
  76072. /**
  76073. * Gets the coefficient of restitution
  76074. */
  76075. /**
  76076. * Sets the coefficient of restitution
  76077. */
  76078. restitution: number;
  76079. /**
  76080. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  76081. */
  76082. /**
  76083. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  76084. */
  76085. pressure: number;
  76086. /**
  76087. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  76088. */
  76089. /**
  76090. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  76091. */
  76092. stiffness: number;
  76093. /**
  76094. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  76095. */
  76096. /**
  76097. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  76098. */
  76099. velocityIterations: number;
  76100. /**
  76101. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  76102. */
  76103. /**
  76104. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  76105. */
  76106. positionIterations: number;
  76107. /**
  76108. * The unique id of the physics imposter
  76109. * set by the physics engine when adding this impostor to the array
  76110. */
  76111. uniqueId: number;
  76112. /**
  76113. * @hidden
  76114. */
  76115. soft: boolean;
  76116. /**
  76117. * @hidden
  76118. */
  76119. segments: number;
  76120. private _joints;
  76121. /**
  76122. * Initializes the physics imposter
  76123. * @param object The physics-enabled object used as the physics imposter
  76124. * @param type The type of the physics imposter
  76125. * @param _options The options for the physics imposter
  76126. * @param _scene The Babylon scene
  76127. */
  76128. constructor(
  76129. /**
  76130. * The physics-enabled object used as the physics imposter
  76131. */
  76132. object: IPhysicsEnabledObject,
  76133. /**
  76134. * The type of the physics imposter
  76135. */
  76136. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  76137. /**
  76138. * This function will completly initialize this impostor.
  76139. * It will create a new body - but only if this mesh has no parent.
  76140. * If it has, this impostor will not be used other than to define the impostor
  76141. * of the child mesh.
  76142. * @hidden
  76143. */
  76144. _init(): void;
  76145. private _getPhysicsParent;
  76146. /**
  76147. * Should a new body be generated.
  76148. * @returns boolean specifying if body initialization is required
  76149. */
  76150. isBodyInitRequired(): boolean;
  76151. /**
  76152. * Sets the updated scaling
  76153. * @param updated Specifies if the scaling is updated
  76154. */
  76155. setScalingUpdated(): void;
  76156. /**
  76157. * Force a regeneration of this or the parent's impostor's body.
  76158. * Use under cautious - This will remove all joints already implemented.
  76159. */
  76160. forceUpdate(): void;
  76161. /**
  76162. * Gets the body that holds this impostor. Either its own, or its parent.
  76163. */
  76164. /**
  76165. * Set the physics body. Used mainly by the physics engine/plugin
  76166. */
  76167. physicsBody: any;
  76168. /**
  76169. * Get the parent of the physics imposter
  76170. * @returns Physics imposter or null
  76171. */
  76172. /**
  76173. * Sets the parent of the physics imposter
  76174. */
  76175. parent: Nullable<PhysicsImpostor>;
  76176. /**
  76177. * Resets the update flags
  76178. */
  76179. resetUpdateFlags(): void;
  76180. /**
  76181. * Gets the object extend size
  76182. * @returns the object extend size
  76183. */
  76184. getObjectExtendSize(): Vector3;
  76185. /**
  76186. * Gets the object center
  76187. * @returns The object center
  76188. */
  76189. getObjectCenter(): Vector3;
  76190. /**
  76191. * Get a specific parametes from the options parameter
  76192. * @param paramName The object parameter name
  76193. * @returns The object parameter
  76194. */
  76195. getParam(paramName: string): any;
  76196. /**
  76197. * Sets a specific parameter in the options given to the physics plugin
  76198. * @param paramName The parameter name
  76199. * @param value The value of the parameter
  76200. */
  76201. setParam(paramName: string, value: number): void;
  76202. /**
  76203. * Specifically change the body's mass option. Won't recreate the physics body object
  76204. * @param mass The mass of the physics imposter
  76205. */
  76206. setMass(mass: number): void;
  76207. /**
  76208. * Gets the linear velocity
  76209. * @returns linear velocity or null
  76210. */
  76211. getLinearVelocity(): Nullable<Vector3>;
  76212. /**
  76213. * Sets the linear velocity
  76214. * @param velocity linear velocity or null
  76215. */
  76216. setLinearVelocity(velocity: Nullable<Vector3>): void;
  76217. /**
  76218. * Gets the angular velocity
  76219. * @returns angular velocity or null
  76220. */
  76221. getAngularVelocity(): Nullable<Vector3>;
  76222. /**
  76223. * Sets the angular velocity
  76224. * @param velocity The velocity or null
  76225. */
  76226. setAngularVelocity(velocity: Nullable<Vector3>): void;
  76227. /**
  76228. * Execute a function with the physics plugin native code
  76229. * Provide a function the will have two variables - the world object and the physics body object
  76230. * @param func The function to execute with the physics plugin native code
  76231. */
  76232. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  76233. /**
  76234. * Register a function that will be executed before the physics world is stepping forward
  76235. * @param func The function to execute before the physics world is stepped forward
  76236. */
  76237. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76238. /**
  76239. * Unregister a function that will be executed before the physics world is stepping forward
  76240. * @param func The function to execute before the physics world is stepped forward
  76241. */
  76242. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76243. /**
  76244. * Register a function that will be executed after the physics step
  76245. * @param func The function to execute after physics step
  76246. */
  76247. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76248. /**
  76249. * Unregisters a function that will be executed after the physics step
  76250. * @param func The function to execute after physics step
  76251. */
  76252. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  76253. /**
  76254. * register a function that will be executed when this impostor collides against a different body
  76255. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  76256. * @param func Callback that is executed on collision
  76257. */
  76258. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  76259. /**
  76260. * Unregisters the physics imposter on contact
  76261. * @param collideAgainst The physics object to collide against
  76262. * @param func Callback to execute on collision
  76263. */
  76264. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  76265. private _tmpQuat;
  76266. private _tmpQuat2;
  76267. /**
  76268. * Get the parent rotation
  76269. * @returns The parent rotation
  76270. */
  76271. getParentsRotation(): Quaternion;
  76272. /**
  76273. * this function is executed by the physics engine.
  76274. */
  76275. beforeStep: () => void;
  76276. /**
  76277. * this function is executed by the physics engine
  76278. */
  76279. afterStep: () => void;
  76280. /**
  76281. * Legacy collision detection event support
  76282. */
  76283. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  76284. /**
  76285. * event and body object due to cannon's event-based architecture.
  76286. */
  76287. onCollide: (e: {
  76288. body: any;
  76289. }) => void;
  76290. /**
  76291. * Apply a force
  76292. * @param force The force to apply
  76293. * @param contactPoint The contact point for the force
  76294. * @returns The physics imposter
  76295. */
  76296. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  76297. /**
  76298. * Apply an impulse
  76299. * @param force The impulse force
  76300. * @param contactPoint The contact point for the impulse force
  76301. * @returns The physics imposter
  76302. */
  76303. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  76304. /**
  76305. * A help function to create a joint
  76306. * @param otherImpostor A physics imposter used to create a joint
  76307. * @param jointType The type of joint
  76308. * @param jointData The data for the joint
  76309. * @returns The physics imposter
  76310. */
  76311. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  76312. /**
  76313. * Add a joint to this impostor with a different impostor
  76314. * @param otherImpostor A physics imposter used to add a joint
  76315. * @param joint The joint to add
  76316. * @returns The physics imposter
  76317. */
  76318. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  76319. /**
  76320. * Add an anchor to a cloth impostor
  76321. * @param otherImpostor rigid impostor to anchor to
  76322. * @param width ratio across width from 0 to 1
  76323. * @param height ratio up height from 0 to 1
  76324. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  76325. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  76326. * @returns impostor the soft imposter
  76327. */
  76328. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  76329. /**
  76330. * Add a hook to a rope impostor
  76331. * @param otherImpostor rigid impostor to anchor to
  76332. * @param length ratio across rope from 0 to 1
  76333. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  76334. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  76335. * @returns impostor the rope imposter
  76336. */
  76337. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  76338. /**
  76339. * Will keep this body still, in a sleep mode.
  76340. * @returns the physics imposter
  76341. */
  76342. sleep(): PhysicsImpostor;
  76343. /**
  76344. * Wake the body up.
  76345. * @returns The physics imposter
  76346. */
  76347. wakeUp(): PhysicsImpostor;
  76348. /**
  76349. * Clones the physics imposter
  76350. * @param newObject The physics imposter clones to this physics-enabled object
  76351. * @returns A nullable physics imposter
  76352. */
  76353. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  76354. /**
  76355. * Disposes the physics imposter
  76356. */
  76357. dispose(): void;
  76358. /**
  76359. * Sets the delta position
  76360. * @param position The delta position amount
  76361. */
  76362. setDeltaPosition(position: Vector3): void;
  76363. /**
  76364. * Sets the delta rotation
  76365. * @param rotation The delta rotation amount
  76366. */
  76367. setDeltaRotation(rotation: Quaternion): void;
  76368. /**
  76369. * Gets the box size of the physics imposter and stores the result in the input parameter
  76370. * @param result Stores the box size
  76371. * @returns The physics imposter
  76372. */
  76373. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  76374. /**
  76375. * Gets the radius of the physics imposter
  76376. * @returns Radius of the physics imposter
  76377. */
  76378. getRadius(): number;
  76379. /**
  76380. * Sync a bone with this impostor
  76381. * @param bone The bone to sync to the impostor.
  76382. * @param boneMesh The mesh that the bone is influencing.
  76383. * @param jointPivot The pivot of the joint / bone in local space.
  76384. * @param distToJoint Optional distance from the impostor to the joint.
  76385. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  76386. */
  76387. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  76388. /**
  76389. * Sync impostor to a bone
  76390. * @param bone The bone that the impostor will be synced to.
  76391. * @param boneMesh The mesh that the bone is influencing.
  76392. * @param jointPivot The pivot of the joint / bone in local space.
  76393. * @param distToJoint Optional distance from the impostor to the joint.
  76394. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  76395. * @param boneAxis Optional vector3 axis the bone is aligned with
  76396. */
  76397. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  76398. /**
  76399. * No-Imposter type
  76400. */
  76401. static NoImpostor: number;
  76402. /**
  76403. * Sphere-Imposter type
  76404. */
  76405. static SphereImpostor: number;
  76406. /**
  76407. * Box-Imposter type
  76408. */
  76409. static BoxImpostor: number;
  76410. /**
  76411. * Plane-Imposter type
  76412. */
  76413. static PlaneImpostor: number;
  76414. /**
  76415. * Mesh-imposter type
  76416. */
  76417. static MeshImpostor: number;
  76418. /**
  76419. * Capsule-Impostor type (Ammo.js plugin only)
  76420. */
  76421. static CapsuleImpostor: number;
  76422. /**
  76423. * Cylinder-Imposter type
  76424. */
  76425. static CylinderImpostor: number;
  76426. /**
  76427. * Particle-Imposter type
  76428. */
  76429. static ParticleImpostor: number;
  76430. /**
  76431. * Heightmap-Imposter type
  76432. */
  76433. static HeightmapImpostor: number;
  76434. /**
  76435. * ConvexHull-Impostor type (Ammo.js plugin only)
  76436. */
  76437. static ConvexHullImpostor: number;
  76438. /**
  76439. * Rope-Imposter type
  76440. */
  76441. static RopeImpostor: number;
  76442. /**
  76443. * Cloth-Imposter type
  76444. */
  76445. static ClothImpostor: number;
  76446. /**
  76447. * Softbody-Imposter type
  76448. */
  76449. static SoftbodyImpostor: number;
  76450. }
  76451. }
  76452. declare module BABYLON {
  76453. /**
  76454. * @hidden
  76455. **/
  76456. export class _CreationDataStorage {
  76457. closePath?: boolean;
  76458. closeArray?: boolean;
  76459. idx: number[];
  76460. dashSize: number;
  76461. gapSize: number;
  76462. path3D: Path3D;
  76463. pathArray: Vector3[][];
  76464. arc: number;
  76465. radius: number;
  76466. cap: number;
  76467. tessellation: number;
  76468. }
  76469. /**
  76470. * @hidden
  76471. **/
  76472. class _InstanceDataStorage {
  76473. visibleInstances: any;
  76474. batchCache: _InstancesBatch;
  76475. instancesBufferSize: number;
  76476. instancesBuffer: Nullable<Buffer>;
  76477. instancesData: Float32Array;
  76478. overridenInstanceCount: number;
  76479. isFrozen: boolean;
  76480. previousBatch: Nullable<_InstancesBatch>;
  76481. hardwareInstancedRendering: boolean;
  76482. sideOrientation: number;
  76483. }
  76484. /**
  76485. * @hidden
  76486. **/
  76487. export class _InstancesBatch {
  76488. mustReturn: boolean;
  76489. visibleInstances: Nullable<InstancedMesh[]>[];
  76490. renderSelf: boolean[];
  76491. hardwareInstancedRendering: boolean[];
  76492. }
  76493. /**
  76494. * Class used to represent renderable models
  76495. */
  76496. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  76497. /**
  76498. * Mesh side orientation : usually the external or front surface
  76499. */
  76500. static readonly FRONTSIDE: number;
  76501. /**
  76502. * Mesh side orientation : usually the internal or back surface
  76503. */
  76504. static readonly BACKSIDE: number;
  76505. /**
  76506. * Mesh side orientation : both internal and external or front and back surfaces
  76507. */
  76508. static readonly DOUBLESIDE: number;
  76509. /**
  76510. * Mesh side orientation : by default, `FRONTSIDE`
  76511. */
  76512. static readonly DEFAULTSIDE: number;
  76513. /**
  76514. * Mesh cap setting : no cap
  76515. */
  76516. static readonly NO_CAP: number;
  76517. /**
  76518. * Mesh cap setting : one cap at the beginning of the mesh
  76519. */
  76520. static readonly CAP_START: number;
  76521. /**
  76522. * Mesh cap setting : one cap at the end of the mesh
  76523. */
  76524. static readonly CAP_END: number;
  76525. /**
  76526. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  76527. */
  76528. static readonly CAP_ALL: number;
  76529. /**
  76530. * Mesh pattern setting : no flip or rotate
  76531. */
  76532. static readonly NO_FLIP: number;
  76533. /**
  76534. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  76535. */
  76536. static readonly FLIP_TILE: number;
  76537. /**
  76538. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  76539. */
  76540. static readonly ROTATE_TILE: number;
  76541. /**
  76542. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  76543. */
  76544. static readonly FLIP_ROW: number;
  76545. /**
  76546. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  76547. */
  76548. static readonly ROTATE_ROW: number;
  76549. /**
  76550. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  76551. */
  76552. static readonly FLIP_N_ROTATE_TILE: number;
  76553. /**
  76554. * Mesh pattern setting : rotate pattern and rotate
  76555. */
  76556. static readonly FLIP_N_ROTATE_ROW: number;
  76557. /**
  76558. * Mesh tile positioning : part tiles same on left/right or top/bottom
  76559. */
  76560. static readonly CENTER: number;
  76561. /**
  76562. * Mesh tile positioning : part tiles on left
  76563. */
  76564. static readonly LEFT: number;
  76565. /**
  76566. * Mesh tile positioning : part tiles on right
  76567. */
  76568. static readonly RIGHT: number;
  76569. /**
  76570. * Mesh tile positioning : part tiles on top
  76571. */
  76572. static readonly TOP: number;
  76573. /**
  76574. * Mesh tile positioning : part tiles on bottom
  76575. */
  76576. static readonly BOTTOM: number;
  76577. /**
  76578. * Gets the default side orientation.
  76579. * @param orientation the orientation to value to attempt to get
  76580. * @returns the default orientation
  76581. * @hidden
  76582. */
  76583. static _GetDefaultSideOrientation(orientation?: number): number;
  76584. private _internalMeshDataInfo;
  76585. /**
  76586. * An event triggered before rendering the mesh
  76587. */
  76588. readonly onBeforeRenderObservable: Observable<Mesh>;
  76589. /**
  76590. * An event triggered before binding the mesh
  76591. */
  76592. readonly onBeforeBindObservable: Observable<Mesh>;
  76593. /**
  76594. * An event triggered after rendering the mesh
  76595. */
  76596. readonly onAfterRenderObservable: Observable<Mesh>;
  76597. /**
  76598. * An event triggered before drawing the mesh
  76599. */
  76600. readonly onBeforeDrawObservable: Observable<Mesh>;
  76601. private _onBeforeDrawObserver;
  76602. /**
  76603. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  76604. */
  76605. onBeforeDraw: () => void;
  76606. /**
  76607. * Gets the delay loading state of the mesh (when delay loading is turned on)
  76608. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  76609. */
  76610. delayLoadState: number;
  76611. /**
  76612. * Gets the list of instances created from this mesh
  76613. * it is not supposed to be modified manually.
  76614. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  76615. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  76616. */
  76617. instances: InstancedMesh[];
  76618. /**
  76619. * Gets the file containing delay loading data for this mesh
  76620. */
  76621. delayLoadingFile: string;
  76622. /** @hidden */
  76623. _binaryInfo: any;
  76624. /**
  76625. * User defined function used to change how LOD level selection is done
  76626. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  76627. */
  76628. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  76629. /**
  76630. * Gets or sets the morph target manager
  76631. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  76632. */
  76633. morphTargetManager: Nullable<MorphTargetManager>;
  76634. /** @hidden */
  76635. _creationDataStorage: Nullable<_CreationDataStorage>;
  76636. /** @hidden */
  76637. _geometry: Nullable<Geometry>;
  76638. /** @hidden */
  76639. _delayInfo: Array<string>;
  76640. /** @hidden */
  76641. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  76642. /** @hidden */
  76643. _instanceDataStorage: _InstanceDataStorage;
  76644. private _effectiveMaterial;
  76645. /** @hidden */
  76646. _shouldGenerateFlatShading: boolean;
  76647. /** @hidden */
  76648. _originalBuilderSideOrientation: number;
  76649. /**
  76650. * Use this property to change the original side orientation defined at construction time
  76651. */
  76652. overrideMaterialSideOrientation: Nullable<number>;
  76653. /**
  76654. * Gets the source mesh (the one used to clone this one from)
  76655. */
  76656. readonly source: Nullable<Mesh>;
  76657. /**
  76658. * Gets or sets a boolean indicating that this mesh does not use index buffer
  76659. */
  76660. isUnIndexed: boolean;
  76661. /**
  76662. * @constructor
  76663. * @param name The value used by scene.getMeshByName() to do a lookup.
  76664. * @param scene The scene to add this mesh to.
  76665. * @param parent The parent of this mesh, if it has one
  76666. * @param source An optional Mesh from which geometry is shared, cloned.
  76667. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  76668. * When false, achieved by calling a clone(), also passing False.
  76669. * This will make creation of children, recursive.
  76670. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  76671. */
  76672. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  76673. /**
  76674. * Gets the class name
  76675. * @returns the string "Mesh".
  76676. */
  76677. getClassName(): string;
  76678. /** @hidden */
  76679. readonly _isMesh: boolean;
  76680. /**
  76681. * Returns a description of this mesh
  76682. * @param fullDetails define if full details about this mesh must be used
  76683. * @returns a descriptive string representing this mesh
  76684. */
  76685. toString(fullDetails?: boolean): string;
  76686. /** @hidden */
  76687. _unBindEffect(): void;
  76688. /**
  76689. * Gets a boolean indicating if this mesh has LOD
  76690. */
  76691. readonly hasLODLevels: boolean;
  76692. /**
  76693. * Gets the list of MeshLODLevel associated with the current mesh
  76694. * @returns an array of MeshLODLevel
  76695. */
  76696. getLODLevels(): MeshLODLevel[];
  76697. private _sortLODLevels;
  76698. /**
  76699. * Add a mesh as LOD level triggered at the given distance.
  76700. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76701. * @param distance The distance from the center of the object to show this level
  76702. * @param mesh The mesh to be added as LOD level (can be null)
  76703. * @return This mesh (for chaining)
  76704. */
  76705. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  76706. /**
  76707. * Returns the LOD level mesh at the passed distance or null if not found.
  76708. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76709. * @param distance The distance from the center of the object to show this level
  76710. * @returns a Mesh or `null`
  76711. */
  76712. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  76713. /**
  76714. * Remove a mesh from the LOD array
  76715. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76716. * @param mesh defines the mesh to be removed
  76717. * @return This mesh (for chaining)
  76718. */
  76719. removeLODLevel(mesh: Mesh): Mesh;
  76720. /**
  76721. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  76722. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  76723. * @param camera defines the camera to use to compute distance
  76724. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  76725. * @return This mesh (for chaining)
  76726. */
  76727. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  76728. /**
  76729. * Gets the mesh internal Geometry object
  76730. */
  76731. readonly geometry: Nullable<Geometry>;
  76732. /**
  76733. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  76734. * @returns the total number of vertices
  76735. */
  76736. getTotalVertices(): number;
  76737. /**
  76738. * Returns the content of an associated vertex buffer
  76739. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  76740. * - VertexBuffer.PositionKind
  76741. * - VertexBuffer.UVKind
  76742. * - VertexBuffer.UV2Kind
  76743. * - VertexBuffer.UV3Kind
  76744. * - VertexBuffer.UV4Kind
  76745. * - VertexBuffer.UV5Kind
  76746. * - VertexBuffer.UV6Kind
  76747. * - VertexBuffer.ColorKind
  76748. * - VertexBuffer.MatricesIndicesKind
  76749. * - VertexBuffer.MatricesIndicesExtraKind
  76750. * - VertexBuffer.MatricesWeightsKind
  76751. * - VertexBuffer.MatricesWeightsExtraKind
  76752. * @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
  76753. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  76754. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  76755. */
  76756. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  76757. /**
  76758. * Returns the mesh VertexBuffer object from the requested `kind`
  76759. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  76760. * - VertexBuffer.PositionKind
  76761. * - VertexBuffer.NormalKind
  76762. * - VertexBuffer.UVKind
  76763. * - VertexBuffer.UV2Kind
  76764. * - VertexBuffer.UV3Kind
  76765. * - VertexBuffer.UV4Kind
  76766. * - VertexBuffer.UV5Kind
  76767. * - VertexBuffer.UV6Kind
  76768. * - VertexBuffer.ColorKind
  76769. * - VertexBuffer.MatricesIndicesKind
  76770. * - VertexBuffer.MatricesIndicesExtraKind
  76771. * - VertexBuffer.MatricesWeightsKind
  76772. * - VertexBuffer.MatricesWeightsExtraKind
  76773. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  76774. */
  76775. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  76776. /**
  76777. * Tests if a specific vertex buffer is associated with this mesh
  76778. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  76779. * - VertexBuffer.PositionKind
  76780. * - VertexBuffer.NormalKind
  76781. * - VertexBuffer.UVKind
  76782. * - VertexBuffer.UV2Kind
  76783. * - VertexBuffer.UV3Kind
  76784. * - VertexBuffer.UV4Kind
  76785. * - VertexBuffer.UV5Kind
  76786. * - VertexBuffer.UV6Kind
  76787. * - VertexBuffer.ColorKind
  76788. * - VertexBuffer.MatricesIndicesKind
  76789. * - VertexBuffer.MatricesIndicesExtraKind
  76790. * - VertexBuffer.MatricesWeightsKind
  76791. * - VertexBuffer.MatricesWeightsExtraKind
  76792. * @returns a boolean
  76793. */
  76794. isVerticesDataPresent(kind: string): boolean;
  76795. /**
  76796. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  76797. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  76798. * - VertexBuffer.PositionKind
  76799. * - VertexBuffer.UVKind
  76800. * - VertexBuffer.UV2Kind
  76801. * - VertexBuffer.UV3Kind
  76802. * - VertexBuffer.UV4Kind
  76803. * - VertexBuffer.UV5Kind
  76804. * - VertexBuffer.UV6Kind
  76805. * - VertexBuffer.ColorKind
  76806. * - VertexBuffer.MatricesIndicesKind
  76807. * - VertexBuffer.MatricesIndicesExtraKind
  76808. * - VertexBuffer.MatricesWeightsKind
  76809. * - VertexBuffer.MatricesWeightsExtraKind
  76810. * @returns a boolean
  76811. */
  76812. isVertexBufferUpdatable(kind: string): boolean;
  76813. /**
  76814. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  76815. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  76816. * - VertexBuffer.PositionKind
  76817. * - VertexBuffer.NormalKind
  76818. * - VertexBuffer.UVKind
  76819. * - VertexBuffer.UV2Kind
  76820. * - VertexBuffer.UV3Kind
  76821. * - VertexBuffer.UV4Kind
  76822. * - VertexBuffer.UV5Kind
  76823. * - VertexBuffer.UV6Kind
  76824. * - VertexBuffer.ColorKind
  76825. * - VertexBuffer.MatricesIndicesKind
  76826. * - VertexBuffer.MatricesIndicesExtraKind
  76827. * - VertexBuffer.MatricesWeightsKind
  76828. * - VertexBuffer.MatricesWeightsExtraKind
  76829. * @returns an array of strings
  76830. */
  76831. getVerticesDataKinds(): string[];
  76832. /**
  76833. * Returns a positive integer : the total number of indices in this mesh geometry.
  76834. * @returns the numner of indices or zero if the mesh has no geometry.
  76835. */
  76836. getTotalIndices(): number;
  76837. /**
  76838. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  76839. * @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.
  76840. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  76841. * @returns the indices array or an empty array if the mesh has no geometry
  76842. */
  76843. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  76844. readonly isBlocked: boolean;
  76845. /**
  76846. * Determine if the current mesh is ready to be rendered
  76847. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  76848. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  76849. * @returns true if all associated assets are ready (material, textures, shaders)
  76850. */
  76851. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  76852. /**
  76853. * 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.
  76854. */
  76855. readonly areNormalsFrozen: boolean;
  76856. /**
  76857. * 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.
  76858. * @returns the current mesh
  76859. */
  76860. freezeNormals(): Mesh;
  76861. /**
  76862. * 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
  76863. * @returns the current mesh
  76864. */
  76865. unfreezeNormals(): Mesh;
  76866. /**
  76867. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  76868. */
  76869. overridenInstanceCount: number;
  76870. /** @hidden */
  76871. _preActivate(): Mesh;
  76872. /** @hidden */
  76873. _preActivateForIntermediateRendering(renderId: number): Mesh;
  76874. /** @hidden */
  76875. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  76876. /**
  76877. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  76878. * This means the mesh underlying bounding box and sphere are recomputed.
  76879. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  76880. * @returns the current mesh
  76881. */
  76882. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  76883. /** @hidden */
  76884. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  76885. /**
  76886. * This function will subdivide the mesh into multiple submeshes
  76887. * @param count defines the expected number of submeshes
  76888. */
  76889. subdivide(count: number): void;
  76890. /**
  76891. * Copy a FloatArray into a specific associated vertex buffer
  76892. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  76893. * - VertexBuffer.PositionKind
  76894. * - VertexBuffer.UVKind
  76895. * - VertexBuffer.UV2Kind
  76896. * - VertexBuffer.UV3Kind
  76897. * - VertexBuffer.UV4Kind
  76898. * - VertexBuffer.UV5Kind
  76899. * - VertexBuffer.UV6Kind
  76900. * - VertexBuffer.ColorKind
  76901. * - VertexBuffer.MatricesIndicesKind
  76902. * - VertexBuffer.MatricesIndicesExtraKind
  76903. * - VertexBuffer.MatricesWeightsKind
  76904. * - VertexBuffer.MatricesWeightsExtraKind
  76905. * @param data defines the data source
  76906. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  76907. * @param stride defines the data stride size (can be null)
  76908. * @returns the current mesh
  76909. */
  76910. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  76911. /**
  76912. * Flags an associated vertex buffer as updatable
  76913. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  76914. * - VertexBuffer.PositionKind
  76915. * - VertexBuffer.UVKind
  76916. * - VertexBuffer.UV2Kind
  76917. * - VertexBuffer.UV3Kind
  76918. * - VertexBuffer.UV4Kind
  76919. * - VertexBuffer.UV5Kind
  76920. * - VertexBuffer.UV6Kind
  76921. * - VertexBuffer.ColorKind
  76922. * - VertexBuffer.MatricesIndicesKind
  76923. * - VertexBuffer.MatricesIndicesExtraKind
  76924. * - VertexBuffer.MatricesWeightsKind
  76925. * - VertexBuffer.MatricesWeightsExtraKind
  76926. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  76927. */
  76928. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  76929. /**
  76930. * Sets the mesh global Vertex Buffer
  76931. * @param buffer defines the buffer to use
  76932. * @returns the current mesh
  76933. */
  76934. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  76935. /**
  76936. * Update a specific associated vertex buffer
  76937. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  76938. * - VertexBuffer.PositionKind
  76939. * - VertexBuffer.UVKind
  76940. * - VertexBuffer.UV2Kind
  76941. * - VertexBuffer.UV3Kind
  76942. * - VertexBuffer.UV4Kind
  76943. * - VertexBuffer.UV5Kind
  76944. * - VertexBuffer.UV6Kind
  76945. * - VertexBuffer.ColorKind
  76946. * - VertexBuffer.MatricesIndicesKind
  76947. * - VertexBuffer.MatricesIndicesExtraKind
  76948. * - VertexBuffer.MatricesWeightsKind
  76949. * - VertexBuffer.MatricesWeightsExtraKind
  76950. * @param data defines the data source
  76951. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  76952. * @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)
  76953. * @returns the current mesh
  76954. */
  76955. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  76956. /**
  76957. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  76958. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  76959. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  76960. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  76961. * @returns the current mesh
  76962. */
  76963. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  76964. /**
  76965. * Creates a un-shared specific occurence of the geometry for the mesh.
  76966. * @returns the current mesh
  76967. */
  76968. makeGeometryUnique(): Mesh;
  76969. /**
  76970. * Set the index buffer of this mesh
  76971. * @param indices defines the source data
  76972. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  76973. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  76974. * @returns the current mesh
  76975. */
  76976. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  76977. /**
  76978. * Update the current index buffer
  76979. * @param indices defines the source data
  76980. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  76981. * @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)
  76982. * @returns the current mesh
  76983. */
  76984. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  76985. /**
  76986. * Invert the geometry to move from a right handed system to a left handed one.
  76987. * @returns the current mesh
  76988. */
  76989. toLeftHanded(): Mesh;
  76990. /** @hidden */
  76991. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  76992. /** @hidden */
  76993. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  76994. /**
  76995. * Registers for this mesh a javascript function called just before the rendering process
  76996. * @param func defines the function to call before rendering this mesh
  76997. * @returns the current mesh
  76998. */
  76999. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77000. /**
  77001. * Disposes a previously registered javascript function called before the rendering
  77002. * @param func defines the function to remove
  77003. * @returns the current mesh
  77004. */
  77005. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  77006. /**
  77007. * Registers for this mesh a javascript function called just after the rendering is complete
  77008. * @param func defines the function to call after rendering this mesh
  77009. * @returns the current mesh
  77010. */
  77011. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  77012. /**
  77013. * Disposes a previously registered javascript function called after the rendering.
  77014. * @param func defines the function to remove
  77015. * @returns the current mesh
  77016. */
  77017. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  77018. /** @hidden */
  77019. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  77020. /** @hidden */
  77021. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  77022. /** @hidden */
  77023. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  77024. /** @hidden */
  77025. _rebuild(): void;
  77026. /** @hidden */
  77027. _freeze(): void;
  77028. /** @hidden */
  77029. _unFreeze(): void;
  77030. /**
  77031. * 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
  77032. * @param subMesh defines the subMesh to render
  77033. * @param enableAlphaMode defines if alpha mode can be changed
  77034. * @returns the current mesh
  77035. */
  77036. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  77037. private _onBeforeDraw;
  77038. /**
  77039. * Renormalize the mesh and patch it up if there are no weights
  77040. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  77041. * However in the case of zero weights then we set just a single influence to 1.
  77042. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  77043. */
  77044. cleanMatrixWeights(): void;
  77045. private normalizeSkinFourWeights;
  77046. private normalizeSkinWeightsAndExtra;
  77047. /**
  77048. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  77049. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  77050. * the user know there was an issue with importing the mesh
  77051. * @returns a validation object with skinned, valid and report string
  77052. */
  77053. validateSkinning(): {
  77054. skinned: boolean;
  77055. valid: boolean;
  77056. report: string;
  77057. };
  77058. /** @hidden */
  77059. _checkDelayState(): Mesh;
  77060. private _queueLoad;
  77061. /**
  77062. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  77063. * A mesh is in the frustum if its bounding box intersects the frustum
  77064. * @param frustumPlanes defines the frustum to test
  77065. * @returns true if the mesh is in the frustum planes
  77066. */
  77067. isInFrustum(frustumPlanes: Plane[]): boolean;
  77068. /**
  77069. * Sets the mesh material by the material or multiMaterial `id` property
  77070. * @param id is a string identifying the material or the multiMaterial
  77071. * @returns the current mesh
  77072. */
  77073. setMaterialByID(id: string): Mesh;
  77074. /**
  77075. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  77076. * @returns an array of IAnimatable
  77077. */
  77078. getAnimatables(): IAnimatable[];
  77079. /**
  77080. * Modifies the mesh geometry according to the passed transformation matrix.
  77081. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  77082. * The mesh normals are modified using the same transformation.
  77083. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77084. * @param transform defines the transform matrix to use
  77085. * @see http://doc.babylonjs.com/resources/baking_transformations
  77086. * @returns the current mesh
  77087. */
  77088. bakeTransformIntoVertices(transform: Matrix): Mesh;
  77089. /**
  77090. * Modifies the mesh geometry according to its own current World Matrix.
  77091. * The mesh World Matrix is then reset.
  77092. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  77093. * Note that, under the hood, this method sets a new VertexBuffer each call.
  77094. * @see http://doc.babylonjs.com/resources/baking_transformations
  77095. * @returns the current mesh
  77096. */
  77097. bakeCurrentTransformIntoVertices(): Mesh;
  77098. /** @hidden */
  77099. readonly _positions: Nullable<Vector3[]>;
  77100. /** @hidden */
  77101. _resetPointsArrayCache(): Mesh;
  77102. /** @hidden */
  77103. _generatePointsArray(): boolean;
  77104. /**
  77105. * Returns a new Mesh object generated from the current mesh properties.
  77106. * This method must not get confused with createInstance()
  77107. * @param name is a string, the name given to the new mesh
  77108. * @param newParent can be any Node object (default `null`)
  77109. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  77110. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  77111. * @returns a new mesh
  77112. */
  77113. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  77114. /**
  77115. * Releases resources associated with this mesh.
  77116. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  77117. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  77118. */
  77119. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  77120. /**
  77121. * Modifies the mesh geometry according to a displacement map.
  77122. * 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.
  77123. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77124. * @param url is a string, the URL from the image file is to be downloaded.
  77125. * @param minHeight is the lower limit of the displacement.
  77126. * @param maxHeight is the upper limit of the displacement.
  77127. * @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.
  77128. * @param uvOffset is an optional vector2 used to offset UV.
  77129. * @param uvScale is an optional vector2 used to scale UV.
  77130. * @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.
  77131. * @returns the Mesh.
  77132. */
  77133. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77134. /**
  77135. * Modifies the mesh geometry according to a displacementMap buffer.
  77136. * 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.
  77137. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  77138. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  77139. * @param heightMapWidth is the width of the buffer image.
  77140. * @param heightMapHeight is the height of the buffer image.
  77141. * @param minHeight is the lower limit of the displacement.
  77142. * @param maxHeight is the upper limit of the displacement.
  77143. * @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.
  77144. * @param uvOffset is an optional vector2 used to offset UV.
  77145. * @param uvScale is an optional vector2 used to scale UV.
  77146. * @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.
  77147. * @returns the Mesh.
  77148. */
  77149. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  77150. /**
  77151. * Modify the mesh to get a flat shading rendering.
  77152. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  77153. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  77154. * @returns current mesh
  77155. */
  77156. convertToFlatShadedMesh(): Mesh;
  77157. /**
  77158. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  77159. * In other words, more vertices, no more indices and a single bigger VBO.
  77160. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  77161. * @returns current mesh
  77162. */
  77163. convertToUnIndexedMesh(): Mesh;
  77164. /**
  77165. * Inverses facet orientations.
  77166. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77167. * @param flipNormals will also inverts the normals
  77168. * @returns current mesh
  77169. */
  77170. flipFaces(flipNormals?: boolean): Mesh;
  77171. /**
  77172. * Increase the number of facets and hence vertices in a mesh
  77173. * Vertex normals are interpolated from existing vertex normals
  77174. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77175. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  77176. */
  77177. increaseVertices(numberPerEdge: number): void;
  77178. /**
  77179. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  77180. * This will undo any application of covertToFlatShadedMesh
  77181. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  77182. */
  77183. forceSharedVertices(): void;
  77184. /** @hidden */
  77185. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  77186. /** @hidden */
  77187. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  77188. /**
  77189. * Creates a new InstancedMesh object from the mesh model.
  77190. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  77191. * @param name defines the name of the new instance
  77192. * @returns a new InstancedMesh
  77193. */
  77194. createInstance(name: string): InstancedMesh;
  77195. /**
  77196. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  77197. * After this call, all the mesh instances have the same submeshes than the current mesh.
  77198. * @returns the current mesh
  77199. */
  77200. synchronizeInstances(): Mesh;
  77201. /**
  77202. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  77203. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  77204. * This should be used together with the simplification to avoid disappearing triangles.
  77205. * @param successCallback an optional success callback to be called after the optimization finished.
  77206. * @returns the current mesh
  77207. */
  77208. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  77209. /**
  77210. * Serialize current mesh
  77211. * @param serializationObject defines the object which will receive the serialization data
  77212. */
  77213. serialize(serializationObject: any): void;
  77214. /** @hidden */
  77215. _syncGeometryWithMorphTargetManager(): void;
  77216. /** @hidden */
  77217. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  77218. /**
  77219. * Returns a new Mesh object parsed from the source provided.
  77220. * @param parsedMesh is the source
  77221. * @param scene defines the hosting scene
  77222. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  77223. * @returns a new Mesh
  77224. */
  77225. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  77226. /**
  77227. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  77228. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77229. * @param name defines the name of the mesh to create
  77230. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  77231. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  77232. * @param closePath creates a seam between the first and the last points of each path of the path array
  77233. * @param offset is taken in account only if the `pathArray` is containing a single path
  77234. * @param scene defines the hosting scene
  77235. * @param updatable defines if the mesh must be flagged as updatable
  77236. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77237. * @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)
  77238. * @returns a new Mesh
  77239. */
  77240. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77241. /**
  77242. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  77243. * @param name defines the name of the mesh to create
  77244. * @param radius sets the radius size (float) of the polygon (default 0.5)
  77245. * @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
  77246. * @param scene defines the hosting scene
  77247. * @param updatable defines if the mesh must be flagged as updatable
  77248. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77249. * @returns a new Mesh
  77250. */
  77251. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  77252. /**
  77253. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  77254. * @param name defines the name of the mesh to create
  77255. * @param size sets the size (float) of each box side (default 1)
  77256. * @param scene defines the hosting scene
  77257. * @param updatable defines if the mesh must be flagged as updatable
  77258. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77259. * @returns a new Mesh
  77260. */
  77261. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  77262. /**
  77263. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  77264. * @param name defines the name of the mesh to create
  77265. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  77266. * @param diameter sets the diameter size (float) of the sphere (default 1)
  77267. * @param scene defines the hosting scene
  77268. * @param updatable defines if the mesh must be flagged as updatable
  77269. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77270. * @returns a new Mesh
  77271. */
  77272. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77273. /**
  77274. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  77275. * @param name defines the name of the mesh to create
  77276. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  77277. * @param diameter sets the diameter size (float) of the sphere (default 1)
  77278. * @param scene defines the hosting scene
  77279. * @returns a new Mesh
  77280. */
  77281. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  77282. /**
  77283. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  77284. * @param name defines the name of the mesh to create
  77285. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  77286. * @param diameterTop set the top cap diameter (floats, default 1)
  77287. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  77288. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  77289. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  77290. * @param scene defines the hosting scene
  77291. * @param updatable defines if the mesh must be flagged as updatable
  77292. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77293. * @returns a new Mesh
  77294. */
  77295. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  77296. /**
  77297. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  77298. * @param name defines the name of the mesh to create
  77299. * @param diameter sets the diameter size (float) of the torus (default 1)
  77300. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  77301. * @param tessellation sets the number of torus sides (postive integer, default 16)
  77302. * @param scene defines the hosting scene
  77303. * @param updatable defines if the mesh must be flagged as updatable
  77304. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77305. * @returns a new Mesh
  77306. */
  77307. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77308. /**
  77309. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  77310. * @param name defines the name of the mesh to create
  77311. * @param radius sets the global radius size (float) of the torus knot (default 2)
  77312. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  77313. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  77314. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  77315. * @param p the number of windings on X axis (positive integers, default 2)
  77316. * @param q the number of windings on Y axis (positive integers, default 3)
  77317. * @param scene defines the hosting scene
  77318. * @param updatable defines if the mesh must be flagged as updatable
  77319. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77320. * @returns a new Mesh
  77321. */
  77322. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77323. /**
  77324. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  77325. * @param name defines the name of the mesh to create
  77326. * @param points is an array successive Vector3
  77327. * @param scene defines the hosting scene
  77328. * @param updatable defines if the mesh must be flagged as updatable
  77329. * @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).
  77330. * @returns a new Mesh
  77331. */
  77332. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  77333. /**
  77334. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  77335. * @param name defines the name of the mesh to create
  77336. * @param points is an array successive Vector3
  77337. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  77338. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  77339. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  77340. * @param scene defines the hosting scene
  77341. * @param updatable defines if the mesh must be flagged as updatable
  77342. * @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)
  77343. * @returns a new Mesh
  77344. */
  77345. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  77346. /**
  77347. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  77348. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  77349. * 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.
  77350. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77351. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77352. * Remember you can only change the shape positions, not their number when updating a polygon.
  77353. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  77354. * @param name defines the name of the mesh to create
  77355. * @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
  77356. * @param scene defines the hosting scene
  77357. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  77358. * @param updatable defines if the mesh must be flagged as updatable
  77359. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77360. * @param earcutInjection can be used to inject your own earcut reference
  77361. * @returns a new Mesh
  77362. */
  77363. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  77364. /**
  77365. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  77366. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  77367. * @param name defines the name of the mesh to create
  77368. * @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
  77369. * @param depth defines the height of extrusion
  77370. * @param scene defines the hosting scene
  77371. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  77372. * @param updatable defines if the mesh must be flagged as updatable
  77373. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77374. * @param earcutInjection can be used to inject your own earcut reference
  77375. * @returns a new Mesh
  77376. */
  77377. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  77378. /**
  77379. * Creates an extruded shape mesh.
  77380. * 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
  77381. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77382. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77383. * @param name defines the name of the mesh to create
  77384. * @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
  77385. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  77386. * @param scale is the value to scale the shape
  77387. * @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
  77388. * @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
  77389. * @param scene defines the hosting scene
  77390. * @param updatable defines if the mesh must be flagged as updatable
  77391. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77392. * @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)
  77393. * @returns a new Mesh
  77394. */
  77395. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77396. /**
  77397. * Creates an custom extruded shape mesh.
  77398. * The custom extrusion is a parametric shape.
  77399. * It has no predefined shape. Its final shape will depend on the input parameters.
  77400. * Please consider using the same method from the MeshBuilder class instead
  77401. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77402. * @param name defines the name of the mesh to create
  77403. * @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
  77404. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  77405. * @param scaleFunction is a custom Javascript function called on each path point
  77406. * @param rotationFunction is a custom Javascript function called on each path point
  77407. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  77408. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  77409. * @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
  77410. * @param scene defines the hosting scene
  77411. * @param updatable defines if the mesh must be flagged as updatable
  77412. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77413. * @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)
  77414. * @returns a new Mesh
  77415. */
  77416. 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;
  77417. /**
  77418. * Creates lathe mesh.
  77419. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  77420. * Please consider using the same method from the MeshBuilder class instead
  77421. * @param name defines the name of the mesh to create
  77422. * @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
  77423. * @param radius is the radius value of the lathe
  77424. * @param tessellation is the side number of the lathe.
  77425. * @param scene defines the hosting scene
  77426. * @param updatable defines if the mesh must be flagged as updatable
  77427. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77428. * @returns a new Mesh
  77429. */
  77430. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77431. /**
  77432. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  77433. * @param name defines the name of the mesh to create
  77434. * @param size sets the size (float) of both sides of the plane at once (default 1)
  77435. * @param scene defines the hosting scene
  77436. * @param updatable defines if the mesh must be flagged as updatable
  77437. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77438. * @returns a new Mesh
  77439. */
  77440. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  77441. /**
  77442. * Creates a ground mesh.
  77443. * Please consider using the same method from the MeshBuilder class instead
  77444. * @param name defines the name of the mesh to create
  77445. * @param width set the width of the ground
  77446. * @param height set the height of the ground
  77447. * @param subdivisions sets the number of subdivisions per side
  77448. * @param scene defines the hosting scene
  77449. * @param updatable defines if the mesh must be flagged as updatable
  77450. * @returns a new Mesh
  77451. */
  77452. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  77453. /**
  77454. * Creates a tiled ground mesh.
  77455. * Please consider using the same method from the MeshBuilder class instead
  77456. * @param name defines the name of the mesh to create
  77457. * @param xmin set the ground minimum X coordinate
  77458. * @param zmin set the ground minimum Y coordinate
  77459. * @param xmax set the ground maximum X coordinate
  77460. * @param zmax set the ground maximum Z coordinate
  77461. * @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
  77462. * @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
  77463. * @param scene defines the hosting scene
  77464. * @param updatable defines if the mesh must be flagged as updatable
  77465. * @returns a new Mesh
  77466. */
  77467. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  77468. w: number;
  77469. h: number;
  77470. }, precision: {
  77471. w: number;
  77472. h: number;
  77473. }, scene: Scene, updatable?: boolean): Mesh;
  77474. /**
  77475. * Creates a ground mesh from a height map.
  77476. * Please consider using the same method from the MeshBuilder class instead
  77477. * @see http://doc.babylonjs.com/babylon101/height_map
  77478. * @param name defines the name of the mesh to create
  77479. * @param url sets the URL of the height map image resource
  77480. * @param width set the ground width size
  77481. * @param height set the ground height size
  77482. * @param subdivisions sets the number of subdivision per side
  77483. * @param minHeight is the minimum altitude on the ground
  77484. * @param maxHeight is the maximum altitude on the ground
  77485. * @param scene defines the hosting scene
  77486. * @param updatable defines if the mesh must be flagged as updatable
  77487. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  77488. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  77489. * @returns a new Mesh
  77490. */
  77491. 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;
  77492. /**
  77493. * Creates a tube mesh.
  77494. * The tube is a parametric shape.
  77495. * It has no predefined shape. Its final shape will depend on the input parameters.
  77496. * Please consider using the same method from the MeshBuilder class instead
  77497. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  77498. * @param name defines the name of the mesh to create
  77499. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  77500. * @param radius sets the tube radius size
  77501. * @param tessellation is the number of sides on the tubular surface
  77502. * @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
  77503. * @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
  77504. * @param scene defines the hosting scene
  77505. * @param updatable defines if the mesh must be flagged as updatable
  77506. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  77507. * @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)
  77508. * @returns a new Mesh
  77509. */
  77510. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  77511. (i: number, distance: number): number;
  77512. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  77513. /**
  77514. * Creates a polyhedron mesh.
  77515. * Please consider using the same method from the MeshBuilder class instead.
  77516. * * 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
  77517. * * The parameter `size` (positive float, default 1) sets the polygon size
  77518. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  77519. * * 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`
  77520. * * 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
  77521. * * 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)`)
  77522. * * 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
  77523. * * 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
  77524. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77525. * * If you create a double-sided mesh, you can choose what parts of 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
  77526. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77527. * @param name defines the name of the mesh to create
  77528. * @param options defines the options used to create the mesh
  77529. * @param scene defines the hosting scene
  77530. * @returns a new Mesh
  77531. */
  77532. static CreatePolyhedron(name: string, options: {
  77533. type?: number;
  77534. size?: number;
  77535. sizeX?: number;
  77536. sizeY?: number;
  77537. sizeZ?: number;
  77538. custom?: any;
  77539. faceUV?: Vector4[];
  77540. faceColors?: Color4[];
  77541. updatable?: boolean;
  77542. sideOrientation?: number;
  77543. }, scene: Scene): Mesh;
  77544. /**
  77545. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  77546. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  77547. * * 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`)
  77548. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  77549. * * 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
  77550. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77551. * * If you create a double-sided mesh, you can choose what parts of 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
  77552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77553. * @param name defines the name of the mesh
  77554. * @param options defines the options used to create the mesh
  77555. * @param scene defines the hosting scene
  77556. * @returns a new Mesh
  77557. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  77558. */
  77559. static CreateIcoSphere(name: string, options: {
  77560. radius?: number;
  77561. flat?: boolean;
  77562. subdivisions?: number;
  77563. sideOrientation?: number;
  77564. updatable?: boolean;
  77565. }, scene: Scene): Mesh;
  77566. /**
  77567. * Creates a decal mesh.
  77568. * Please consider using the same method from the MeshBuilder class instead.
  77569. * A decal is a mesh usually applied as a model onto the surface of another mesh
  77570. * @param name defines the name of the mesh
  77571. * @param sourceMesh defines the mesh receiving the decal
  77572. * @param position sets the position of the decal in world coordinates
  77573. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  77574. * @param size sets the decal scaling
  77575. * @param angle sets the angle to rotate the decal
  77576. * @returns a new Mesh
  77577. */
  77578. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  77579. /**
  77580. * Prepare internal position array for software CPU skinning
  77581. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  77582. */
  77583. setPositionsForCPUSkinning(): Float32Array;
  77584. /**
  77585. * Prepare internal normal array for software CPU skinning
  77586. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  77587. */
  77588. setNormalsForCPUSkinning(): Float32Array;
  77589. /**
  77590. * Updates the vertex buffer by applying transformation from the bones
  77591. * @param skeleton defines the skeleton to apply to current mesh
  77592. * @returns the current mesh
  77593. */
  77594. applySkeleton(skeleton: Skeleton): Mesh;
  77595. /**
  77596. * 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
  77597. * @param meshes defines the list of meshes to scan
  77598. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  77599. */
  77600. static MinMax(meshes: AbstractMesh[]): {
  77601. min: Vector3;
  77602. max: Vector3;
  77603. };
  77604. /**
  77605. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  77606. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  77607. * @returns a vector3
  77608. */
  77609. static Center(meshesOrMinMaxVector: {
  77610. min: Vector3;
  77611. max: Vector3;
  77612. } | AbstractMesh[]): Vector3;
  77613. /**
  77614. * Merge the array of meshes into a single mesh for performance reasons.
  77615. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  77616. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  77617. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  77618. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  77619. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  77620. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  77621. * @returns a new mesh
  77622. */
  77623. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  77624. /** @hidden */
  77625. addInstance(instance: InstancedMesh): void;
  77626. /** @hidden */
  77627. removeInstance(instance: InstancedMesh): void;
  77628. }
  77629. }
  77630. declare module BABYLON {
  77631. /**
  77632. * Interface used to define Action
  77633. */
  77634. export interface IAction {
  77635. /**
  77636. * Trigger for the action
  77637. */
  77638. trigger: number;
  77639. /** Options of the trigger */
  77640. triggerOptions: any;
  77641. /**
  77642. * Gets the trigger parameters
  77643. * @returns the trigger parameters
  77644. */
  77645. getTriggerParameter(): any;
  77646. /**
  77647. * Internal only - executes current action event
  77648. * @hidden
  77649. */
  77650. _executeCurrent(evt?: ActionEvent): void;
  77651. /**
  77652. * Serialize placeholder for child classes
  77653. * @param parent of child
  77654. * @returns the serialized object
  77655. */
  77656. serialize(parent: any): any;
  77657. /**
  77658. * Internal only
  77659. * @hidden
  77660. */
  77661. _prepare(): void;
  77662. /**
  77663. * Internal only - manager for action
  77664. * @hidden
  77665. */
  77666. _actionManager: AbstractActionManager;
  77667. /**
  77668. * Adds action to chain of actions, may be a DoNothingAction
  77669. * @param action defines the next action to execute
  77670. * @returns The action passed in
  77671. * @see https://www.babylonjs-playground.com/#1T30HR#0
  77672. */
  77673. then(action: IAction): IAction;
  77674. }
  77675. /**
  77676. * The action to be carried out following a trigger
  77677. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  77678. */
  77679. export class Action implements IAction {
  77680. /** the trigger, with or without parameters, for the action */
  77681. triggerOptions: any;
  77682. /**
  77683. * Trigger for the action
  77684. */
  77685. trigger: number;
  77686. /**
  77687. * Internal only - manager for action
  77688. * @hidden
  77689. */
  77690. _actionManager: ActionManager;
  77691. private _nextActiveAction;
  77692. private _child;
  77693. private _condition?;
  77694. private _triggerParameter;
  77695. /**
  77696. * An event triggered prior to action being executed.
  77697. */
  77698. onBeforeExecuteObservable: Observable<Action>;
  77699. /**
  77700. * Creates a new Action
  77701. * @param triggerOptions the trigger, with or without parameters, for the action
  77702. * @param condition an optional determinant of action
  77703. */
  77704. constructor(
  77705. /** the trigger, with or without parameters, for the action */
  77706. triggerOptions: any, condition?: Condition);
  77707. /**
  77708. * Internal only
  77709. * @hidden
  77710. */
  77711. _prepare(): void;
  77712. /**
  77713. * Gets the trigger parameters
  77714. * @returns the trigger parameters
  77715. */
  77716. getTriggerParameter(): any;
  77717. /**
  77718. * Internal only - executes current action event
  77719. * @hidden
  77720. */
  77721. _executeCurrent(evt?: ActionEvent): void;
  77722. /**
  77723. * Execute placeholder for child classes
  77724. * @param evt optional action event
  77725. */
  77726. execute(evt?: ActionEvent): void;
  77727. /**
  77728. * Skips to next active action
  77729. */
  77730. skipToNextActiveAction(): void;
  77731. /**
  77732. * Adds action to chain of actions, may be a DoNothingAction
  77733. * @param action defines the next action to execute
  77734. * @returns The action passed in
  77735. * @see https://www.babylonjs-playground.com/#1T30HR#0
  77736. */
  77737. then(action: Action): Action;
  77738. /**
  77739. * Internal only
  77740. * @hidden
  77741. */
  77742. _getProperty(propertyPath: string): string;
  77743. /**
  77744. * Internal only
  77745. * @hidden
  77746. */
  77747. _getEffectiveTarget(target: any, propertyPath: string): any;
  77748. /**
  77749. * Serialize placeholder for child classes
  77750. * @param parent of child
  77751. * @returns the serialized object
  77752. */
  77753. serialize(parent: any): any;
  77754. /**
  77755. * Internal only called by serialize
  77756. * @hidden
  77757. */
  77758. protected _serialize(serializedAction: any, parent?: any): any;
  77759. /**
  77760. * Internal only
  77761. * @hidden
  77762. */
  77763. static _SerializeValueAsString: (value: any) => string;
  77764. /**
  77765. * Internal only
  77766. * @hidden
  77767. */
  77768. static _GetTargetProperty: (target: Scene | Node) => {
  77769. name: string;
  77770. targetType: string;
  77771. value: string;
  77772. };
  77773. }
  77774. }
  77775. declare module BABYLON {
  77776. /**
  77777. * A Condition applied to an Action
  77778. */
  77779. export class Condition {
  77780. /**
  77781. * Internal only - manager for action
  77782. * @hidden
  77783. */
  77784. _actionManager: ActionManager;
  77785. /**
  77786. * Internal only
  77787. * @hidden
  77788. */
  77789. _evaluationId: number;
  77790. /**
  77791. * Internal only
  77792. * @hidden
  77793. */
  77794. _currentResult: boolean;
  77795. /**
  77796. * Creates a new Condition
  77797. * @param actionManager the manager of the action the condition is applied to
  77798. */
  77799. constructor(actionManager: ActionManager);
  77800. /**
  77801. * Check if the current condition is valid
  77802. * @returns a boolean
  77803. */
  77804. isValid(): boolean;
  77805. /**
  77806. * Internal only
  77807. * @hidden
  77808. */
  77809. _getProperty(propertyPath: string): string;
  77810. /**
  77811. * Internal only
  77812. * @hidden
  77813. */
  77814. _getEffectiveTarget(target: any, propertyPath: string): any;
  77815. /**
  77816. * Serialize placeholder for child classes
  77817. * @returns the serialized object
  77818. */
  77819. serialize(): any;
  77820. /**
  77821. * Internal only
  77822. * @hidden
  77823. */
  77824. protected _serialize(serializedCondition: any): any;
  77825. }
  77826. /**
  77827. * Defines specific conditional operators as extensions of Condition
  77828. */
  77829. export class ValueCondition extends Condition {
  77830. /** path to specify the property of the target the conditional operator uses */
  77831. propertyPath: string;
  77832. /** the value compared by the conditional operator against the current value of the property */
  77833. value: any;
  77834. /** the conditional operator, default ValueCondition.IsEqual */
  77835. operator: number;
  77836. /**
  77837. * Internal only
  77838. * @hidden
  77839. */
  77840. private static _IsEqual;
  77841. /**
  77842. * Internal only
  77843. * @hidden
  77844. */
  77845. private static _IsDifferent;
  77846. /**
  77847. * Internal only
  77848. * @hidden
  77849. */
  77850. private static _IsGreater;
  77851. /**
  77852. * Internal only
  77853. * @hidden
  77854. */
  77855. private static _IsLesser;
  77856. /**
  77857. * returns the number for IsEqual
  77858. */
  77859. static readonly IsEqual: number;
  77860. /**
  77861. * Returns the number for IsDifferent
  77862. */
  77863. static readonly IsDifferent: number;
  77864. /**
  77865. * Returns the number for IsGreater
  77866. */
  77867. static readonly IsGreater: number;
  77868. /**
  77869. * Returns the number for IsLesser
  77870. */
  77871. static readonly IsLesser: number;
  77872. /**
  77873. * Internal only The action manager for the condition
  77874. * @hidden
  77875. */
  77876. _actionManager: ActionManager;
  77877. /**
  77878. * Internal only
  77879. * @hidden
  77880. */
  77881. private _target;
  77882. /**
  77883. * Internal only
  77884. * @hidden
  77885. */
  77886. private _effectiveTarget;
  77887. /**
  77888. * Internal only
  77889. * @hidden
  77890. */
  77891. private _property;
  77892. /**
  77893. * Creates a new ValueCondition
  77894. * @param actionManager manager for the action the condition applies to
  77895. * @param target for the action
  77896. * @param propertyPath path to specify the property of the target the conditional operator uses
  77897. * @param value the value compared by the conditional operator against the current value of the property
  77898. * @param operator the conditional operator, default ValueCondition.IsEqual
  77899. */
  77900. constructor(actionManager: ActionManager, target: any,
  77901. /** path to specify the property of the target the conditional operator uses */
  77902. propertyPath: string,
  77903. /** the value compared by the conditional operator against the current value of the property */
  77904. value: any,
  77905. /** the conditional operator, default ValueCondition.IsEqual */
  77906. operator?: number);
  77907. /**
  77908. * Compares the given value with the property value for the specified conditional operator
  77909. * @returns the result of the comparison
  77910. */
  77911. isValid(): boolean;
  77912. /**
  77913. * Serialize the ValueCondition into a JSON compatible object
  77914. * @returns serialization object
  77915. */
  77916. serialize(): any;
  77917. /**
  77918. * Gets the name of the conditional operator for the ValueCondition
  77919. * @param operator the conditional operator
  77920. * @returns the name
  77921. */
  77922. static GetOperatorName(operator: number): string;
  77923. }
  77924. /**
  77925. * Defines a predicate condition as an extension of Condition
  77926. */
  77927. export class PredicateCondition extends Condition {
  77928. /** defines the predicate function used to validate the condition */
  77929. predicate: () => boolean;
  77930. /**
  77931. * Internal only - manager for action
  77932. * @hidden
  77933. */
  77934. _actionManager: ActionManager;
  77935. /**
  77936. * Creates a new PredicateCondition
  77937. * @param actionManager manager for the action the condition applies to
  77938. * @param predicate defines the predicate function used to validate the condition
  77939. */
  77940. constructor(actionManager: ActionManager,
  77941. /** defines the predicate function used to validate the condition */
  77942. predicate: () => boolean);
  77943. /**
  77944. * @returns the validity of the predicate condition
  77945. */
  77946. isValid(): boolean;
  77947. }
  77948. /**
  77949. * Defines a state condition as an extension of Condition
  77950. */
  77951. export class StateCondition extends Condition {
  77952. /** Value to compare with target state */
  77953. value: string;
  77954. /**
  77955. * Internal only - manager for action
  77956. * @hidden
  77957. */
  77958. _actionManager: ActionManager;
  77959. /**
  77960. * Internal only
  77961. * @hidden
  77962. */
  77963. private _target;
  77964. /**
  77965. * Creates a new StateCondition
  77966. * @param actionManager manager for the action the condition applies to
  77967. * @param target of the condition
  77968. * @param value to compare with target state
  77969. */
  77970. constructor(actionManager: ActionManager, target: any,
  77971. /** Value to compare with target state */
  77972. value: string);
  77973. /**
  77974. * Gets a boolean indicating if the current condition is met
  77975. * @returns the validity of the state
  77976. */
  77977. isValid(): boolean;
  77978. /**
  77979. * Serialize the StateCondition into a JSON compatible object
  77980. * @returns serialization object
  77981. */
  77982. serialize(): any;
  77983. }
  77984. }
  77985. declare module BABYLON {
  77986. /**
  77987. * This defines an action responsible to toggle a boolean once triggered.
  77988. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77989. */
  77990. export class SwitchBooleanAction extends Action {
  77991. /**
  77992. * The path to the boolean property in the target object
  77993. */
  77994. propertyPath: string;
  77995. private _target;
  77996. private _effectiveTarget;
  77997. private _property;
  77998. /**
  77999. * Instantiate the action
  78000. * @param triggerOptions defines the trigger options
  78001. * @param target defines the object containing the boolean
  78002. * @param propertyPath defines the path to the boolean property in the target object
  78003. * @param condition defines the trigger related conditions
  78004. */
  78005. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  78006. /** @hidden */
  78007. _prepare(): void;
  78008. /**
  78009. * Execute the action toggle the boolean value.
  78010. */
  78011. execute(): void;
  78012. /**
  78013. * Serializes the actions and its related information.
  78014. * @param parent defines the object to serialize in
  78015. * @returns the serialized object
  78016. */
  78017. serialize(parent: any): any;
  78018. }
  78019. /**
  78020. * This defines an action responsible to set a the state field of the target
  78021. * to a desired value once triggered.
  78022. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78023. */
  78024. export class SetStateAction extends Action {
  78025. /**
  78026. * The value to store in the state field.
  78027. */
  78028. value: string;
  78029. private _target;
  78030. /**
  78031. * Instantiate the action
  78032. * @param triggerOptions defines the trigger options
  78033. * @param target defines the object containing the state property
  78034. * @param value defines the value to store in the state field
  78035. * @param condition defines the trigger related conditions
  78036. */
  78037. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  78038. /**
  78039. * Execute the action and store the value on the target state property.
  78040. */
  78041. execute(): void;
  78042. /**
  78043. * Serializes the actions and its related information.
  78044. * @param parent defines the object to serialize in
  78045. * @returns the serialized object
  78046. */
  78047. serialize(parent: any): any;
  78048. }
  78049. /**
  78050. * This defines an action responsible to set a property of the target
  78051. * to a desired value once triggered.
  78052. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78053. */
  78054. export class SetValueAction extends Action {
  78055. /**
  78056. * The path of the property to set in the target.
  78057. */
  78058. propertyPath: string;
  78059. /**
  78060. * The value to set in the property
  78061. */
  78062. value: any;
  78063. private _target;
  78064. private _effectiveTarget;
  78065. private _property;
  78066. /**
  78067. * Instantiate the action
  78068. * @param triggerOptions defines the trigger options
  78069. * @param target defines the object containing the property
  78070. * @param propertyPath defines the path of the property to set in the target
  78071. * @param value defines the value to set in the property
  78072. * @param condition defines the trigger related conditions
  78073. */
  78074. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78075. /** @hidden */
  78076. _prepare(): void;
  78077. /**
  78078. * Execute the action and set the targetted property to the desired value.
  78079. */
  78080. execute(): void;
  78081. /**
  78082. * Serializes the actions and its related information.
  78083. * @param parent defines the object to serialize in
  78084. * @returns the serialized object
  78085. */
  78086. serialize(parent: any): any;
  78087. }
  78088. /**
  78089. * This defines an action responsible to increment the target value
  78090. * to a desired value once triggered.
  78091. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78092. */
  78093. export class IncrementValueAction extends Action {
  78094. /**
  78095. * The path of the property to increment in the target.
  78096. */
  78097. propertyPath: string;
  78098. /**
  78099. * The value we should increment the property by.
  78100. */
  78101. value: any;
  78102. private _target;
  78103. private _effectiveTarget;
  78104. private _property;
  78105. /**
  78106. * Instantiate the action
  78107. * @param triggerOptions defines the trigger options
  78108. * @param target defines the object containing the property
  78109. * @param propertyPath defines the path of the property to increment in the target
  78110. * @param value defines the value value we should increment the property by
  78111. * @param condition defines the trigger related conditions
  78112. */
  78113. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  78114. /** @hidden */
  78115. _prepare(): void;
  78116. /**
  78117. * Execute the action and increment the target of the value amount.
  78118. */
  78119. execute(): void;
  78120. /**
  78121. * Serializes the actions and its related information.
  78122. * @param parent defines the object to serialize in
  78123. * @returns the serialized object
  78124. */
  78125. serialize(parent: any): any;
  78126. }
  78127. /**
  78128. * This defines an action responsible to start an animation once triggered.
  78129. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78130. */
  78131. export class PlayAnimationAction extends Action {
  78132. /**
  78133. * Where the animation should start (animation frame)
  78134. */
  78135. from: number;
  78136. /**
  78137. * Where the animation should stop (animation frame)
  78138. */
  78139. to: number;
  78140. /**
  78141. * Define if the animation should loop or stop after the first play.
  78142. */
  78143. loop?: boolean;
  78144. private _target;
  78145. /**
  78146. * Instantiate the action
  78147. * @param triggerOptions defines the trigger options
  78148. * @param target defines the target animation or animation name
  78149. * @param from defines from where the animation should start (animation frame)
  78150. * @param end defines where the animation should stop (animation frame)
  78151. * @param loop defines if the animation should loop or stop after the first play
  78152. * @param condition defines the trigger related conditions
  78153. */
  78154. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  78155. /** @hidden */
  78156. _prepare(): void;
  78157. /**
  78158. * Execute the action and play the animation.
  78159. */
  78160. execute(): void;
  78161. /**
  78162. * Serializes the actions and its related information.
  78163. * @param parent defines the object to serialize in
  78164. * @returns the serialized object
  78165. */
  78166. serialize(parent: any): any;
  78167. }
  78168. /**
  78169. * This defines an action responsible to stop an animation once triggered.
  78170. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78171. */
  78172. export class StopAnimationAction extends Action {
  78173. private _target;
  78174. /**
  78175. * Instantiate the action
  78176. * @param triggerOptions defines the trigger options
  78177. * @param target defines the target animation or animation name
  78178. * @param condition defines the trigger related conditions
  78179. */
  78180. constructor(triggerOptions: any, target: any, condition?: Condition);
  78181. /** @hidden */
  78182. _prepare(): void;
  78183. /**
  78184. * Execute the action and stop the animation.
  78185. */
  78186. execute(): void;
  78187. /**
  78188. * Serializes the actions and its related information.
  78189. * @param parent defines the object to serialize in
  78190. * @returns the serialized object
  78191. */
  78192. serialize(parent: any): any;
  78193. }
  78194. /**
  78195. * This defines an action responsible that does nothing once triggered.
  78196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78197. */
  78198. export class DoNothingAction extends Action {
  78199. /**
  78200. * Instantiate the action
  78201. * @param triggerOptions defines the trigger options
  78202. * @param condition defines the trigger related conditions
  78203. */
  78204. constructor(triggerOptions?: any, condition?: Condition);
  78205. /**
  78206. * Execute the action and do nothing.
  78207. */
  78208. execute(): void;
  78209. /**
  78210. * Serializes the actions and its related information.
  78211. * @param parent defines the object to serialize in
  78212. * @returns the serialized object
  78213. */
  78214. serialize(parent: any): any;
  78215. }
  78216. /**
  78217. * This defines an action responsible to trigger several actions once triggered.
  78218. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78219. */
  78220. export class CombineAction extends Action {
  78221. /**
  78222. * The list of aggregated animations to run.
  78223. */
  78224. children: Action[];
  78225. /**
  78226. * Instantiate the action
  78227. * @param triggerOptions defines the trigger options
  78228. * @param children defines the list of aggregated animations to run
  78229. * @param condition defines the trigger related conditions
  78230. */
  78231. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  78232. /** @hidden */
  78233. _prepare(): void;
  78234. /**
  78235. * Execute the action and executes all the aggregated actions.
  78236. */
  78237. execute(evt: ActionEvent): void;
  78238. /**
  78239. * Serializes the actions and its related information.
  78240. * @param parent defines the object to serialize in
  78241. * @returns the serialized object
  78242. */
  78243. serialize(parent: any): any;
  78244. }
  78245. /**
  78246. * This defines an action responsible to run code (external event) once triggered.
  78247. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78248. */
  78249. export class ExecuteCodeAction extends Action {
  78250. /**
  78251. * The callback function to run.
  78252. */
  78253. func: (evt: ActionEvent) => void;
  78254. /**
  78255. * Instantiate the action
  78256. * @param triggerOptions defines the trigger options
  78257. * @param func defines the callback function to run
  78258. * @param condition defines the trigger related conditions
  78259. */
  78260. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  78261. /**
  78262. * Execute the action and run the attached code.
  78263. */
  78264. execute(evt: ActionEvent): void;
  78265. }
  78266. /**
  78267. * This defines an action responsible to set the parent property of the target once triggered.
  78268. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78269. */
  78270. export class SetParentAction extends Action {
  78271. private _parent;
  78272. private _target;
  78273. /**
  78274. * Instantiate the action
  78275. * @param triggerOptions defines the trigger options
  78276. * @param target defines the target containing the parent property
  78277. * @param parent defines from where the animation should start (animation frame)
  78278. * @param condition defines the trigger related conditions
  78279. */
  78280. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  78281. /** @hidden */
  78282. _prepare(): void;
  78283. /**
  78284. * Execute the action and set the parent property.
  78285. */
  78286. execute(): void;
  78287. /**
  78288. * Serializes the actions and its related information.
  78289. * @param parent defines the object to serialize in
  78290. * @returns the serialized object
  78291. */
  78292. serialize(parent: any): any;
  78293. }
  78294. }
  78295. declare module BABYLON {
  78296. /**
  78297. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  78298. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  78299. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78300. */
  78301. export class ActionManager extends AbstractActionManager {
  78302. /**
  78303. * Nothing
  78304. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78305. */
  78306. static readonly NothingTrigger: number;
  78307. /**
  78308. * On pick
  78309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78310. */
  78311. static readonly OnPickTrigger: number;
  78312. /**
  78313. * On left pick
  78314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78315. */
  78316. static readonly OnLeftPickTrigger: number;
  78317. /**
  78318. * On right pick
  78319. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78320. */
  78321. static readonly OnRightPickTrigger: number;
  78322. /**
  78323. * On center pick
  78324. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78325. */
  78326. static readonly OnCenterPickTrigger: number;
  78327. /**
  78328. * On pick down
  78329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78330. */
  78331. static readonly OnPickDownTrigger: number;
  78332. /**
  78333. * On double pick
  78334. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78335. */
  78336. static readonly OnDoublePickTrigger: number;
  78337. /**
  78338. * On pick up
  78339. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78340. */
  78341. static readonly OnPickUpTrigger: number;
  78342. /**
  78343. * On pick out.
  78344. * This trigger will only be raised if you also declared a OnPickDown
  78345. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78346. */
  78347. static readonly OnPickOutTrigger: number;
  78348. /**
  78349. * On long press
  78350. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78351. */
  78352. static readonly OnLongPressTrigger: number;
  78353. /**
  78354. * On pointer over
  78355. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78356. */
  78357. static readonly OnPointerOverTrigger: number;
  78358. /**
  78359. * On pointer out
  78360. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78361. */
  78362. static readonly OnPointerOutTrigger: number;
  78363. /**
  78364. * On every frame
  78365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78366. */
  78367. static readonly OnEveryFrameTrigger: number;
  78368. /**
  78369. * On intersection enter
  78370. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78371. */
  78372. static readonly OnIntersectionEnterTrigger: number;
  78373. /**
  78374. * On intersection exit
  78375. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78376. */
  78377. static readonly OnIntersectionExitTrigger: number;
  78378. /**
  78379. * On key down
  78380. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78381. */
  78382. static readonly OnKeyDownTrigger: number;
  78383. /**
  78384. * On key up
  78385. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  78386. */
  78387. static readonly OnKeyUpTrigger: number;
  78388. private _scene;
  78389. /**
  78390. * Creates a new action manager
  78391. * @param scene defines the hosting scene
  78392. */
  78393. constructor(scene: Scene);
  78394. /**
  78395. * Releases all associated resources
  78396. */
  78397. dispose(): void;
  78398. /**
  78399. * Gets hosting scene
  78400. * @returns the hosting scene
  78401. */
  78402. getScene(): Scene;
  78403. /**
  78404. * Does this action manager handles actions of any of the given triggers
  78405. * @param triggers defines the triggers to be tested
  78406. * @return a boolean indicating whether one (or more) of the triggers is handled
  78407. */
  78408. hasSpecificTriggers(triggers: number[]): boolean;
  78409. /**
  78410. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  78411. * speed.
  78412. * @param triggerA defines the trigger to be tested
  78413. * @param triggerB defines the trigger to be tested
  78414. * @return a boolean indicating whether one (or more) of the triggers is handled
  78415. */
  78416. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  78417. /**
  78418. * Does this action manager handles actions of a given trigger
  78419. * @param trigger defines the trigger to be tested
  78420. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  78421. * @return whether the trigger is handled
  78422. */
  78423. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  78424. /**
  78425. * Does this action manager has pointer triggers
  78426. */
  78427. readonly hasPointerTriggers: boolean;
  78428. /**
  78429. * Does this action manager has pick triggers
  78430. */
  78431. readonly hasPickTriggers: boolean;
  78432. /**
  78433. * Registers an action to this action manager
  78434. * @param action defines the action to be registered
  78435. * @return the action amended (prepared) after registration
  78436. */
  78437. registerAction(action: IAction): Nullable<IAction>;
  78438. /**
  78439. * Unregisters an action to this action manager
  78440. * @param action defines the action to be unregistered
  78441. * @return a boolean indicating whether the action has been unregistered
  78442. */
  78443. unregisterAction(action: IAction): Boolean;
  78444. /**
  78445. * Process a specific trigger
  78446. * @param trigger defines the trigger to process
  78447. * @param evt defines the event details to be processed
  78448. */
  78449. processTrigger(trigger: number, evt?: IActionEvent): void;
  78450. /** @hidden */
  78451. _getEffectiveTarget(target: any, propertyPath: string): any;
  78452. /** @hidden */
  78453. _getProperty(propertyPath: string): string;
  78454. /**
  78455. * Serialize this manager to a JSON object
  78456. * @param name defines the property name to store this manager
  78457. * @returns a JSON representation of this manager
  78458. */
  78459. serialize(name: string): any;
  78460. /**
  78461. * Creates a new ActionManager from a JSON data
  78462. * @param parsedActions defines the JSON data to read from
  78463. * @param object defines the hosting mesh
  78464. * @param scene defines the hosting scene
  78465. */
  78466. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  78467. /**
  78468. * Get a trigger name by index
  78469. * @param trigger defines the trigger index
  78470. * @returns a trigger name
  78471. */
  78472. static GetTriggerName(trigger: number): string;
  78473. }
  78474. }
  78475. declare module BABYLON {
  78476. /**
  78477. * Class representing a ray with position and direction
  78478. */
  78479. export class Ray {
  78480. /** origin point */
  78481. origin: Vector3;
  78482. /** direction */
  78483. direction: Vector3;
  78484. /** length of the ray */
  78485. length: number;
  78486. private static readonly TmpVector3;
  78487. private _tmpRay;
  78488. /**
  78489. * Creates a new ray
  78490. * @param origin origin point
  78491. * @param direction direction
  78492. * @param length length of the ray
  78493. */
  78494. constructor(
  78495. /** origin point */
  78496. origin: Vector3,
  78497. /** direction */
  78498. direction: Vector3,
  78499. /** length of the ray */
  78500. length?: number);
  78501. /**
  78502. * Checks if the ray intersects a box
  78503. * @param minimum bound of the box
  78504. * @param maximum bound of the box
  78505. * @param intersectionTreshold extra extend to be added to the box in all direction
  78506. * @returns if the box was hit
  78507. */
  78508. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  78509. /**
  78510. * Checks if the ray intersects a box
  78511. * @param box the bounding box to check
  78512. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  78513. * @returns if the box was hit
  78514. */
  78515. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  78516. /**
  78517. * If the ray hits a sphere
  78518. * @param sphere the bounding sphere to check
  78519. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  78520. * @returns true if it hits the sphere
  78521. */
  78522. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  78523. /**
  78524. * If the ray hits a triange
  78525. * @param vertex0 triangle vertex
  78526. * @param vertex1 triangle vertex
  78527. * @param vertex2 triangle vertex
  78528. * @returns intersection information if hit
  78529. */
  78530. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  78531. /**
  78532. * Checks if ray intersects a plane
  78533. * @param plane the plane to check
  78534. * @returns the distance away it was hit
  78535. */
  78536. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  78537. /**
  78538. * Checks if ray intersects a mesh
  78539. * @param mesh the mesh to check
  78540. * @param fastCheck if only the bounding box should checked
  78541. * @returns picking info of the intersecton
  78542. */
  78543. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  78544. /**
  78545. * Checks if ray intersects a mesh
  78546. * @param meshes the meshes to check
  78547. * @param fastCheck if only the bounding box should checked
  78548. * @param results array to store result in
  78549. * @returns Array of picking infos
  78550. */
  78551. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  78552. private _comparePickingInfo;
  78553. private static smallnum;
  78554. private static rayl;
  78555. /**
  78556. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  78557. * @param sega the first point of the segment to test the intersection against
  78558. * @param segb the second point of the segment to test the intersection against
  78559. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  78560. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  78561. */
  78562. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  78563. /**
  78564. * Update the ray from viewport position
  78565. * @param x position
  78566. * @param y y position
  78567. * @param viewportWidth viewport width
  78568. * @param viewportHeight viewport height
  78569. * @param world world matrix
  78570. * @param view view matrix
  78571. * @param projection projection matrix
  78572. * @returns this ray updated
  78573. */
  78574. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78575. /**
  78576. * Creates a ray with origin and direction of 0,0,0
  78577. * @returns the new ray
  78578. */
  78579. static Zero(): Ray;
  78580. /**
  78581. * Creates a new ray from screen space and viewport
  78582. * @param x position
  78583. * @param y y position
  78584. * @param viewportWidth viewport width
  78585. * @param viewportHeight viewport height
  78586. * @param world world matrix
  78587. * @param view view matrix
  78588. * @param projection projection matrix
  78589. * @returns new ray
  78590. */
  78591. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  78592. /**
  78593. * 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
  78594. * transformed to the given world matrix.
  78595. * @param origin The origin point
  78596. * @param end The end point
  78597. * @param world a matrix to transform the ray to. Default is the identity matrix.
  78598. * @returns the new ray
  78599. */
  78600. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  78601. /**
  78602. * Transforms a ray by a matrix
  78603. * @param ray ray to transform
  78604. * @param matrix matrix to apply
  78605. * @returns the resulting new ray
  78606. */
  78607. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  78608. /**
  78609. * Transforms a ray by a matrix
  78610. * @param ray ray to transform
  78611. * @param matrix matrix to apply
  78612. * @param result ray to store result in
  78613. */
  78614. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  78615. /**
  78616. * Unproject a ray from screen space to object space
  78617. * @param sourceX defines the screen space x coordinate to use
  78618. * @param sourceY defines the screen space y coordinate to use
  78619. * @param viewportWidth defines the current width of the viewport
  78620. * @param viewportHeight defines the current height of the viewport
  78621. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  78622. * @param view defines the view matrix to use
  78623. * @param projection defines the projection matrix to use
  78624. */
  78625. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  78626. }
  78627. /**
  78628. * Type used to define predicate used to select faces when a mesh intersection is detected
  78629. */
  78630. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  78631. interface Scene {
  78632. /** @hidden */
  78633. _tempPickingRay: Nullable<Ray>;
  78634. /** @hidden */
  78635. _cachedRayForTransform: Ray;
  78636. /** @hidden */
  78637. _pickWithRayInverseMatrix: Matrix;
  78638. /** @hidden */
  78639. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  78640. /** @hidden */
  78641. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  78642. }
  78643. }
  78644. declare module BABYLON {
  78645. interface Scene {
  78646. /** @hidden */
  78647. _pointerOverSprite: Nullable<Sprite>;
  78648. /** @hidden */
  78649. _pickedDownSprite: Nullable<Sprite>;
  78650. /** @hidden */
  78651. _tempSpritePickingRay: Nullable<Ray>;
  78652. /**
  78653. * All of the sprite managers added to this scene
  78654. * @see http://doc.babylonjs.com/babylon101/sprites
  78655. */
  78656. spriteManagers: Array<ISpriteManager>;
  78657. /**
  78658. * An event triggered when sprites rendering is about to start
  78659. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78660. */
  78661. onBeforeSpritesRenderingObservable: Observable<Scene>;
  78662. /**
  78663. * An event triggered when sprites rendering is done
  78664. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78665. */
  78666. onAfterSpritesRenderingObservable: Observable<Scene>;
  78667. /** @hidden */
  78668. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78669. /** Launch a ray to try to pick a sprite in the scene
  78670. * @param x position on screen
  78671. * @param y position on screen
  78672. * @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
  78673. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78674. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78675. * @returns a PickingInfo
  78676. */
  78677. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78678. /** Use the given ray to pick a sprite in the scene
  78679. * @param ray The ray (in world space) to use to pick meshes
  78680. * @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
  78681. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78682. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78683. * @returns a PickingInfo
  78684. */
  78685. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78686. /**
  78687. * Force the sprite under the pointer
  78688. * @param sprite defines the sprite to use
  78689. */
  78690. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  78691. /**
  78692. * Gets the sprite under the pointer
  78693. * @returns a Sprite or null if no sprite is under the pointer
  78694. */
  78695. getPointerOverSprite(): Nullable<Sprite>;
  78696. }
  78697. /**
  78698. * Defines the sprite scene component responsible to manage sprites
  78699. * in a given scene.
  78700. */
  78701. export class SpriteSceneComponent implements ISceneComponent {
  78702. /**
  78703. * The component name helpfull to identify the component in the list of scene components.
  78704. */
  78705. readonly name: string;
  78706. /**
  78707. * The scene the component belongs to.
  78708. */
  78709. scene: Scene;
  78710. /** @hidden */
  78711. private _spritePredicate;
  78712. /**
  78713. * Creates a new instance of the component for the given scene
  78714. * @param scene Defines the scene to register the component in
  78715. */
  78716. constructor(scene: Scene);
  78717. /**
  78718. * Registers the component in a given scene
  78719. */
  78720. register(): void;
  78721. /**
  78722. * Rebuilds the elements related to this component in case of
  78723. * context lost for instance.
  78724. */
  78725. rebuild(): void;
  78726. /**
  78727. * Disposes the component and the associated ressources.
  78728. */
  78729. dispose(): void;
  78730. private _pickSpriteButKeepRay;
  78731. private _pointerMove;
  78732. private _pointerDown;
  78733. private _pointerUp;
  78734. }
  78735. }
  78736. declare module BABYLON {
  78737. /** @hidden */
  78738. export var fogFragmentDeclaration: {
  78739. name: string;
  78740. shader: string;
  78741. };
  78742. }
  78743. declare module BABYLON {
  78744. /** @hidden */
  78745. export var fogFragment: {
  78746. name: string;
  78747. shader: string;
  78748. };
  78749. }
  78750. declare module BABYLON {
  78751. /** @hidden */
  78752. export var spritesPixelShader: {
  78753. name: string;
  78754. shader: string;
  78755. };
  78756. }
  78757. declare module BABYLON {
  78758. /** @hidden */
  78759. export var fogVertexDeclaration: {
  78760. name: string;
  78761. shader: string;
  78762. };
  78763. }
  78764. declare module BABYLON {
  78765. /** @hidden */
  78766. export var spritesVertexShader: {
  78767. name: string;
  78768. shader: string;
  78769. };
  78770. }
  78771. declare module BABYLON {
  78772. /**
  78773. * Defines the minimum interface to fullfil in order to be a sprite manager.
  78774. */
  78775. export interface ISpriteManager extends IDisposable {
  78776. /**
  78777. * Restricts the camera to viewing objects with the same layerMask.
  78778. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  78779. */
  78780. layerMask: number;
  78781. /**
  78782. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  78783. */
  78784. isPickable: boolean;
  78785. /**
  78786. * Specifies the rendering group id for this mesh (0 by default)
  78787. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  78788. */
  78789. renderingGroupId: number;
  78790. /**
  78791. * Defines the list of sprites managed by the manager.
  78792. */
  78793. sprites: Array<Sprite>;
  78794. /**
  78795. * Tests the intersection of a sprite with a specific ray.
  78796. * @param ray The ray we are sending to test the collision
  78797. * @param camera The camera space we are sending rays in
  78798. * @param predicate A predicate allowing excluding sprites from the list of object to test
  78799. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  78800. * @returns picking info or null.
  78801. */
  78802. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78803. /**
  78804. * Renders the list of sprites on screen.
  78805. */
  78806. render(): void;
  78807. }
  78808. /**
  78809. * Class used to manage multiple sprites on the same spritesheet
  78810. * @see http://doc.babylonjs.com/babylon101/sprites
  78811. */
  78812. export class SpriteManager implements ISpriteManager {
  78813. /** defines the manager's name */
  78814. name: string;
  78815. /** Gets the list of sprites */
  78816. sprites: Sprite[];
  78817. /** Gets or sets the rendering group id (0 by default) */
  78818. renderingGroupId: number;
  78819. /** Gets or sets camera layer mask */
  78820. layerMask: number;
  78821. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  78822. fogEnabled: boolean;
  78823. /** Gets or sets a boolean indicating if the sprites are pickable */
  78824. isPickable: boolean;
  78825. /** Defines the default width of a cell in the spritesheet */
  78826. cellWidth: number;
  78827. /** Defines the default height of a cell in the spritesheet */
  78828. cellHeight: number;
  78829. /**
  78830. * An event triggered when the manager is disposed.
  78831. */
  78832. onDisposeObservable: Observable<SpriteManager>;
  78833. private _onDisposeObserver;
  78834. /**
  78835. * Callback called when the manager is disposed
  78836. */
  78837. onDispose: () => void;
  78838. private _capacity;
  78839. private _spriteTexture;
  78840. private _epsilon;
  78841. private _scene;
  78842. private _vertexData;
  78843. private _buffer;
  78844. private _vertexBuffers;
  78845. private _indexBuffer;
  78846. private _effectBase;
  78847. private _effectFog;
  78848. /**
  78849. * Gets or sets the spritesheet texture
  78850. */
  78851. texture: Texture;
  78852. /**
  78853. * Creates a new sprite manager
  78854. * @param name defines the manager's name
  78855. * @param imgUrl defines the sprite sheet url
  78856. * @param capacity defines the maximum allowed number of sprites
  78857. * @param cellSize defines the size of a sprite cell
  78858. * @param scene defines the hosting scene
  78859. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  78860. * @param samplingMode defines the smapling mode to use with spritesheet
  78861. */
  78862. constructor(
  78863. /** defines the manager's name */
  78864. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  78865. private _appendSpriteVertex;
  78866. /**
  78867. * Intersects the sprites with a ray
  78868. * @param ray defines the ray to intersect with
  78869. * @param camera defines the current active camera
  78870. * @param predicate defines a predicate used to select candidate sprites
  78871. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  78872. * @returns null if no hit or a PickingInfo
  78873. */
  78874. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78875. /**
  78876. * Render all child sprites
  78877. */
  78878. render(): void;
  78879. /**
  78880. * Release associated resources
  78881. */
  78882. dispose(): void;
  78883. }
  78884. }
  78885. declare module BABYLON {
  78886. /**
  78887. * Class used to represent a sprite
  78888. * @see http://doc.babylonjs.com/babylon101/sprites
  78889. */
  78890. export class Sprite {
  78891. /** defines the name */
  78892. name: string;
  78893. /** Gets or sets the current world position */
  78894. position: Vector3;
  78895. /** Gets or sets the main color */
  78896. color: Color4;
  78897. /** Gets or sets the width */
  78898. width: number;
  78899. /** Gets or sets the height */
  78900. height: number;
  78901. /** Gets or sets rotation angle */
  78902. angle: number;
  78903. /** Gets or sets the cell index in the sprite sheet */
  78904. cellIndex: number;
  78905. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  78906. invertU: number;
  78907. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  78908. invertV: number;
  78909. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  78910. disposeWhenFinishedAnimating: boolean;
  78911. /** Gets the list of attached animations */
  78912. animations: Animation[];
  78913. /** Gets or sets a boolean indicating if the sprite can be picked */
  78914. isPickable: boolean;
  78915. /**
  78916. * Gets or sets the associated action manager
  78917. */
  78918. actionManager: Nullable<ActionManager>;
  78919. private _animationStarted;
  78920. private _loopAnimation;
  78921. private _fromIndex;
  78922. private _toIndex;
  78923. private _delay;
  78924. private _direction;
  78925. private _manager;
  78926. private _time;
  78927. private _onAnimationEnd;
  78928. /**
  78929. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  78930. */
  78931. isVisible: boolean;
  78932. /**
  78933. * Gets or sets the sprite size
  78934. */
  78935. size: number;
  78936. /**
  78937. * Creates a new Sprite
  78938. * @param name defines the name
  78939. * @param manager defines the manager
  78940. */
  78941. constructor(
  78942. /** defines the name */
  78943. name: string, manager: ISpriteManager);
  78944. /**
  78945. * Starts an animation
  78946. * @param from defines the initial key
  78947. * @param to defines the end key
  78948. * @param loop defines if the animation must loop
  78949. * @param delay defines the start delay (in ms)
  78950. * @param onAnimationEnd defines a callback to call when animation ends
  78951. */
  78952. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  78953. /** Stops current animation (if any) */
  78954. stopAnimation(): void;
  78955. /** @hidden */
  78956. _animate(deltaTime: number): void;
  78957. /** Release associated resources */
  78958. dispose(): void;
  78959. }
  78960. }
  78961. declare module BABYLON {
  78962. /**
  78963. * Information about the result of picking within a scene
  78964. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  78965. */
  78966. export class PickingInfo {
  78967. /** @hidden */
  78968. _pickingUnavailable: boolean;
  78969. /**
  78970. * If the pick collided with an object
  78971. */
  78972. hit: boolean;
  78973. /**
  78974. * Distance away where the pick collided
  78975. */
  78976. distance: number;
  78977. /**
  78978. * The location of pick collision
  78979. */
  78980. pickedPoint: Nullable<Vector3>;
  78981. /**
  78982. * The mesh corresponding the the pick collision
  78983. */
  78984. pickedMesh: Nullable<AbstractMesh>;
  78985. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  78986. bu: number;
  78987. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  78988. bv: number;
  78989. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  78990. faceId: number;
  78991. /** Id of the the submesh that was picked */
  78992. subMeshId: number;
  78993. /** If a sprite was picked, this will be the sprite the pick collided with */
  78994. pickedSprite: Nullable<Sprite>;
  78995. /**
  78996. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  78997. */
  78998. originMesh: Nullable<AbstractMesh>;
  78999. /**
  79000. * The ray that was used to perform the picking.
  79001. */
  79002. ray: Nullable<Ray>;
  79003. /**
  79004. * Gets the normal correspodning to the face the pick collided with
  79005. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  79006. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  79007. * @returns The normal correspodning to the face the pick collided with
  79008. */
  79009. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  79010. /**
  79011. * Gets the texture coordinates of where the pick occured
  79012. * @returns the vector containing the coordnates of the texture
  79013. */
  79014. getTextureCoordinates(): Nullable<Vector2>;
  79015. }
  79016. }
  79017. declare module BABYLON {
  79018. /**
  79019. * Gather the list of pointer event types as constants.
  79020. */
  79021. export class PointerEventTypes {
  79022. /**
  79023. * 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.
  79024. */
  79025. static readonly POINTERDOWN: number;
  79026. /**
  79027. * The pointerup event is fired when a pointer is no longer active.
  79028. */
  79029. static readonly POINTERUP: number;
  79030. /**
  79031. * The pointermove event is fired when a pointer changes coordinates.
  79032. */
  79033. static readonly POINTERMOVE: number;
  79034. /**
  79035. * The pointerwheel event is fired when a mouse wheel has been rotated.
  79036. */
  79037. static readonly POINTERWHEEL: number;
  79038. /**
  79039. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  79040. */
  79041. static readonly POINTERPICK: number;
  79042. /**
  79043. * The pointertap event is fired when a the object has been touched and released without drag.
  79044. */
  79045. static readonly POINTERTAP: number;
  79046. /**
  79047. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  79048. */
  79049. static readonly POINTERDOUBLETAP: number;
  79050. }
  79051. /**
  79052. * Base class of pointer info types.
  79053. */
  79054. export class PointerInfoBase {
  79055. /**
  79056. * Defines the type of event (PointerEventTypes)
  79057. */
  79058. type: number;
  79059. /**
  79060. * Defines the related dom event
  79061. */
  79062. event: PointerEvent | MouseWheelEvent;
  79063. /**
  79064. * Instantiates the base class of pointers info.
  79065. * @param type Defines the type of event (PointerEventTypes)
  79066. * @param event Defines the related dom event
  79067. */
  79068. constructor(
  79069. /**
  79070. * Defines the type of event (PointerEventTypes)
  79071. */
  79072. type: number,
  79073. /**
  79074. * Defines the related dom event
  79075. */
  79076. event: PointerEvent | MouseWheelEvent);
  79077. }
  79078. /**
  79079. * This class is used to store pointer related info for the onPrePointerObservable event.
  79080. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  79081. */
  79082. export class PointerInfoPre extends PointerInfoBase {
  79083. /**
  79084. * Ray from a pointer if availible (eg. 6dof controller)
  79085. */
  79086. ray: Nullable<Ray>;
  79087. /**
  79088. * Defines the local position of the pointer on the canvas.
  79089. */
  79090. localPosition: Vector2;
  79091. /**
  79092. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  79093. */
  79094. skipOnPointerObservable: boolean;
  79095. /**
  79096. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  79097. * @param type Defines the type of event (PointerEventTypes)
  79098. * @param event Defines the related dom event
  79099. * @param localX Defines the local x coordinates of the pointer when the event occured
  79100. * @param localY Defines the local y coordinates of the pointer when the event occured
  79101. */
  79102. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  79103. }
  79104. /**
  79105. * This type contains all the data related to a pointer event in Babylon.js.
  79106. * 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.
  79107. */
  79108. export class PointerInfo extends PointerInfoBase {
  79109. /**
  79110. * Defines the picking info associated to the info (if any)\
  79111. */
  79112. pickInfo: Nullable<PickingInfo>;
  79113. /**
  79114. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  79115. * @param type Defines the type of event (PointerEventTypes)
  79116. * @param event Defines the related dom event
  79117. * @param pickInfo Defines the picking info associated to the info (if any)\
  79118. */
  79119. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  79120. /**
  79121. * Defines the picking info associated to the info (if any)\
  79122. */
  79123. pickInfo: Nullable<PickingInfo>);
  79124. }
  79125. /**
  79126. * Data relating to a touch event on the screen.
  79127. */
  79128. export interface PointerTouch {
  79129. /**
  79130. * X coordinate of touch.
  79131. */
  79132. x: number;
  79133. /**
  79134. * Y coordinate of touch.
  79135. */
  79136. y: number;
  79137. /**
  79138. * Id of touch. Unique for each finger.
  79139. */
  79140. pointerId: number;
  79141. /**
  79142. * Event type passed from DOM.
  79143. */
  79144. type: any;
  79145. }
  79146. }
  79147. declare module BABYLON {
  79148. /**
  79149. * Manage the mouse inputs to control the movement of a free camera.
  79150. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79151. */
  79152. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  79153. /**
  79154. * Define if touch is enabled in the mouse input
  79155. */
  79156. touchEnabled: boolean;
  79157. /**
  79158. * Defines the camera the input is attached to.
  79159. */
  79160. camera: FreeCamera;
  79161. /**
  79162. * Defines the buttons associated with the input to handle camera move.
  79163. */
  79164. buttons: number[];
  79165. /**
  79166. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  79167. */
  79168. angularSensibility: number;
  79169. private _pointerInput;
  79170. private _onMouseMove;
  79171. private _observer;
  79172. private previousPosition;
  79173. /**
  79174. * Observable for when a pointer move event occurs containing the move offset
  79175. */
  79176. onPointerMovedObservable: Observable<{
  79177. offsetX: number;
  79178. offsetY: number;
  79179. }>;
  79180. /**
  79181. * @hidden
  79182. * If the camera should be rotated automatically based on pointer movement
  79183. */
  79184. _allowCameraRotation: boolean;
  79185. /**
  79186. * Manage the mouse inputs to control the movement of a free camera.
  79187. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79188. * @param touchEnabled Defines if touch is enabled or not
  79189. */
  79190. constructor(
  79191. /**
  79192. * Define if touch is enabled in the mouse input
  79193. */
  79194. touchEnabled?: boolean);
  79195. /**
  79196. * Attach the input controls to a specific dom element to get the input from.
  79197. * @param element Defines the element the controls should be listened from
  79198. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79199. */
  79200. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79201. /**
  79202. * Called on JS contextmenu event.
  79203. * Override this method to provide functionality.
  79204. */
  79205. protected onContextMenu(evt: PointerEvent): void;
  79206. /**
  79207. * Detach the current controls from the specified dom element.
  79208. * @param element Defines the element to stop listening the inputs from
  79209. */
  79210. detachControl(element: Nullable<HTMLElement>): void;
  79211. /**
  79212. * Gets the class name of the current intput.
  79213. * @returns the class name
  79214. */
  79215. getClassName(): string;
  79216. /**
  79217. * Get the friendly name associated with the input class.
  79218. * @returns the input friendly name
  79219. */
  79220. getSimpleName(): string;
  79221. }
  79222. }
  79223. declare module BABYLON {
  79224. /**
  79225. * Manage the touch inputs to control the movement of a free camera.
  79226. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79227. */
  79228. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  79229. /**
  79230. * Defines the camera the input is attached to.
  79231. */
  79232. camera: FreeCamera;
  79233. /**
  79234. * Defines the touch sensibility for rotation.
  79235. * The higher the faster.
  79236. */
  79237. touchAngularSensibility: number;
  79238. /**
  79239. * Defines the touch sensibility for move.
  79240. * The higher the faster.
  79241. */
  79242. touchMoveSensibility: number;
  79243. private _offsetX;
  79244. private _offsetY;
  79245. private _pointerPressed;
  79246. private _pointerInput;
  79247. private _observer;
  79248. private _onLostFocus;
  79249. /**
  79250. * Attach the input controls to a specific dom element to get the input from.
  79251. * @param element Defines the element the controls should be listened from
  79252. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79253. */
  79254. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79255. /**
  79256. * Detach the current controls from the specified dom element.
  79257. * @param element Defines the element to stop listening the inputs from
  79258. */
  79259. detachControl(element: Nullable<HTMLElement>): void;
  79260. /**
  79261. * Update the current camera state depending on the inputs that have been used this frame.
  79262. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79263. */
  79264. checkInputs(): void;
  79265. /**
  79266. * Gets the class name of the current intput.
  79267. * @returns the class name
  79268. */
  79269. getClassName(): string;
  79270. /**
  79271. * Get the friendly name associated with the input class.
  79272. * @returns the input friendly name
  79273. */
  79274. getSimpleName(): string;
  79275. }
  79276. }
  79277. declare module BABYLON {
  79278. /**
  79279. * Default Inputs manager for the FreeCamera.
  79280. * It groups all the default supported inputs for ease of use.
  79281. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79282. */
  79283. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  79284. /**
  79285. * @hidden
  79286. */
  79287. _mouseInput: Nullable<FreeCameraMouseInput>;
  79288. /**
  79289. * Instantiates a new FreeCameraInputsManager.
  79290. * @param camera Defines the camera the inputs belong to
  79291. */
  79292. constructor(camera: FreeCamera);
  79293. /**
  79294. * Add keyboard input support to the input manager.
  79295. * @returns the current input manager
  79296. */
  79297. addKeyboard(): FreeCameraInputsManager;
  79298. /**
  79299. * Add mouse input support to the input manager.
  79300. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  79301. * @returns the current input manager
  79302. */
  79303. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  79304. /**
  79305. * Removes the mouse input support from the manager
  79306. * @returns the current input manager
  79307. */
  79308. removeMouse(): FreeCameraInputsManager;
  79309. /**
  79310. * Add touch input support to the input manager.
  79311. * @returns the current input manager
  79312. */
  79313. addTouch(): FreeCameraInputsManager;
  79314. /**
  79315. * Remove all attached input methods from a camera
  79316. */
  79317. clear(): void;
  79318. }
  79319. }
  79320. declare module BABYLON {
  79321. /**
  79322. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79323. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  79324. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79325. */
  79326. export class FreeCamera extends TargetCamera {
  79327. /**
  79328. * Define the collision ellipsoid of the camera.
  79329. * This is helpful to simulate a camera body like the player body around the camera
  79330. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  79331. */
  79332. ellipsoid: Vector3;
  79333. /**
  79334. * Define an offset for the position of the ellipsoid around the camera.
  79335. * This can be helpful to determine the center of the body near the gravity center of the body
  79336. * instead of its head.
  79337. */
  79338. ellipsoidOffset: Vector3;
  79339. /**
  79340. * Enable or disable collisions of the camera with the rest of the scene objects.
  79341. */
  79342. checkCollisions: boolean;
  79343. /**
  79344. * Enable or disable gravity on the camera.
  79345. */
  79346. applyGravity: boolean;
  79347. /**
  79348. * Define the input manager associated to the camera.
  79349. */
  79350. inputs: FreeCameraInputsManager;
  79351. /**
  79352. * Gets the input sensibility for a mouse input. (default is 2000.0)
  79353. * Higher values reduce sensitivity.
  79354. */
  79355. /**
  79356. * Sets the input sensibility for a mouse input. (default is 2000.0)
  79357. * Higher values reduce sensitivity.
  79358. */
  79359. angularSensibility: number;
  79360. /**
  79361. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  79362. */
  79363. keysUp: number[];
  79364. /**
  79365. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  79366. */
  79367. keysDown: number[];
  79368. /**
  79369. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  79370. */
  79371. keysLeft: number[];
  79372. /**
  79373. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  79374. */
  79375. keysRight: number[];
  79376. /**
  79377. * Event raised when the camera collide with a mesh in the scene.
  79378. */
  79379. onCollide: (collidedMesh: AbstractMesh) => void;
  79380. private _collider;
  79381. private _needMoveForGravity;
  79382. private _oldPosition;
  79383. private _diffPosition;
  79384. private _newPosition;
  79385. /** @hidden */
  79386. _localDirection: Vector3;
  79387. /** @hidden */
  79388. _transformedDirection: Vector3;
  79389. /**
  79390. * Instantiates a Free Camera.
  79391. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  79392. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  79393. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  79394. * @param name Define the name of the camera in the scene
  79395. * @param position Define the start position of the camera in the scene
  79396. * @param scene Define the scene the camera belongs to
  79397. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  79398. */
  79399. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  79400. /**
  79401. * Attached controls to the current camera.
  79402. * @param element Defines the element the controls should be listened from
  79403. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79404. */
  79405. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79406. /**
  79407. * Detach the current controls from the camera.
  79408. * The camera will stop reacting to inputs.
  79409. * @param element Defines the element to stop listening the inputs from
  79410. */
  79411. detachControl(element: HTMLElement): void;
  79412. private _collisionMask;
  79413. /**
  79414. * Define a collision mask to limit the list of object the camera can collide with
  79415. */
  79416. collisionMask: number;
  79417. /** @hidden */
  79418. _collideWithWorld(displacement: Vector3): void;
  79419. private _onCollisionPositionChange;
  79420. /** @hidden */
  79421. _checkInputs(): void;
  79422. /** @hidden */
  79423. _decideIfNeedsToMove(): boolean;
  79424. /** @hidden */
  79425. _updatePosition(): void;
  79426. /**
  79427. * Destroy the camera and release the current resources hold by it.
  79428. */
  79429. dispose(): void;
  79430. /**
  79431. * Gets the current object class name.
  79432. * @return the class name
  79433. */
  79434. getClassName(): string;
  79435. }
  79436. }
  79437. declare module BABYLON {
  79438. /**
  79439. * Represents a gamepad control stick position
  79440. */
  79441. export class StickValues {
  79442. /**
  79443. * The x component of the control stick
  79444. */
  79445. x: number;
  79446. /**
  79447. * The y component of the control stick
  79448. */
  79449. y: number;
  79450. /**
  79451. * Initializes the gamepad x and y control stick values
  79452. * @param x The x component of the gamepad control stick value
  79453. * @param y The y component of the gamepad control stick value
  79454. */
  79455. constructor(
  79456. /**
  79457. * The x component of the control stick
  79458. */
  79459. x: number,
  79460. /**
  79461. * The y component of the control stick
  79462. */
  79463. y: number);
  79464. }
  79465. /**
  79466. * An interface which manages callbacks for gamepad button changes
  79467. */
  79468. export interface GamepadButtonChanges {
  79469. /**
  79470. * Called when a gamepad has been changed
  79471. */
  79472. changed: boolean;
  79473. /**
  79474. * Called when a gamepad press event has been triggered
  79475. */
  79476. pressChanged: boolean;
  79477. /**
  79478. * Called when a touch event has been triggered
  79479. */
  79480. touchChanged: boolean;
  79481. /**
  79482. * Called when a value has changed
  79483. */
  79484. valueChanged: boolean;
  79485. }
  79486. /**
  79487. * Represents a gamepad
  79488. */
  79489. export class Gamepad {
  79490. /**
  79491. * The id of the gamepad
  79492. */
  79493. id: string;
  79494. /**
  79495. * The index of the gamepad
  79496. */
  79497. index: number;
  79498. /**
  79499. * The browser gamepad
  79500. */
  79501. browserGamepad: any;
  79502. /**
  79503. * Specifies what type of gamepad this represents
  79504. */
  79505. type: number;
  79506. private _leftStick;
  79507. private _rightStick;
  79508. /** @hidden */
  79509. _isConnected: boolean;
  79510. private _leftStickAxisX;
  79511. private _leftStickAxisY;
  79512. private _rightStickAxisX;
  79513. private _rightStickAxisY;
  79514. /**
  79515. * Triggered when the left control stick has been changed
  79516. */
  79517. private _onleftstickchanged;
  79518. /**
  79519. * Triggered when the right control stick has been changed
  79520. */
  79521. private _onrightstickchanged;
  79522. /**
  79523. * Represents a gamepad controller
  79524. */
  79525. static GAMEPAD: number;
  79526. /**
  79527. * Represents a generic controller
  79528. */
  79529. static GENERIC: number;
  79530. /**
  79531. * Represents an XBox controller
  79532. */
  79533. static XBOX: number;
  79534. /**
  79535. * Represents a pose-enabled controller
  79536. */
  79537. static POSE_ENABLED: number;
  79538. /**
  79539. * Specifies whether the left control stick should be Y-inverted
  79540. */
  79541. protected _invertLeftStickY: boolean;
  79542. /**
  79543. * Specifies if the gamepad has been connected
  79544. */
  79545. readonly isConnected: boolean;
  79546. /**
  79547. * Initializes the gamepad
  79548. * @param id The id of the gamepad
  79549. * @param index The index of the gamepad
  79550. * @param browserGamepad The browser gamepad
  79551. * @param leftStickX The x component of the left joystick
  79552. * @param leftStickY The y component of the left joystick
  79553. * @param rightStickX The x component of the right joystick
  79554. * @param rightStickY The y component of the right joystick
  79555. */
  79556. constructor(
  79557. /**
  79558. * The id of the gamepad
  79559. */
  79560. id: string,
  79561. /**
  79562. * The index of the gamepad
  79563. */
  79564. index: number,
  79565. /**
  79566. * The browser gamepad
  79567. */
  79568. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  79569. /**
  79570. * Callback triggered when the left joystick has changed
  79571. * @param callback
  79572. */
  79573. onleftstickchanged(callback: (values: StickValues) => void): void;
  79574. /**
  79575. * Callback triggered when the right joystick has changed
  79576. * @param callback
  79577. */
  79578. onrightstickchanged(callback: (values: StickValues) => void): void;
  79579. /**
  79580. * Gets the left joystick
  79581. */
  79582. /**
  79583. * Sets the left joystick values
  79584. */
  79585. leftStick: StickValues;
  79586. /**
  79587. * Gets the right joystick
  79588. */
  79589. /**
  79590. * Sets the right joystick value
  79591. */
  79592. rightStick: StickValues;
  79593. /**
  79594. * Updates the gamepad joystick positions
  79595. */
  79596. update(): void;
  79597. /**
  79598. * Disposes the gamepad
  79599. */
  79600. dispose(): void;
  79601. }
  79602. /**
  79603. * Represents a generic gamepad
  79604. */
  79605. export class GenericPad extends Gamepad {
  79606. private _buttons;
  79607. private _onbuttondown;
  79608. private _onbuttonup;
  79609. /**
  79610. * Observable triggered when a button has been pressed
  79611. */
  79612. onButtonDownObservable: Observable<number>;
  79613. /**
  79614. * Observable triggered when a button has been released
  79615. */
  79616. onButtonUpObservable: Observable<number>;
  79617. /**
  79618. * Callback triggered when a button has been pressed
  79619. * @param callback Called when a button has been pressed
  79620. */
  79621. onbuttondown(callback: (buttonPressed: number) => void): void;
  79622. /**
  79623. * Callback triggered when a button has been released
  79624. * @param callback Called when a button has been released
  79625. */
  79626. onbuttonup(callback: (buttonReleased: number) => void): void;
  79627. /**
  79628. * Initializes the generic gamepad
  79629. * @param id The id of the generic gamepad
  79630. * @param index The index of the generic gamepad
  79631. * @param browserGamepad The browser gamepad
  79632. */
  79633. constructor(id: string, index: number, browserGamepad: any);
  79634. private _setButtonValue;
  79635. /**
  79636. * Updates the generic gamepad
  79637. */
  79638. update(): void;
  79639. /**
  79640. * Disposes the generic gamepad
  79641. */
  79642. dispose(): void;
  79643. }
  79644. }
  79645. declare module BABYLON {
  79646. /**
  79647. * Defines the types of pose enabled controllers that are supported
  79648. */
  79649. export enum PoseEnabledControllerType {
  79650. /**
  79651. * HTC Vive
  79652. */
  79653. VIVE = 0,
  79654. /**
  79655. * Oculus Rift
  79656. */
  79657. OCULUS = 1,
  79658. /**
  79659. * Windows mixed reality
  79660. */
  79661. WINDOWS = 2,
  79662. /**
  79663. * Samsung gear VR
  79664. */
  79665. GEAR_VR = 3,
  79666. /**
  79667. * Google Daydream
  79668. */
  79669. DAYDREAM = 4,
  79670. /**
  79671. * Generic
  79672. */
  79673. GENERIC = 5
  79674. }
  79675. /**
  79676. * Defines the MutableGamepadButton interface for the state of a gamepad button
  79677. */
  79678. export interface MutableGamepadButton {
  79679. /**
  79680. * Value of the button/trigger
  79681. */
  79682. value: number;
  79683. /**
  79684. * If the button/trigger is currently touched
  79685. */
  79686. touched: boolean;
  79687. /**
  79688. * If the button/trigger is currently pressed
  79689. */
  79690. pressed: boolean;
  79691. }
  79692. /**
  79693. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  79694. * @hidden
  79695. */
  79696. export interface ExtendedGamepadButton extends GamepadButton {
  79697. /**
  79698. * If the button/trigger is currently pressed
  79699. */
  79700. readonly pressed: boolean;
  79701. /**
  79702. * If the button/trigger is currently touched
  79703. */
  79704. readonly touched: boolean;
  79705. /**
  79706. * Value of the button/trigger
  79707. */
  79708. readonly value: number;
  79709. }
  79710. /** @hidden */
  79711. export interface _GamePadFactory {
  79712. /**
  79713. * Returns wether or not the current gamepad can be created for this type of controller.
  79714. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  79715. * @returns true if it can be created, otherwise false
  79716. */
  79717. canCreate(gamepadInfo: any): boolean;
  79718. /**
  79719. * Creates a new instance of the Gamepad.
  79720. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  79721. * @returns the new gamepad instance
  79722. */
  79723. create(gamepadInfo: any): Gamepad;
  79724. }
  79725. /**
  79726. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  79727. */
  79728. export class PoseEnabledControllerHelper {
  79729. /** @hidden */
  79730. static _ControllerFactories: _GamePadFactory[];
  79731. /** @hidden */
  79732. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  79733. /**
  79734. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  79735. * @param vrGamepad the gamepad to initialized
  79736. * @returns a vr controller of the type the gamepad identified as
  79737. */
  79738. static InitiateController(vrGamepad: any): Gamepad;
  79739. }
  79740. /**
  79741. * Defines the PoseEnabledController object that contains state of a vr capable controller
  79742. */
  79743. export class PoseEnabledController extends Gamepad implements PoseControlled {
  79744. private _deviceRoomPosition;
  79745. private _deviceRoomRotationQuaternion;
  79746. /**
  79747. * The device position in babylon space
  79748. */
  79749. devicePosition: Vector3;
  79750. /**
  79751. * The device rotation in babylon space
  79752. */
  79753. deviceRotationQuaternion: Quaternion;
  79754. /**
  79755. * The scale factor of the device in babylon space
  79756. */
  79757. deviceScaleFactor: number;
  79758. /**
  79759. * (Likely devicePosition should be used instead) The device position in its room space
  79760. */
  79761. position: Vector3;
  79762. /**
  79763. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  79764. */
  79765. rotationQuaternion: Quaternion;
  79766. /**
  79767. * The type of controller (Eg. Windows mixed reality)
  79768. */
  79769. controllerType: PoseEnabledControllerType;
  79770. protected _calculatedPosition: Vector3;
  79771. private _calculatedRotation;
  79772. /**
  79773. * The raw pose from the device
  79774. */
  79775. rawPose: DevicePose;
  79776. private _trackPosition;
  79777. private _maxRotationDistFromHeadset;
  79778. private _draggedRoomRotation;
  79779. /**
  79780. * @hidden
  79781. */
  79782. _disableTrackPosition(fixedPosition: Vector3): void;
  79783. /**
  79784. * Internal, the mesh attached to the controller
  79785. * @hidden
  79786. */
  79787. _mesh: Nullable<AbstractMesh>;
  79788. private _poseControlledCamera;
  79789. private _leftHandSystemQuaternion;
  79790. /**
  79791. * Internal, matrix used to convert room space to babylon space
  79792. * @hidden
  79793. */
  79794. _deviceToWorld: Matrix;
  79795. /**
  79796. * Node to be used when casting a ray from the controller
  79797. * @hidden
  79798. */
  79799. _pointingPoseNode: Nullable<TransformNode>;
  79800. /**
  79801. * Name of the child mesh that can be used to cast a ray from the controller
  79802. */
  79803. static readonly POINTING_POSE: string;
  79804. /**
  79805. * Creates a new PoseEnabledController from a gamepad
  79806. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  79807. */
  79808. constructor(browserGamepad: any);
  79809. private _workingMatrix;
  79810. /**
  79811. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  79812. */
  79813. update(): void;
  79814. /**
  79815. * Updates only the pose device and mesh without doing any button event checking
  79816. */
  79817. protected _updatePoseAndMesh(): void;
  79818. /**
  79819. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  79820. * @param poseData raw pose fromthe device
  79821. */
  79822. updateFromDevice(poseData: DevicePose): void;
  79823. /**
  79824. * @hidden
  79825. */
  79826. _meshAttachedObservable: Observable<AbstractMesh>;
  79827. /**
  79828. * Attaches a mesh to the controller
  79829. * @param mesh the mesh to be attached
  79830. */
  79831. attachToMesh(mesh: AbstractMesh): void;
  79832. /**
  79833. * Attaches the controllers mesh to a camera
  79834. * @param camera the camera the mesh should be attached to
  79835. */
  79836. attachToPoseControlledCamera(camera: TargetCamera): void;
  79837. /**
  79838. * Disposes of the controller
  79839. */
  79840. dispose(): void;
  79841. /**
  79842. * The mesh that is attached to the controller
  79843. */
  79844. readonly mesh: Nullable<AbstractMesh>;
  79845. /**
  79846. * Gets the ray of the controller in the direction the controller is pointing
  79847. * @param length the length the resulting ray should be
  79848. * @returns a ray in the direction the controller is pointing
  79849. */
  79850. getForwardRay(length?: number): Ray;
  79851. }
  79852. }
  79853. declare module BABYLON {
  79854. /**
  79855. * Defines the WebVRController object that represents controllers tracked in 3D space
  79856. */
  79857. export abstract class WebVRController extends PoseEnabledController {
  79858. /**
  79859. * Internal, the default controller model for the controller
  79860. */
  79861. protected _defaultModel: AbstractMesh;
  79862. /**
  79863. * Fired when the trigger state has changed
  79864. */
  79865. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  79866. /**
  79867. * Fired when the main button state has changed
  79868. */
  79869. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  79870. /**
  79871. * Fired when the secondary button state has changed
  79872. */
  79873. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  79874. /**
  79875. * Fired when the pad state has changed
  79876. */
  79877. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  79878. /**
  79879. * Fired when controllers stick values have changed
  79880. */
  79881. onPadValuesChangedObservable: Observable<StickValues>;
  79882. /**
  79883. * Array of button availible on the controller
  79884. */
  79885. protected _buttons: Array<MutableGamepadButton>;
  79886. private _onButtonStateChange;
  79887. /**
  79888. * Fired when a controller button's state has changed
  79889. * @param callback the callback containing the button that was modified
  79890. */
  79891. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  79892. /**
  79893. * X and Y axis corresponding to the controllers joystick
  79894. */
  79895. pad: StickValues;
  79896. /**
  79897. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  79898. */
  79899. hand: string;
  79900. /**
  79901. * The default controller model for the controller
  79902. */
  79903. readonly defaultModel: AbstractMesh;
  79904. /**
  79905. * Creates a new WebVRController from a gamepad
  79906. * @param vrGamepad the gamepad that the WebVRController should be created from
  79907. */
  79908. constructor(vrGamepad: any);
  79909. /**
  79910. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  79911. */
  79912. update(): void;
  79913. /**
  79914. * Function to be called when a button is modified
  79915. */
  79916. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  79917. /**
  79918. * Loads a mesh and attaches it to the controller
  79919. * @param scene the scene the mesh should be added to
  79920. * @param meshLoaded callback for when the mesh has been loaded
  79921. */
  79922. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  79923. private _setButtonValue;
  79924. private _changes;
  79925. private _checkChanges;
  79926. /**
  79927. * Disposes of th webVRCOntroller
  79928. */
  79929. dispose(): void;
  79930. }
  79931. }
  79932. declare module BABYLON {
  79933. /**
  79934. * The HemisphericLight simulates the ambient environment light,
  79935. * so the passed direction is the light reflection direction, not the incoming direction.
  79936. */
  79937. export class HemisphericLight extends Light {
  79938. /**
  79939. * The groundColor is the light in the opposite direction to the one specified during creation.
  79940. * 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.
  79941. */
  79942. groundColor: Color3;
  79943. /**
  79944. * The light reflection direction, not the incoming direction.
  79945. */
  79946. direction: Vector3;
  79947. /**
  79948. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  79949. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  79950. * The HemisphericLight can't cast shadows.
  79951. * Documentation : https://doc.babylonjs.com/babylon101/lights
  79952. * @param name The friendly name of the light
  79953. * @param direction The direction of the light reflection
  79954. * @param scene The scene the light belongs to
  79955. */
  79956. constructor(name: string, direction: Vector3, scene: Scene);
  79957. protected _buildUniformLayout(): void;
  79958. /**
  79959. * Returns the string "HemisphericLight".
  79960. * @return The class name
  79961. */
  79962. getClassName(): string;
  79963. /**
  79964. * Sets the HemisphericLight direction towards the passed target (Vector3).
  79965. * Returns the updated direction.
  79966. * @param target The target the direction should point to
  79967. * @return The computed direction
  79968. */
  79969. setDirectionToTarget(target: Vector3): Vector3;
  79970. /**
  79971. * Returns the shadow generator associated to the light.
  79972. * @returns Always null for hemispheric lights because it does not support shadows.
  79973. */
  79974. getShadowGenerator(): Nullable<IShadowGenerator>;
  79975. /**
  79976. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  79977. * @param effect The effect to update
  79978. * @param lightIndex The index of the light in the effect to update
  79979. * @returns The hemispheric light
  79980. */
  79981. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  79982. /**
  79983. * Computes the world matrix of the node
  79984. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  79985. * @param useWasUpdatedFlag defines a reserved property
  79986. * @returns the world matrix
  79987. */
  79988. computeWorldMatrix(): Matrix;
  79989. /**
  79990. * Returns the integer 3.
  79991. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  79992. */
  79993. getTypeID(): number;
  79994. /**
  79995. * Prepares the list of defines specific to the light type.
  79996. * @param defines the list of defines
  79997. * @param lightIndex defines the index of the light for the effect
  79998. */
  79999. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  80000. }
  80001. }
  80002. declare module BABYLON {
  80003. /** @hidden */
  80004. export var vrMultiviewToSingleviewPixelShader: {
  80005. name: string;
  80006. shader: string;
  80007. };
  80008. }
  80009. declare module BABYLON {
  80010. /**
  80011. * Renders to multiple views with a single draw call
  80012. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  80013. */
  80014. export class MultiviewRenderTarget extends RenderTargetTexture {
  80015. /**
  80016. * Creates a multiview render target
  80017. * @param scene scene used with the render target
  80018. * @param size the size of the render target (used for each view)
  80019. */
  80020. constructor(scene: Scene, size?: number | {
  80021. width: number;
  80022. height: number;
  80023. } | {
  80024. ratio: number;
  80025. });
  80026. /**
  80027. * @hidden
  80028. * @param faceIndex the face index, if its a cube texture
  80029. */
  80030. _bindFrameBuffer(faceIndex?: number): void;
  80031. /**
  80032. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  80033. * @returns the view count
  80034. */
  80035. getViewCount(): number;
  80036. }
  80037. }
  80038. declare module BABYLON {
  80039. interface Engine {
  80040. /**
  80041. * Creates a new multiview render target
  80042. * @param width defines the width of the texture
  80043. * @param height defines the height of the texture
  80044. * @returns the created multiview texture
  80045. */
  80046. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  80047. /**
  80048. * Binds a multiview framebuffer to be drawn to
  80049. * @param multiviewTexture texture to bind
  80050. */
  80051. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  80052. }
  80053. interface Camera {
  80054. /**
  80055. * @hidden
  80056. * 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)
  80057. */
  80058. _useMultiviewToSingleView: boolean;
  80059. /**
  80060. * @hidden
  80061. * 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)
  80062. */
  80063. _multiviewTexture: Nullable<RenderTargetTexture>;
  80064. /**
  80065. * @hidden
  80066. * ensures the multiview texture of the camera exists and has the specified width/height
  80067. * @param width height to set on the multiview texture
  80068. * @param height width to set on the multiview texture
  80069. */
  80070. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  80071. }
  80072. interface Scene {
  80073. /** @hidden */
  80074. _transformMatrixR: Matrix;
  80075. /** @hidden */
  80076. _multiviewSceneUbo: Nullable<UniformBuffer>;
  80077. /** @hidden */
  80078. _createMultiviewUbo(): void;
  80079. /** @hidden */
  80080. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  80081. /** @hidden */
  80082. _renderMultiviewToSingleView(camera: Camera): void;
  80083. }
  80084. }
  80085. declare module BABYLON {
  80086. /**
  80087. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  80088. * This will not be used for webXR as it supports displaying texture arrays directly
  80089. */
  80090. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  80091. /**
  80092. * Initializes a VRMultiviewToSingleview
  80093. * @param name name of the post process
  80094. * @param camera camera to be applied to
  80095. * @param scaleFactor scaling factor to the size of the output texture
  80096. */
  80097. constructor(name: string, camera: Camera, scaleFactor: number);
  80098. }
  80099. }
  80100. declare module BABYLON {
  80101. interface Engine {
  80102. /** @hidden */
  80103. _vrDisplay: any;
  80104. /** @hidden */
  80105. _vrSupported: boolean;
  80106. /** @hidden */
  80107. _oldSize: Size;
  80108. /** @hidden */
  80109. _oldHardwareScaleFactor: number;
  80110. /** @hidden */
  80111. _vrExclusivePointerMode: boolean;
  80112. /** @hidden */
  80113. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  80114. /** @hidden */
  80115. _onVRDisplayPointerRestricted: () => void;
  80116. /** @hidden */
  80117. _onVRDisplayPointerUnrestricted: () => void;
  80118. /** @hidden */
  80119. _onVrDisplayConnect: Nullable<(display: any) => void>;
  80120. /** @hidden */
  80121. _onVrDisplayDisconnect: Nullable<() => void>;
  80122. /** @hidden */
  80123. _onVrDisplayPresentChange: Nullable<() => void>;
  80124. /**
  80125. * Observable signaled when VR display mode changes
  80126. */
  80127. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  80128. /**
  80129. * Observable signaled when VR request present is complete
  80130. */
  80131. onVRRequestPresentComplete: Observable<boolean>;
  80132. /**
  80133. * Observable signaled when VR request present starts
  80134. */
  80135. onVRRequestPresentStart: Observable<Engine>;
  80136. /**
  80137. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  80138. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  80139. */
  80140. isInVRExclusivePointerMode: boolean;
  80141. /**
  80142. * Gets a boolean indicating if a webVR device was detected
  80143. * @returns true if a webVR device was detected
  80144. */
  80145. isVRDevicePresent(): boolean;
  80146. /**
  80147. * Gets the current webVR device
  80148. * @returns the current webVR device (or null)
  80149. */
  80150. getVRDevice(): any;
  80151. /**
  80152. * Initializes a webVR display and starts listening to display change events
  80153. * The onVRDisplayChangedObservable will be notified upon these changes
  80154. * @returns A promise containing a VRDisplay and if vr is supported
  80155. */
  80156. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  80157. /** @hidden */
  80158. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  80159. /**
  80160. * Call this function to switch to webVR mode
  80161. * Will do nothing if webVR is not supported or if there is no webVR device
  80162. * @see http://doc.babylonjs.com/how_to/webvr_camera
  80163. */
  80164. enableVR(): void;
  80165. /** @hidden */
  80166. _onVRFullScreenTriggered(): void;
  80167. }
  80168. }
  80169. declare module BABYLON {
  80170. /**
  80171. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  80172. * IMPORTANT!! The data is right-hand data.
  80173. * @export
  80174. * @interface DevicePose
  80175. */
  80176. export interface DevicePose {
  80177. /**
  80178. * The position of the device, values in array are [x,y,z].
  80179. */
  80180. readonly position: Nullable<Float32Array>;
  80181. /**
  80182. * The linearVelocity of the device, values in array are [x,y,z].
  80183. */
  80184. readonly linearVelocity: Nullable<Float32Array>;
  80185. /**
  80186. * The linearAcceleration of the device, values in array are [x,y,z].
  80187. */
  80188. readonly linearAcceleration: Nullable<Float32Array>;
  80189. /**
  80190. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  80191. */
  80192. readonly orientation: Nullable<Float32Array>;
  80193. /**
  80194. * The angularVelocity of the device, values in array are [x,y,z].
  80195. */
  80196. readonly angularVelocity: Nullable<Float32Array>;
  80197. /**
  80198. * The angularAcceleration of the device, values in array are [x,y,z].
  80199. */
  80200. readonly angularAcceleration: Nullable<Float32Array>;
  80201. }
  80202. /**
  80203. * Interface representing a pose controlled object in Babylon.
  80204. * A pose controlled object has both regular pose values as well as pose values
  80205. * from an external device such as a VR head mounted display
  80206. */
  80207. export interface PoseControlled {
  80208. /**
  80209. * The position of the object in babylon space.
  80210. */
  80211. position: Vector3;
  80212. /**
  80213. * The rotation quaternion of the object in babylon space.
  80214. */
  80215. rotationQuaternion: Quaternion;
  80216. /**
  80217. * The position of the device in babylon space.
  80218. */
  80219. devicePosition?: Vector3;
  80220. /**
  80221. * The rotation quaternion of the device in babylon space.
  80222. */
  80223. deviceRotationQuaternion: Quaternion;
  80224. /**
  80225. * The raw pose coming from the device.
  80226. */
  80227. rawPose: Nullable<DevicePose>;
  80228. /**
  80229. * The scale of the device to be used when translating from device space to babylon space.
  80230. */
  80231. deviceScaleFactor: number;
  80232. /**
  80233. * Updates the poseControlled values based on the input device pose.
  80234. * @param poseData the pose data to update the object with
  80235. */
  80236. updateFromDevice(poseData: DevicePose): void;
  80237. }
  80238. /**
  80239. * Set of options to customize the webVRCamera
  80240. */
  80241. export interface WebVROptions {
  80242. /**
  80243. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  80244. */
  80245. trackPosition?: boolean;
  80246. /**
  80247. * Sets the scale of the vrDevice in babylon space. (default: 1)
  80248. */
  80249. positionScale?: number;
  80250. /**
  80251. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  80252. */
  80253. displayName?: string;
  80254. /**
  80255. * Should the native controller meshes be initialized. (default: true)
  80256. */
  80257. controllerMeshes?: boolean;
  80258. /**
  80259. * Creating a default HemiLight only on controllers. (default: true)
  80260. */
  80261. defaultLightingOnControllers?: boolean;
  80262. /**
  80263. * If you don't want to use the default VR button of the helper. (default: false)
  80264. */
  80265. useCustomVRButton?: boolean;
  80266. /**
  80267. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  80268. */
  80269. customVRButton?: HTMLButtonElement;
  80270. /**
  80271. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  80272. */
  80273. rayLength?: number;
  80274. /**
  80275. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  80276. */
  80277. defaultHeight?: number;
  80278. /**
  80279. * If multiview should be used if availible (default: false)
  80280. */
  80281. useMultiview?: boolean;
  80282. }
  80283. /**
  80284. * This represents a WebVR camera.
  80285. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  80286. * @example http://doc.babylonjs.com/how_to/webvr_camera
  80287. */
  80288. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  80289. private webVROptions;
  80290. /**
  80291. * @hidden
  80292. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  80293. */
  80294. _vrDevice: any;
  80295. /**
  80296. * The rawPose of the vrDevice.
  80297. */
  80298. rawPose: Nullable<DevicePose>;
  80299. private _onVREnabled;
  80300. private _specsVersion;
  80301. private _attached;
  80302. private _frameData;
  80303. protected _descendants: Array<Node>;
  80304. private _deviceRoomPosition;
  80305. /** @hidden */
  80306. _deviceRoomRotationQuaternion: Quaternion;
  80307. private _standingMatrix;
  80308. /**
  80309. * Represents device position in babylon space.
  80310. */
  80311. devicePosition: Vector3;
  80312. /**
  80313. * Represents device rotation in babylon space.
  80314. */
  80315. deviceRotationQuaternion: Quaternion;
  80316. /**
  80317. * The scale of the device to be used when translating from device space to babylon space.
  80318. */
  80319. deviceScaleFactor: number;
  80320. private _deviceToWorld;
  80321. private _worldToDevice;
  80322. /**
  80323. * References to the webVR controllers for the vrDevice.
  80324. */
  80325. controllers: Array<WebVRController>;
  80326. /**
  80327. * Emits an event when a controller is attached.
  80328. */
  80329. onControllersAttachedObservable: Observable<WebVRController[]>;
  80330. /**
  80331. * Emits an event when a controller's mesh has been loaded;
  80332. */
  80333. onControllerMeshLoadedObservable: Observable<WebVRController>;
  80334. /**
  80335. * Emits an event when the HMD's pose has been updated.
  80336. */
  80337. onPoseUpdatedFromDeviceObservable: Observable<any>;
  80338. private _poseSet;
  80339. /**
  80340. * If the rig cameras be used as parent instead of this camera.
  80341. */
  80342. rigParenting: boolean;
  80343. private _lightOnControllers;
  80344. private _defaultHeight?;
  80345. /**
  80346. * Instantiates a WebVRFreeCamera.
  80347. * @param name The name of the WebVRFreeCamera
  80348. * @param position The starting anchor position for the camera
  80349. * @param scene The scene the camera belongs to
  80350. * @param webVROptions a set of customizable options for the webVRCamera
  80351. */
  80352. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  80353. /**
  80354. * Gets the device distance from the ground in meters.
  80355. * @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.
  80356. */
  80357. deviceDistanceToRoomGround(): number;
  80358. /**
  80359. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80360. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  80361. */
  80362. useStandingMatrix(callback?: (bool: boolean) => void): void;
  80363. /**
  80364. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  80365. * @returns A promise with a boolean set to if the standing matrix is supported.
  80366. */
  80367. useStandingMatrixAsync(): Promise<boolean>;
  80368. /**
  80369. * Disposes the camera
  80370. */
  80371. dispose(): void;
  80372. /**
  80373. * Gets a vrController by name.
  80374. * @param name The name of the controller to retreive
  80375. * @returns the controller matching the name specified or null if not found
  80376. */
  80377. getControllerByName(name: string): Nullable<WebVRController>;
  80378. private _leftController;
  80379. /**
  80380. * The controller corresponding to the users left hand.
  80381. */
  80382. readonly leftController: Nullable<WebVRController>;
  80383. private _rightController;
  80384. /**
  80385. * The controller corresponding to the users right hand.
  80386. */
  80387. readonly rightController: Nullable<WebVRController>;
  80388. /**
  80389. * Casts a ray forward from the vrCamera's gaze.
  80390. * @param length Length of the ray (default: 100)
  80391. * @returns the ray corresponding to the gaze
  80392. */
  80393. getForwardRay(length?: number): Ray;
  80394. /**
  80395. * @hidden
  80396. * Updates the camera based on device's frame data
  80397. */
  80398. _checkInputs(): void;
  80399. /**
  80400. * Updates the poseControlled values based on the input device pose.
  80401. * @param poseData Pose coming from the device
  80402. */
  80403. updateFromDevice(poseData: DevicePose): void;
  80404. private _htmlElementAttached;
  80405. private _detachIfAttached;
  80406. /**
  80407. * WebVR's attach control will start broadcasting frames to the device.
  80408. * Note that in certain browsers (chrome for example) this function must be called
  80409. * within a user-interaction callback. Example:
  80410. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  80411. *
  80412. * @param element html element to attach the vrDevice to
  80413. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  80414. */
  80415. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80416. /**
  80417. * Detaches the camera from the html element and disables VR
  80418. *
  80419. * @param element html element to detach from
  80420. */
  80421. detachControl(element: HTMLElement): void;
  80422. /**
  80423. * @returns the name of this class
  80424. */
  80425. getClassName(): string;
  80426. /**
  80427. * Calls resetPose on the vrDisplay
  80428. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  80429. */
  80430. resetToCurrentRotation(): void;
  80431. /**
  80432. * @hidden
  80433. * Updates the rig cameras (left and right eye)
  80434. */
  80435. _updateRigCameras(): void;
  80436. private _workingVector;
  80437. private _oneVector;
  80438. private _workingMatrix;
  80439. private updateCacheCalled;
  80440. private _correctPositionIfNotTrackPosition;
  80441. /**
  80442. * @hidden
  80443. * Updates the cached values of the camera
  80444. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  80445. */
  80446. _updateCache(ignoreParentClass?: boolean): void;
  80447. /**
  80448. * @hidden
  80449. * Get current device position in babylon world
  80450. */
  80451. _computeDevicePosition(): void;
  80452. /**
  80453. * Updates the current device position and rotation in the babylon world
  80454. */
  80455. update(): void;
  80456. /**
  80457. * @hidden
  80458. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  80459. * @returns an identity matrix
  80460. */
  80461. _getViewMatrix(): Matrix;
  80462. private _tmpMatrix;
  80463. /**
  80464. * This function is called by the two RIG cameras.
  80465. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  80466. * @hidden
  80467. */
  80468. _getWebVRViewMatrix(): Matrix;
  80469. /** @hidden */
  80470. _getWebVRProjectionMatrix(): Matrix;
  80471. private _onGamepadConnectedObserver;
  80472. private _onGamepadDisconnectedObserver;
  80473. private _updateCacheWhenTrackingDisabledObserver;
  80474. /**
  80475. * Initializes the controllers and their meshes
  80476. */
  80477. initControllers(): void;
  80478. }
  80479. }
  80480. declare module BABYLON {
  80481. /**
  80482. * Size options for a post process
  80483. */
  80484. export type PostProcessOptions = {
  80485. width: number;
  80486. height: number;
  80487. };
  80488. /**
  80489. * PostProcess can be used to apply a shader to a texture after it has been rendered
  80490. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  80491. */
  80492. export class PostProcess {
  80493. /** Name of the PostProcess. */
  80494. name: string;
  80495. /**
  80496. * Gets or sets the unique id of the post process
  80497. */
  80498. uniqueId: number;
  80499. /**
  80500. * Width of the texture to apply the post process on
  80501. */
  80502. width: number;
  80503. /**
  80504. * Height of the texture to apply the post process on
  80505. */
  80506. height: number;
  80507. /**
  80508. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  80509. * @hidden
  80510. */
  80511. _outputTexture: Nullable<InternalTexture>;
  80512. /**
  80513. * Sampling mode used by the shader
  80514. * See https://doc.babylonjs.com/classes/3.1/texture
  80515. */
  80516. renderTargetSamplingMode: number;
  80517. /**
  80518. * Clear color to use when screen clearing
  80519. */
  80520. clearColor: Color4;
  80521. /**
  80522. * If the buffer needs to be cleared before applying the post process. (default: true)
  80523. * Should be set to false if shader will overwrite all previous pixels.
  80524. */
  80525. autoClear: boolean;
  80526. /**
  80527. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  80528. */
  80529. alphaMode: number;
  80530. /**
  80531. * Sets the setAlphaBlendConstants of the babylon engine
  80532. */
  80533. alphaConstants: Color4;
  80534. /**
  80535. * Animations to be used for the post processing
  80536. */
  80537. animations: Animation[];
  80538. /**
  80539. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  80540. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  80541. */
  80542. enablePixelPerfectMode: boolean;
  80543. /**
  80544. * Force the postprocess to be applied without taking in account viewport
  80545. */
  80546. forceFullscreenViewport: boolean;
  80547. /**
  80548. * List of inspectable custom properties (used by the Inspector)
  80549. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80550. */
  80551. inspectableCustomProperties: IInspectable[];
  80552. /**
  80553. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  80554. *
  80555. * | Value | Type | Description |
  80556. * | ----- | ----------------------------------- | ----------- |
  80557. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  80558. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  80559. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  80560. *
  80561. */
  80562. scaleMode: number;
  80563. /**
  80564. * Force textures to be a power of two (default: false)
  80565. */
  80566. alwaysForcePOT: boolean;
  80567. private _samples;
  80568. /**
  80569. * Number of sample textures (default: 1)
  80570. */
  80571. samples: number;
  80572. /**
  80573. * Modify the scale of the post process to be the same as the viewport (default: false)
  80574. */
  80575. adaptScaleToCurrentViewport: boolean;
  80576. private _camera;
  80577. private _scene;
  80578. private _engine;
  80579. private _options;
  80580. private _reusable;
  80581. private _textureType;
  80582. /**
  80583. * Smart array of input and output textures for the post process.
  80584. * @hidden
  80585. */
  80586. _textures: SmartArray<InternalTexture>;
  80587. /**
  80588. * The index in _textures that corresponds to the output texture.
  80589. * @hidden
  80590. */
  80591. _currentRenderTextureInd: number;
  80592. private _effect;
  80593. private _samplers;
  80594. private _fragmentUrl;
  80595. private _vertexUrl;
  80596. private _parameters;
  80597. private _scaleRatio;
  80598. protected _indexParameters: any;
  80599. private _shareOutputWithPostProcess;
  80600. private _texelSize;
  80601. private _forcedOutputTexture;
  80602. /**
  80603. * Returns the fragment url or shader name used in the post process.
  80604. * @returns the fragment url or name in the shader store.
  80605. */
  80606. getEffectName(): string;
  80607. /**
  80608. * An event triggered when the postprocess is activated.
  80609. */
  80610. onActivateObservable: Observable<Camera>;
  80611. private _onActivateObserver;
  80612. /**
  80613. * A function that is added to the onActivateObservable
  80614. */
  80615. onActivate: Nullable<(camera: Camera) => void>;
  80616. /**
  80617. * An event triggered when the postprocess changes its size.
  80618. */
  80619. onSizeChangedObservable: Observable<PostProcess>;
  80620. private _onSizeChangedObserver;
  80621. /**
  80622. * A function that is added to the onSizeChangedObservable
  80623. */
  80624. onSizeChanged: (postProcess: PostProcess) => void;
  80625. /**
  80626. * An event triggered when the postprocess applies its effect.
  80627. */
  80628. onApplyObservable: Observable<Effect>;
  80629. private _onApplyObserver;
  80630. /**
  80631. * A function that is added to the onApplyObservable
  80632. */
  80633. onApply: (effect: Effect) => void;
  80634. /**
  80635. * An event triggered before rendering the postprocess
  80636. */
  80637. onBeforeRenderObservable: Observable<Effect>;
  80638. private _onBeforeRenderObserver;
  80639. /**
  80640. * A function that is added to the onBeforeRenderObservable
  80641. */
  80642. onBeforeRender: (effect: Effect) => void;
  80643. /**
  80644. * An event triggered after rendering the postprocess
  80645. */
  80646. onAfterRenderObservable: Observable<Effect>;
  80647. private _onAfterRenderObserver;
  80648. /**
  80649. * A function that is added to the onAfterRenderObservable
  80650. */
  80651. onAfterRender: (efect: Effect) => void;
  80652. /**
  80653. * 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
  80654. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  80655. */
  80656. inputTexture: InternalTexture;
  80657. /**
  80658. * Gets the camera which post process is applied to.
  80659. * @returns The camera the post process is applied to.
  80660. */
  80661. getCamera(): Camera;
  80662. /**
  80663. * Gets the texel size of the postprocess.
  80664. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  80665. */
  80666. readonly texelSize: Vector2;
  80667. /**
  80668. * Creates a new instance PostProcess
  80669. * @param name The name of the PostProcess.
  80670. * @param fragmentUrl The url of the fragment shader to be used.
  80671. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  80672. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  80673. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  80674. * @param camera The camera to apply the render pass to.
  80675. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  80676. * @param engine The engine which the post process will be applied. (default: current engine)
  80677. * @param reusable If the post process can be reused on the same frame. (default: false)
  80678. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  80679. * @param textureType Type of textures used when performing the post process. (default: 0)
  80680. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  80681. * @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
  80682. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  80683. */
  80684. constructor(
  80685. /** Name of the PostProcess. */
  80686. 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);
  80687. /**
  80688. * Gets a string idenfifying the name of the class
  80689. * @returns "PostProcess" string
  80690. */
  80691. getClassName(): string;
  80692. /**
  80693. * Gets the engine which this post process belongs to.
  80694. * @returns The engine the post process was enabled with.
  80695. */
  80696. getEngine(): Engine;
  80697. /**
  80698. * The effect that is created when initializing the post process.
  80699. * @returns The created effect corresponding the the postprocess.
  80700. */
  80701. getEffect(): Effect;
  80702. /**
  80703. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  80704. * @param postProcess The post process to share the output with.
  80705. * @returns This post process.
  80706. */
  80707. shareOutputWith(postProcess: PostProcess): PostProcess;
  80708. /**
  80709. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  80710. * This should be called if the post process that shares output with this post process is disabled/disposed.
  80711. */
  80712. useOwnOutput(): void;
  80713. /**
  80714. * Updates the effect with the current post process compile time values and recompiles the shader.
  80715. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  80716. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  80717. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  80718. * @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
  80719. * @param onCompiled Called when the shader has been compiled.
  80720. * @param onError Called if there is an error when compiling a shader.
  80721. */
  80722. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80723. /**
  80724. * The post process is reusable if it can be used multiple times within one frame.
  80725. * @returns If the post process is reusable
  80726. */
  80727. isReusable(): boolean;
  80728. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  80729. markTextureDirty(): void;
  80730. /**
  80731. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  80732. * 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.
  80733. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  80734. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  80735. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  80736. * @returns The target texture that was bound to be written to.
  80737. */
  80738. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  80739. /**
  80740. * If the post process is supported.
  80741. */
  80742. readonly isSupported: boolean;
  80743. /**
  80744. * The aspect ratio of the output texture.
  80745. */
  80746. readonly aspectRatio: number;
  80747. /**
  80748. * Get a value indicating if the post-process is ready to be used
  80749. * @returns true if the post-process is ready (shader is compiled)
  80750. */
  80751. isReady(): boolean;
  80752. /**
  80753. * Binds all textures and uniforms to the shader, this will be run on every pass.
  80754. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  80755. */
  80756. apply(): Nullable<Effect>;
  80757. private _disposeTextures;
  80758. /**
  80759. * Disposes the post process.
  80760. * @param camera The camera to dispose the post process on.
  80761. */
  80762. dispose(camera?: Camera): void;
  80763. }
  80764. }
  80765. declare module BABYLON {
  80766. /** @hidden */
  80767. export var kernelBlurVaryingDeclaration: {
  80768. name: string;
  80769. shader: string;
  80770. };
  80771. }
  80772. declare module BABYLON {
  80773. /** @hidden */
  80774. export var kernelBlurFragment: {
  80775. name: string;
  80776. shader: string;
  80777. };
  80778. }
  80779. declare module BABYLON {
  80780. /** @hidden */
  80781. export var kernelBlurFragment2: {
  80782. name: string;
  80783. shader: string;
  80784. };
  80785. }
  80786. declare module BABYLON {
  80787. /** @hidden */
  80788. export var kernelBlurPixelShader: {
  80789. name: string;
  80790. shader: string;
  80791. };
  80792. }
  80793. declare module BABYLON {
  80794. /** @hidden */
  80795. export var kernelBlurVertex: {
  80796. name: string;
  80797. shader: string;
  80798. };
  80799. }
  80800. declare module BABYLON {
  80801. /** @hidden */
  80802. export var kernelBlurVertexShader: {
  80803. name: string;
  80804. shader: string;
  80805. };
  80806. }
  80807. declare module BABYLON {
  80808. /**
  80809. * The Blur Post Process which blurs an image based on a kernel and direction.
  80810. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  80811. */
  80812. export class BlurPostProcess extends PostProcess {
  80813. /** The direction in which to blur the image. */
  80814. direction: Vector2;
  80815. private blockCompilation;
  80816. protected _kernel: number;
  80817. protected _idealKernel: number;
  80818. protected _packedFloat: boolean;
  80819. private _staticDefines;
  80820. /**
  80821. * Sets the length in pixels of the blur sample region
  80822. */
  80823. /**
  80824. * Gets the length in pixels of the blur sample region
  80825. */
  80826. kernel: number;
  80827. /**
  80828. * Sets wether or not the blur needs to unpack/repack floats
  80829. */
  80830. /**
  80831. * Gets wether or not the blur is unpacking/repacking floats
  80832. */
  80833. packedFloat: boolean;
  80834. /**
  80835. * Creates a new instance BlurPostProcess
  80836. * @param name The name of the effect.
  80837. * @param direction The direction in which to blur the image.
  80838. * @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.
  80839. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  80840. * @param camera The camera to apply the render pass to.
  80841. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  80842. * @param engine The engine which the post process will be applied. (default: current engine)
  80843. * @param reusable If the post process can be reused on the same frame. (default: false)
  80844. * @param textureType Type of textures used when performing the post process. (default: 0)
  80845. * @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)
  80846. */
  80847. constructor(name: string,
  80848. /** The direction in which to blur the image. */
  80849. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  80850. /**
  80851. * Updates the effect with the current post process compile time values and recompiles the shader.
  80852. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  80853. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  80854. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  80855. * @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
  80856. * @param onCompiled Called when the shader has been compiled.
  80857. * @param onError Called if there is an error when compiling a shader.
  80858. */
  80859. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80860. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  80861. /**
  80862. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  80863. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  80864. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  80865. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  80866. * The gaps between physical kernels are compensated for in the weighting of the samples
  80867. * @param idealKernel Ideal blur kernel.
  80868. * @return Nearest best kernel.
  80869. */
  80870. protected _nearestBestKernel(idealKernel: number): number;
  80871. /**
  80872. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  80873. * @param x The point on the Gaussian distribution to sample.
  80874. * @return the value of the Gaussian function at x.
  80875. */
  80876. protected _gaussianWeight(x: number): number;
  80877. /**
  80878. * Generates a string that can be used as a floating point number in GLSL.
  80879. * @param x Value to print.
  80880. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  80881. * @return GLSL float string.
  80882. */
  80883. protected _glslFloat(x: number, decimalFigures?: number): string;
  80884. }
  80885. }
  80886. declare module BABYLON {
  80887. /**
  80888. * Mirror texture can be used to simulate the view from a mirror in a scene.
  80889. * It will dynamically be rendered every frame to adapt to the camera point of view.
  80890. * You can then easily use it as a reflectionTexture on a flat surface.
  80891. * In case the surface is not a plane, please consider relying on reflection probes.
  80892. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80893. */
  80894. export class MirrorTexture extends RenderTargetTexture {
  80895. private scene;
  80896. /**
  80897. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  80898. * 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.
  80899. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80900. */
  80901. mirrorPlane: Plane;
  80902. /**
  80903. * Define the blur ratio used to blur the reflection if needed.
  80904. */
  80905. blurRatio: number;
  80906. /**
  80907. * Define the adaptive blur kernel used to blur the reflection if needed.
  80908. * This will autocompute the closest best match for the `blurKernel`
  80909. */
  80910. adaptiveBlurKernel: number;
  80911. /**
  80912. * Define the blur kernel used to blur the reflection if needed.
  80913. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80914. */
  80915. blurKernel: number;
  80916. /**
  80917. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  80918. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80919. */
  80920. blurKernelX: number;
  80921. /**
  80922. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  80923. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80924. */
  80925. blurKernelY: number;
  80926. private _autoComputeBlurKernel;
  80927. protected _onRatioRescale(): void;
  80928. private _updateGammaSpace;
  80929. private _imageProcessingConfigChangeObserver;
  80930. private _transformMatrix;
  80931. private _mirrorMatrix;
  80932. private _savedViewMatrix;
  80933. private _blurX;
  80934. private _blurY;
  80935. private _adaptiveBlurKernel;
  80936. private _blurKernelX;
  80937. private _blurKernelY;
  80938. private _blurRatio;
  80939. /**
  80940. * Instantiates a Mirror Texture.
  80941. * Mirror texture can be used to simulate the view from a mirror in a scene.
  80942. * It will dynamically be rendered every frame to adapt to the camera point of view.
  80943. * You can then easily use it as a reflectionTexture on a flat surface.
  80944. * In case the surface is not a plane, please consider relying on reflection probes.
  80945. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80946. * @param name
  80947. * @param size
  80948. * @param scene
  80949. * @param generateMipMaps
  80950. * @param type
  80951. * @param samplingMode
  80952. * @param generateDepthBuffer
  80953. */
  80954. constructor(name: string, size: number | {
  80955. width: number;
  80956. height: number;
  80957. } | {
  80958. ratio: number;
  80959. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  80960. private _preparePostProcesses;
  80961. /**
  80962. * Clone the mirror texture.
  80963. * @returns the cloned texture
  80964. */
  80965. clone(): MirrorTexture;
  80966. /**
  80967. * Serialize the texture to a JSON representation you could use in Parse later on
  80968. * @returns the serialized JSON representation
  80969. */
  80970. serialize(): any;
  80971. /**
  80972. * Dispose the texture and release its associated resources.
  80973. */
  80974. dispose(): void;
  80975. }
  80976. }
  80977. declare module BABYLON {
  80978. /**
  80979. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  80980. * @see http://doc.babylonjs.com/babylon101/materials#texture
  80981. */
  80982. export class Texture extends BaseTexture {
  80983. /** @hidden */
  80984. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  80985. /** @hidden */
  80986. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  80987. /** @hidden */
  80988. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  80989. /** nearest is mag = nearest and min = nearest and mip = linear */
  80990. static readonly NEAREST_SAMPLINGMODE: number;
  80991. /** nearest is mag = nearest and min = nearest and mip = linear */
  80992. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  80993. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80994. static readonly BILINEAR_SAMPLINGMODE: number;
  80995. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80996. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  80997. /** Trilinear is mag = linear and min = linear and mip = linear */
  80998. static readonly TRILINEAR_SAMPLINGMODE: number;
  80999. /** Trilinear is mag = linear and min = linear and mip = linear */
  81000. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  81001. /** mag = nearest and min = nearest and mip = nearest */
  81002. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  81003. /** mag = nearest and min = linear and mip = nearest */
  81004. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  81005. /** mag = nearest and min = linear and mip = linear */
  81006. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  81007. /** mag = nearest and min = linear and mip = none */
  81008. static readonly NEAREST_LINEAR: number;
  81009. /** mag = nearest and min = nearest and mip = none */
  81010. static readonly NEAREST_NEAREST: number;
  81011. /** mag = linear and min = nearest and mip = nearest */
  81012. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  81013. /** mag = linear and min = nearest and mip = linear */
  81014. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  81015. /** mag = linear and min = linear and mip = none */
  81016. static readonly LINEAR_LINEAR: number;
  81017. /** mag = linear and min = nearest and mip = none */
  81018. static readonly LINEAR_NEAREST: number;
  81019. /** Explicit coordinates mode */
  81020. static readonly EXPLICIT_MODE: number;
  81021. /** Spherical coordinates mode */
  81022. static readonly SPHERICAL_MODE: number;
  81023. /** Planar coordinates mode */
  81024. static readonly PLANAR_MODE: number;
  81025. /** Cubic coordinates mode */
  81026. static readonly CUBIC_MODE: number;
  81027. /** Projection coordinates mode */
  81028. static readonly PROJECTION_MODE: number;
  81029. /** Inverse Cubic coordinates mode */
  81030. static readonly SKYBOX_MODE: number;
  81031. /** Inverse Cubic coordinates mode */
  81032. static readonly INVCUBIC_MODE: number;
  81033. /** Equirectangular coordinates mode */
  81034. static readonly EQUIRECTANGULAR_MODE: number;
  81035. /** Equirectangular Fixed coordinates mode */
  81036. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  81037. /** Equirectangular Fixed Mirrored coordinates mode */
  81038. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81039. /** Texture is not repeating outside of 0..1 UVs */
  81040. static readonly CLAMP_ADDRESSMODE: number;
  81041. /** Texture is repeating outside of 0..1 UVs */
  81042. static readonly WRAP_ADDRESSMODE: number;
  81043. /** Texture is repeating and mirrored */
  81044. static readonly MIRROR_ADDRESSMODE: number;
  81045. /**
  81046. * 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
  81047. */
  81048. static UseSerializedUrlIfAny: boolean;
  81049. /**
  81050. * Define the url of the texture.
  81051. */
  81052. url: Nullable<string>;
  81053. /**
  81054. * Define an offset on the texture to offset the u coordinates of the UVs
  81055. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81056. */
  81057. uOffset: number;
  81058. /**
  81059. * Define an offset on the texture to offset the v coordinates of the UVs
  81060. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  81061. */
  81062. vOffset: number;
  81063. /**
  81064. * Define an offset on the texture to scale the u coordinates of the UVs
  81065. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81066. */
  81067. uScale: number;
  81068. /**
  81069. * Define an offset on the texture to scale the v coordinates of the UVs
  81070. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  81071. */
  81072. vScale: number;
  81073. /**
  81074. * Define an offset on the texture to rotate around the u coordinates of the UVs
  81075. * @see http://doc.babylonjs.com/how_to/more_materials
  81076. */
  81077. uAng: number;
  81078. /**
  81079. * Define an offset on the texture to rotate around the v coordinates of the UVs
  81080. * @see http://doc.babylonjs.com/how_to/more_materials
  81081. */
  81082. vAng: number;
  81083. /**
  81084. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  81085. * @see http://doc.babylonjs.com/how_to/more_materials
  81086. */
  81087. wAng: number;
  81088. /**
  81089. * Defines the center of rotation (U)
  81090. */
  81091. uRotationCenter: number;
  81092. /**
  81093. * Defines the center of rotation (V)
  81094. */
  81095. vRotationCenter: number;
  81096. /**
  81097. * Defines the center of rotation (W)
  81098. */
  81099. wRotationCenter: number;
  81100. /**
  81101. * Are mip maps generated for this texture or not.
  81102. */
  81103. readonly noMipmap: boolean;
  81104. /**
  81105. * List of inspectable custom properties (used by the Inspector)
  81106. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81107. */
  81108. inspectableCustomProperties: Nullable<IInspectable[]>;
  81109. private _noMipmap;
  81110. /** @hidden */
  81111. _invertY: boolean;
  81112. private _rowGenerationMatrix;
  81113. private _cachedTextureMatrix;
  81114. private _projectionModeMatrix;
  81115. private _t0;
  81116. private _t1;
  81117. private _t2;
  81118. private _cachedUOffset;
  81119. private _cachedVOffset;
  81120. private _cachedUScale;
  81121. private _cachedVScale;
  81122. private _cachedUAng;
  81123. private _cachedVAng;
  81124. private _cachedWAng;
  81125. private _cachedProjectionMatrixId;
  81126. private _cachedCoordinatesMode;
  81127. /** @hidden */
  81128. protected _initialSamplingMode: number;
  81129. /** @hidden */
  81130. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  81131. private _deleteBuffer;
  81132. protected _format: Nullable<number>;
  81133. private _delayedOnLoad;
  81134. private _delayedOnError;
  81135. /**
  81136. * Observable triggered once the texture has been loaded.
  81137. */
  81138. onLoadObservable: Observable<Texture>;
  81139. protected _isBlocking: boolean;
  81140. /**
  81141. * Is the texture preventing material to render while loading.
  81142. * If false, a default texture will be used instead of the loading one during the preparation step.
  81143. */
  81144. isBlocking: boolean;
  81145. /**
  81146. * Get the current sampling mode associated with the texture.
  81147. */
  81148. readonly samplingMode: number;
  81149. /**
  81150. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  81151. */
  81152. readonly invertY: boolean;
  81153. /**
  81154. * Instantiates a new texture.
  81155. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  81156. * @see http://doc.babylonjs.com/babylon101/materials#texture
  81157. * @param url define the url of the picture to load as a texture
  81158. * @param scene define the scene or engine the texture will belong to
  81159. * @param noMipmap define if the texture will require mip maps or not
  81160. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81161. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81162. * @param onLoad define a callback triggered when the texture has been loaded
  81163. * @param onError define a callback triggered when an error occurred during the loading session
  81164. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81165. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81166. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81167. */
  81168. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | Engine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  81169. /**
  81170. * Update the url (and optional buffer) of this texture if url was null during construction.
  81171. * @param url the url of the texture
  81172. * @param buffer the buffer of the texture (defaults to null)
  81173. * @param onLoad callback called when the texture is loaded (defaults to null)
  81174. */
  81175. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  81176. /**
  81177. * Finish the loading sequence of a texture flagged as delayed load.
  81178. * @hidden
  81179. */
  81180. delayLoad(): void;
  81181. private _prepareRowForTextureGeneration;
  81182. /**
  81183. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  81184. * @returns the transform matrix of the texture.
  81185. */
  81186. getTextureMatrix(): Matrix;
  81187. /**
  81188. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  81189. * @returns The reflection texture transform
  81190. */
  81191. getReflectionTextureMatrix(): Matrix;
  81192. /**
  81193. * Clones the texture.
  81194. * @returns the cloned texture
  81195. */
  81196. clone(): Texture;
  81197. /**
  81198. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  81199. * @returns The JSON representation of the texture
  81200. */
  81201. serialize(): any;
  81202. /**
  81203. * Get the current class name of the texture useful for serialization or dynamic coding.
  81204. * @returns "Texture"
  81205. */
  81206. getClassName(): string;
  81207. /**
  81208. * Dispose the texture and release its associated resources.
  81209. */
  81210. dispose(): void;
  81211. /**
  81212. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  81213. * @param parsedTexture Define the JSON representation of the texture
  81214. * @param scene Define the scene the parsed texture should be instantiated in
  81215. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  81216. * @returns The parsed texture if successful
  81217. */
  81218. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  81219. /**
  81220. * Creates a texture from its base 64 representation.
  81221. * @param data Define the base64 payload without the data: prefix
  81222. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81223. * @param scene Define the scene the texture should belong to
  81224. * @param noMipmap Forces the texture to not create mip map information if true
  81225. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81226. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81227. * @param onLoad define a callback triggered when the texture has been loaded
  81228. * @param onError define a callback triggered when an error occurred during the loading session
  81229. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81230. * @returns the created texture
  81231. */
  81232. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  81233. /**
  81234. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  81235. * @param data Define the base64 payload without the data: prefix
  81236. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  81237. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  81238. * @param scene Define the scene the texture should belong to
  81239. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  81240. * @param noMipmap Forces the texture to not create mip map information if true
  81241. * @param invertY define if the texture needs to be inverted on the y axis during loading
  81242. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  81243. * @param onLoad define a callback triggered when the texture has been loaded
  81244. * @param onError define a callback triggered when an error occurred during the loading session
  81245. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  81246. * @returns the created texture
  81247. */
  81248. 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;
  81249. }
  81250. }
  81251. declare module BABYLON {
  81252. /**
  81253. * PostProcessManager is used to manage one or more post processes or post process pipelines
  81254. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  81255. */
  81256. export class PostProcessManager {
  81257. private _scene;
  81258. private _indexBuffer;
  81259. private _vertexBuffers;
  81260. /**
  81261. * Creates a new instance PostProcess
  81262. * @param scene The scene that the post process is associated with.
  81263. */
  81264. constructor(scene: Scene);
  81265. private _prepareBuffers;
  81266. private _buildIndexBuffer;
  81267. /**
  81268. * Rebuilds the vertex buffers of the manager.
  81269. * @hidden
  81270. */
  81271. _rebuild(): void;
  81272. /**
  81273. * Prepares a frame to be run through a post process.
  81274. * @param sourceTexture The input texture to the post procesess. (default: null)
  81275. * @param postProcesses An array of post processes to be run. (default: null)
  81276. * @returns True if the post processes were able to be run.
  81277. * @hidden
  81278. */
  81279. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  81280. /**
  81281. * Manually render a set of post processes to a texture.
  81282. * @param postProcesses An array of post processes to be run.
  81283. * @param targetTexture The target texture to render to.
  81284. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  81285. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  81286. * @param lodLevel defines which lod of the texture to render to
  81287. */
  81288. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  81289. /**
  81290. * Finalize the result of the output of the postprocesses.
  81291. * @param doNotPresent If true the result will not be displayed to the screen.
  81292. * @param targetTexture The target texture to render to.
  81293. * @param faceIndex The index of the face to bind the target texture to.
  81294. * @param postProcesses The array of post processes to render.
  81295. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  81296. * @hidden
  81297. */
  81298. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  81299. /**
  81300. * Disposes of the post process manager.
  81301. */
  81302. dispose(): void;
  81303. }
  81304. }
  81305. declare module BABYLON {
  81306. interface AbstractScene {
  81307. /**
  81308. * The list of procedural textures added to the scene
  81309. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81310. */
  81311. proceduralTextures: Array<ProceduralTexture>;
  81312. }
  81313. /**
  81314. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  81315. * in a given scene.
  81316. */
  81317. export class ProceduralTextureSceneComponent implements ISceneComponent {
  81318. /**
  81319. * The component name helpfull to identify the component in the list of scene components.
  81320. */
  81321. readonly name: string;
  81322. /**
  81323. * The scene the component belongs to.
  81324. */
  81325. scene: Scene;
  81326. /**
  81327. * Creates a new instance of the component for the given scene
  81328. * @param scene Defines the scene to register the component in
  81329. */
  81330. constructor(scene: Scene);
  81331. /**
  81332. * Registers the component in a given scene
  81333. */
  81334. register(): void;
  81335. /**
  81336. * Rebuilds the elements related to this component in case of
  81337. * context lost for instance.
  81338. */
  81339. rebuild(): void;
  81340. /**
  81341. * Disposes the component and the associated ressources.
  81342. */
  81343. dispose(): void;
  81344. private _beforeClear;
  81345. }
  81346. }
  81347. declare module BABYLON {
  81348. interface Engine {
  81349. /**
  81350. * Creates a new render target cube texture
  81351. * @param size defines the size of the texture
  81352. * @param options defines the options used to create the texture
  81353. * @returns a new render target cube texture stored in an InternalTexture
  81354. */
  81355. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  81356. }
  81357. }
  81358. declare module BABYLON {
  81359. /** @hidden */
  81360. export var proceduralVertexShader: {
  81361. name: string;
  81362. shader: string;
  81363. };
  81364. }
  81365. declare module BABYLON {
  81366. /**
  81367. * 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.
  81368. * This is the base class of any Procedural texture and contains most of the shareable code.
  81369. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81370. */
  81371. export class ProceduralTexture extends Texture {
  81372. isCube: boolean;
  81373. /**
  81374. * Define if the texture is enabled or not (disabled texture will not render)
  81375. */
  81376. isEnabled: boolean;
  81377. /**
  81378. * Define if the texture must be cleared before rendering (default is true)
  81379. */
  81380. autoClear: boolean;
  81381. /**
  81382. * Callback called when the texture is generated
  81383. */
  81384. onGenerated: () => void;
  81385. /**
  81386. * Event raised when the texture is generated
  81387. */
  81388. onGeneratedObservable: Observable<ProceduralTexture>;
  81389. /** @hidden */
  81390. _generateMipMaps: boolean;
  81391. /** @hidden **/
  81392. _effect: Effect;
  81393. /** @hidden */
  81394. _textures: {
  81395. [key: string]: Texture;
  81396. };
  81397. private _size;
  81398. private _currentRefreshId;
  81399. private _refreshRate;
  81400. private _vertexBuffers;
  81401. private _indexBuffer;
  81402. private _uniforms;
  81403. private _samplers;
  81404. private _fragment;
  81405. private _floats;
  81406. private _ints;
  81407. private _floatsArrays;
  81408. private _colors3;
  81409. private _colors4;
  81410. private _vectors2;
  81411. private _vectors3;
  81412. private _matrices;
  81413. private _fallbackTexture;
  81414. private _fallbackTextureUsed;
  81415. private _engine;
  81416. private _cachedDefines;
  81417. private _contentUpdateId;
  81418. private _contentData;
  81419. /**
  81420. * Instantiates a new procedural texture.
  81421. * 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.
  81422. * This is the base class of any Procedural texture and contains most of the shareable code.
  81423. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  81424. * @param name Define the name of the texture
  81425. * @param size Define the size of the texture to create
  81426. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  81427. * @param scene Define the scene the texture belongs to
  81428. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  81429. * @param generateMipMaps Define if the texture should creates mip maps or not
  81430. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  81431. */
  81432. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  81433. /**
  81434. * The effect that is created when initializing the post process.
  81435. * @returns The created effect corresponding the the postprocess.
  81436. */
  81437. getEffect(): Effect;
  81438. /**
  81439. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  81440. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  81441. */
  81442. getContent(): Nullable<ArrayBufferView>;
  81443. private _createIndexBuffer;
  81444. /** @hidden */
  81445. _rebuild(): void;
  81446. /**
  81447. * Resets the texture in order to recreate its associated resources.
  81448. * This can be called in case of context loss
  81449. */
  81450. reset(): void;
  81451. protected _getDefines(): string;
  81452. /**
  81453. * Is the texture ready to be used ? (rendered at least once)
  81454. * @returns true if ready, otherwise, false.
  81455. */
  81456. isReady(): boolean;
  81457. /**
  81458. * Resets the refresh counter of the texture and start bak from scratch.
  81459. * Could be useful to regenerate the texture if it is setup to render only once.
  81460. */
  81461. resetRefreshCounter(): void;
  81462. /**
  81463. * Set the fragment shader to use in order to render the texture.
  81464. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  81465. */
  81466. setFragment(fragment: any): void;
  81467. /**
  81468. * Define the refresh rate of the texture or the rendering frequency.
  81469. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  81470. */
  81471. refreshRate: number;
  81472. /** @hidden */
  81473. _shouldRender(): boolean;
  81474. /**
  81475. * Get the size the texture is rendering at.
  81476. * @returns the size (texture is always squared)
  81477. */
  81478. getRenderSize(): number;
  81479. /**
  81480. * Resize the texture to new value.
  81481. * @param size Define the new size the texture should have
  81482. * @param generateMipMaps Define whether the new texture should create mip maps
  81483. */
  81484. resize(size: number, generateMipMaps: boolean): void;
  81485. private _checkUniform;
  81486. /**
  81487. * Set a texture in the shader program used to render.
  81488. * @param name Define the name of the uniform samplers as defined in the shader
  81489. * @param texture Define the texture to bind to this sampler
  81490. * @return the texture itself allowing "fluent" like uniform updates
  81491. */
  81492. setTexture(name: string, texture: Texture): ProceduralTexture;
  81493. /**
  81494. * Set a float in the shader.
  81495. * @param name Define the name of the uniform as defined in the shader
  81496. * @param value Define the value to give to the uniform
  81497. * @return the texture itself allowing "fluent" like uniform updates
  81498. */
  81499. setFloat(name: string, value: number): ProceduralTexture;
  81500. /**
  81501. * Set a int in the shader.
  81502. * @param name Define the name of the uniform as defined in the shader
  81503. * @param value Define the value to give to the uniform
  81504. * @return the texture itself allowing "fluent" like uniform updates
  81505. */
  81506. setInt(name: string, value: number): ProceduralTexture;
  81507. /**
  81508. * Set an array of floats in the shader.
  81509. * @param name Define the name of the uniform as defined in the shader
  81510. * @param value Define the value to give to the uniform
  81511. * @return the texture itself allowing "fluent" like uniform updates
  81512. */
  81513. setFloats(name: string, value: number[]): ProceduralTexture;
  81514. /**
  81515. * Set a vec3 in the shader from a Color3.
  81516. * @param name Define the name of the uniform as defined in the shader
  81517. * @param value Define the value to give to the uniform
  81518. * @return the texture itself allowing "fluent" like uniform updates
  81519. */
  81520. setColor3(name: string, value: Color3): ProceduralTexture;
  81521. /**
  81522. * Set a vec4 in the shader from a Color4.
  81523. * @param name Define the name of the uniform as defined in the shader
  81524. * @param value Define the value to give to the uniform
  81525. * @return the texture itself allowing "fluent" like uniform updates
  81526. */
  81527. setColor4(name: string, value: Color4): ProceduralTexture;
  81528. /**
  81529. * Set a vec2 in the shader from a Vector2.
  81530. * @param name Define the name of the uniform as defined in the shader
  81531. * @param value Define the value to give to the uniform
  81532. * @return the texture itself allowing "fluent" like uniform updates
  81533. */
  81534. setVector2(name: string, value: Vector2): ProceduralTexture;
  81535. /**
  81536. * Set a vec3 in the shader from a Vector3.
  81537. * @param name Define the name of the uniform as defined in the shader
  81538. * @param value Define the value to give to the uniform
  81539. * @return the texture itself allowing "fluent" like uniform updates
  81540. */
  81541. setVector3(name: string, value: Vector3): ProceduralTexture;
  81542. /**
  81543. * Set a mat4 in the shader from a MAtrix.
  81544. * @param name Define the name of the uniform as defined in the shader
  81545. * @param value Define the value to give to the uniform
  81546. * @return the texture itself allowing "fluent" like uniform updates
  81547. */
  81548. setMatrix(name: string, value: Matrix): ProceduralTexture;
  81549. /**
  81550. * Render the texture to its associated render target.
  81551. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  81552. */
  81553. render(useCameraPostProcess?: boolean): void;
  81554. /**
  81555. * Clone the texture.
  81556. * @returns the cloned texture
  81557. */
  81558. clone(): ProceduralTexture;
  81559. /**
  81560. * Dispose the texture and release its asoociated resources.
  81561. */
  81562. dispose(): void;
  81563. }
  81564. }
  81565. declare module BABYLON {
  81566. /**
  81567. * This represents the base class for particle system in Babylon.
  81568. * 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.
  81569. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  81570. * @example https://doc.babylonjs.com/babylon101/particles
  81571. */
  81572. export class BaseParticleSystem {
  81573. /**
  81574. * Source color is added to the destination color without alpha affecting the result
  81575. */
  81576. static BLENDMODE_ONEONE: number;
  81577. /**
  81578. * Blend current color and particle color using particle’s alpha
  81579. */
  81580. static BLENDMODE_STANDARD: number;
  81581. /**
  81582. * Add current color and particle color multiplied by particle’s alpha
  81583. */
  81584. static BLENDMODE_ADD: number;
  81585. /**
  81586. * Multiply current color with particle color
  81587. */
  81588. static BLENDMODE_MULTIPLY: number;
  81589. /**
  81590. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  81591. */
  81592. static BLENDMODE_MULTIPLYADD: number;
  81593. /**
  81594. * List of animations used by the particle system.
  81595. */
  81596. animations: Animation[];
  81597. /**
  81598. * The id of the Particle system.
  81599. */
  81600. id: string;
  81601. /**
  81602. * The friendly name of the Particle system.
  81603. */
  81604. name: string;
  81605. /**
  81606. * The rendering group used by the Particle system to chose when to render.
  81607. */
  81608. renderingGroupId: number;
  81609. /**
  81610. * The emitter represents the Mesh or position we are attaching the particle system to.
  81611. */
  81612. emitter: Nullable<AbstractMesh | Vector3>;
  81613. /**
  81614. * The maximum number of particles to emit per frame
  81615. */
  81616. emitRate: number;
  81617. /**
  81618. * If you want to launch only a few particles at once, that can be done, as well.
  81619. */
  81620. manualEmitCount: number;
  81621. /**
  81622. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  81623. */
  81624. updateSpeed: number;
  81625. /**
  81626. * The amount of time the particle system is running (depends of the overall update speed).
  81627. */
  81628. targetStopDuration: number;
  81629. /**
  81630. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  81631. */
  81632. disposeOnStop: boolean;
  81633. /**
  81634. * Minimum power of emitting particles.
  81635. */
  81636. minEmitPower: number;
  81637. /**
  81638. * Maximum power of emitting particles.
  81639. */
  81640. maxEmitPower: number;
  81641. /**
  81642. * Minimum life time of emitting particles.
  81643. */
  81644. minLifeTime: number;
  81645. /**
  81646. * Maximum life time of emitting particles.
  81647. */
  81648. maxLifeTime: number;
  81649. /**
  81650. * Minimum Size of emitting particles.
  81651. */
  81652. minSize: number;
  81653. /**
  81654. * Maximum Size of emitting particles.
  81655. */
  81656. maxSize: number;
  81657. /**
  81658. * Minimum scale of emitting particles on X axis.
  81659. */
  81660. minScaleX: number;
  81661. /**
  81662. * Maximum scale of emitting particles on X axis.
  81663. */
  81664. maxScaleX: number;
  81665. /**
  81666. * Minimum scale of emitting particles on Y axis.
  81667. */
  81668. minScaleY: number;
  81669. /**
  81670. * Maximum scale of emitting particles on Y axis.
  81671. */
  81672. maxScaleY: number;
  81673. /**
  81674. * Gets or sets the minimal initial rotation in radians.
  81675. */
  81676. minInitialRotation: number;
  81677. /**
  81678. * Gets or sets the maximal initial rotation in radians.
  81679. */
  81680. maxInitialRotation: number;
  81681. /**
  81682. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  81683. */
  81684. minAngularSpeed: number;
  81685. /**
  81686. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  81687. */
  81688. maxAngularSpeed: number;
  81689. /**
  81690. * The texture used to render each particle. (this can be a spritesheet)
  81691. */
  81692. particleTexture: Nullable<Texture>;
  81693. /**
  81694. * The layer mask we are rendering the particles through.
  81695. */
  81696. layerMask: number;
  81697. /**
  81698. * This can help using your own shader to render the particle system.
  81699. * The according effect will be created
  81700. */
  81701. customShader: any;
  81702. /**
  81703. * By default particle system starts as soon as they are created. This prevents the
  81704. * automatic start to happen and let you decide when to start emitting particles.
  81705. */
  81706. preventAutoStart: boolean;
  81707. private _noiseTexture;
  81708. /**
  81709. * Gets or sets a texture used to add random noise to particle positions
  81710. */
  81711. noiseTexture: Nullable<ProceduralTexture>;
  81712. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  81713. noiseStrength: Vector3;
  81714. /**
  81715. * Callback triggered when the particle animation is ending.
  81716. */
  81717. onAnimationEnd: Nullable<() => void>;
  81718. /**
  81719. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  81720. */
  81721. blendMode: number;
  81722. /**
  81723. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  81724. * to override the particles.
  81725. */
  81726. forceDepthWrite: boolean;
  81727. /** 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 */
  81728. preWarmCycles: number;
  81729. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  81730. preWarmStepOffset: number;
  81731. /**
  81732. * 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)
  81733. */
  81734. spriteCellChangeSpeed: number;
  81735. /**
  81736. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  81737. */
  81738. startSpriteCellID: number;
  81739. /**
  81740. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  81741. */
  81742. endSpriteCellID: number;
  81743. /**
  81744. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  81745. */
  81746. spriteCellWidth: number;
  81747. /**
  81748. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  81749. */
  81750. spriteCellHeight: number;
  81751. /**
  81752. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  81753. */
  81754. spriteRandomStartCell: boolean;
  81755. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  81756. translationPivot: Vector2;
  81757. /** @hidden */
  81758. protected _isAnimationSheetEnabled: boolean;
  81759. /**
  81760. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  81761. */
  81762. beginAnimationOnStart: boolean;
  81763. /**
  81764. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  81765. */
  81766. beginAnimationFrom: number;
  81767. /**
  81768. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  81769. */
  81770. beginAnimationTo: number;
  81771. /**
  81772. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  81773. */
  81774. beginAnimationLoop: boolean;
  81775. /**
  81776. * Gets or sets a world offset applied to all particles
  81777. */
  81778. worldOffset: Vector3;
  81779. /**
  81780. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  81781. */
  81782. isAnimationSheetEnabled: boolean;
  81783. /**
  81784. * Get hosting scene
  81785. * @returns the scene
  81786. */
  81787. getScene(): Scene;
  81788. /**
  81789. * You can use gravity if you want to give an orientation to your particles.
  81790. */
  81791. gravity: Vector3;
  81792. protected _colorGradients: Nullable<Array<ColorGradient>>;
  81793. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  81794. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  81795. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  81796. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  81797. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  81798. protected _dragGradients: Nullable<Array<FactorGradient>>;
  81799. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  81800. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  81801. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  81802. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  81803. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  81804. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  81805. /**
  81806. * Defines the delay in milliseconds before starting the system (0 by default)
  81807. */
  81808. startDelay: number;
  81809. /**
  81810. * Gets the current list of drag gradients.
  81811. * You must use addDragGradient and removeDragGradient to udpate this list
  81812. * @returns the list of drag gradients
  81813. */
  81814. getDragGradients(): Nullable<Array<FactorGradient>>;
  81815. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  81816. limitVelocityDamping: number;
  81817. /**
  81818. * Gets the current list of limit velocity gradients.
  81819. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  81820. * @returns the list of limit velocity gradients
  81821. */
  81822. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  81823. /**
  81824. * Gets the current list of color gradients.
  81825. * You must use addColorGradient and removeColorGradient to udpate this list
  81826. * @returns the list of color gradients
  81827. */
  81828. getColorGradients(): Nullable<Array<ColorGradient>>;
  81829. /**
  81830. * Gets the current list of size gradients.
  81831. * You must use addSizeGradient and removeSizeGradient to udpate this list
  81832. * @returns the list of size gradients
  81833. */
  81834. getSizeGradients(): Nullable<Array<FactorGradient>>;
  81835. /**
  81836. * Gets the current list of color remap gradients.
  81837. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  81838. * @returns the list of color remap gradients
  81839. */
  81840. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  81841. /**
  81842. * Gets the current list of alpha remap gradients.
  81843. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  81844. * @returns the list of alpha remap gradients
  81845. */
  81846. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  81847. /**
  81848. * Gets the current list of life time gradients.
  81849. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  81850. * @returns the list of life time gradients
  81851. */
  81852. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  81853. /**
  81854. * Gets the current list of angular speed gradients.
  81855. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  81856. * @returns the list of angular speed gradients
  81857. */
  81858. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  81859. /**
  81860. * Gets the current list of velocity gradients.
  81861. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  81862. * @returns the list of velocity gradients
  81863. */
  81864. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  81865. /**
  81866. * Gets the current list of start size gradients.
  81867. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  81868. * @returns the list of start size gradients
  81869. */
  81870. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  81871. /**
  81872. * Gets the current list of emit rate gradients.
  81873. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  81874. * @returns the list of emit rate gradients
  81875. */
  81876. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  81877. /**
  81878. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81879. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81880. */
  81881. direction1: Vector3;
  81882. /**
  81883. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  81884. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81885. */
  81886. direction2: Vector3;
  81887. /**
  81888. * 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.
  81889. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81890. */
  81891. minEmitBox: Vector3;
  81892. /**
  81893. * 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.
  81894. * This only works when particleEmitterTyps is a BoxParticleEmitter
  81895. */
  81896. maxEmitBox: Vector3;
  81897. /**
  81898. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  81899. */
  81900. color1: Color4;
  81901. /**
  81902. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  81903. */
  81904. color2: Color4;
  81905. /**
  81906. * Color the particle will have at the end of its lifetime
  81907. */
  81908. colorDead: Color4;
  81909. /**
  81910. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  81911. */
  81912. textureMask: Color4;
  81913. /**
  81914. * The particle emitter type defines the emitter used by the particle system.
  81915. * It can be for example box, sphere, or cone...
  81916. */
  81917. particleEmitterType: IParticleEmitterType;
  81918. /** @hidden */
  81919. _isSubEmitter: boolean;
  81920. /**
  81921. * Gets or sets the billboard mode to use when isBillboardBased = true.
  81922. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  81923. */
  81924. billboardMode: number;
  81925. protected _isBillboardBased: boolean;
  81926. /**
  81927. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  81928. */
  81929. isBillboardBased: boolean;
  81930. /**
  81931. * The scene the particle system belongs to.
  81932. */
  81933. protected _scene: Scene;
  81934. /**
  81935. * Local cache of defines for image processing.
  81936. */
  81937. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  81938. /**
  81939. * Default configuration related to image processing available in the standard Material.
  81940. */
  81941. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  81942. /**
  81943. * Gets the image processing configuration used either in this material.
  81944. */
  81945. /**
  81946. * Sets the Default image processing configuration used either in the this material.
  81947. *
  81948. * If sets to null, the scene one is in use.
  81949. */
  81950. imageProcessingConfiguration: ImageProcessingConfiguration;
  81951. /**
  81952. * Attaches a new image processing configuration to the Standard Material.
  81953. * @param configuration
  81954. */
  81955. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  81956. /** @hidden */
  81957. protected _reset(): void;
  81958. /** @hidden */
  81959. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  81960. /**
  81961. * Instantiates a particle system.
  81962. * 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.
  81963. * @param name The name of the particle system
  81964. */
  81965. constructor(name: string);
  81966. /**
  81967. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  81968. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  81969. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  81970. * @returns the emitter
  81971. */
  81972. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  81973. /**
  81974. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  81975. * @param radius The radius of the hemisphere to emit from
  81976. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  81977. * @returns the emitter
  81978. */
  81979. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  81980. /**
  81981. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  81982. * @param radius The radius of the sphere to emit from
  81983. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  81984. * @returns the emitter
  81985. */
  81986. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  81987. /**
  81988. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  81989. * @param radius The radius of the sphere to emit from
  81990. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  81991. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  81992. * @returns the emitter
  81993. */
  81994. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  81995. /**
  81996. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  81997. * @param radius The radius of the emission cylinder
  81998. * @param height The height of the emission cylinder
  81999. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  82000. * @param directionRandomizer How much to randomize the particle direction [0-1]
  82001. * @returns the emitter
  82002. */
  82003. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  82004. /**
  82005. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  82006. * @param radius The radius of the cylinder to emit from
  82007. * @param height The height of the emission cylinder
  82008. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82009. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  82010. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  82011. * @returns the emitter
  82012. */
  82013. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  82014. /**
  82015. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  82016. * @param radius The radius of the cone to emit from
  82017. * @param angle The base angle of the cone
  82018. * @returns the emitter
  82019. */
  82020. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  82021. /**
  82022. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  82023. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  82024. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  82025. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82026. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  82027. * @returns the emitter
  82028. */
  82029. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  82030. }
  82031. }
  82032. declare module BABYLON {
  82033. /**
  82034. * Type of sub emitter
  82035. */
  82036. export enum SubEmitterType {
  82037. /**
  82038. * Attached to the particle over it's lifetime
  82039. */
  82040. ATTACHED = 0,
  82041. /**
  82042. * Created when the particle dies
  82043. */
  82044. END = 1
  82045. }
  82046. /**
  82047. * Sub emitter class used to emit particles from an existing particle
  82048. */
  82049. export class SubEmitter {
  82050. /**
  82051. * the particle system to be used by the sub emitter
  82052. */
  82053. particleSystem: ParticleSystem;
  82054. /**
  82055. * Type of the submitter (Default: END)
  82056. */
  82057. type: SubEmitterType;
  82058. /**
  82059. * 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)
  82060. * Note: This only is supported when using an emitter of type Mesh
  82061. */
  82062. inheritDirection: boolean;
  82063. /**
  82064. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  82065. */
  82066. inheritedVelocityAmount: number;
  82067. /**
  82068. * Creates a sub emitter
  82069. * @param particleSystem the particle system to be used by the sub emitter
  82070. */
  82071. constructor(
  82072. /**
  82073. * the particle system to be used by the sub emitter
  82074. */
  82075. particleSystem: ParticleSystem);
  82076. /**
  82077. * Clones the sub emitter
  82078. * @returns the cloned sub emitter
  82079. */
  82080. clone(): SubEmitter;
  82081. /**
  82082. * Serialize current object to a JSON object
  82083. * @returns the serialized object
  82084. */
  82085. serialize(): any;
  82086. /** @hidden */
  82087. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  82088. /**
  82089. * Creates a new SubEmitter from a serialized JSON version
  82090. * @param serializationObject defines the JSON object to read from
  82091. * @param scene defines the hosting scene
  82092. * @param rootUrl defines the rootUrl for data loading
  82093. * @returns a new SubEmitter
  82094. */
  82095. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  82096. /** Release associated resources */
  82097. dispose(): void;
  82098. }
  82099. }
  82100. declare module BABYLON {
  82101. /** @hidden */
  82102. export var imageProcessingDeclaration: {
  82103. name: string;
  82104. shader: string;
  82105. };
  82106. }
  82107. declare module BABYLON {
  82108. /** @hidden */
  82109. export var imageProcessingFunctions: {
  82110. name: string;
  82111. shader: string;
  82112. };
  82113. }
  82114. declare module BABYLON {
  82115. /** @hidden */
  82116. export var particlesPixelShader: {
  82117. name: string;
  82118. shader: string;
  82119. };
  82120. }
  82121. declare module BABYLON {
  82122. /** @hidden */
  82123. export var particlesVertexShader: {
  82124. name: string;
  82125. shader: string;
  82126. };
  82127. }
  82128. declare module BABYLON {
  82129. /**
  82130. * This represents a particle system in Babylon.
  82131. * 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.
  82132. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  82133. * @example https://doc.babylonjs.com/babylon101/particles
  82134. */
  82135. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  82136. /**
  82137. * Billboard mode will only apply to Y axis
  82138. */
  82139. static readonly BILLBOARDMODE_Y: number;
  82140. /**
  82141. * Billboard mode will apply to all axes
  82142. */
  82143. static readonly BILLBOARDMODE_ALL: number;
  82144. /**
  82145. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  82146. */
  82147. static readonly BILLBOARDMODE_STRETCHED: number;
  82148. /**
  82149. * This function can be defined to provide custom update for active particles.
  82150. * This function will be called instead of regular update (age, position, color, etc.).
  82151. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  82152. */
  82153. updateFunction: (particles: Particle[]) => void;
  82154. private _emitterWorldMatrix;
  82155. /**
  82156. * This function can be defined to specify initial direction for every new particle.
  82157. * It by default use the emitterType defined function
  82158. */
  82159. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  82160. /**
  82161. * This function can be defined to specify initial position for every new particle.
  82162. * It by default use the emitterType defined function
  82163. */
  82164. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  82165. /**
  82166. * @hidden
  82167. */
  82168. _inheritedVelocityOffset: Vector3;
  82169. /**
  82170. * An event triggered when the system is disposed
  82171. */
  82172. onDisposeObservable: Observable<ParticleSystem>;
  82173. private _onDisposeObserver;
  82174. /**
  82175. * Sets a callback that will be triggered when the system is disposed
  82176. */
  82177. onDispose: () => void;
  82178. private _particles;
  82179. private _epsilon;
  82180. private _capacity;
  82181. private _stockParticles;
  82182. private _newPartsExcess;
  82183. private _vertexData;
  82184. private _vertexBuffer;
  82185. private _vertexBuffers;
  82186. private _spriteBuffer;
  82187. private _indexBuffer;
  82188. private _effect;
  82189. private _customEffect;
  82190. private _cachedDefines;
  82191. private _scaledColorStep;
  82192. private _colorDiff;
  82193. private _scaledDirection;
  82194. private _scaledGravity;
  82195. private _currentRenderId;
  82196. private _alive;
  82197. private _useInstancing;
  82198. private _started;
  82199. private _stopped;
  82200. private _actualFrame;
  82201. private _scaledUpdateSpeed;
  82202. private _vertexBufferSize;
  82203. /** @hidden */
  82204. _currentEmitRateGradient: Nullable<FactorGradient>;
  82205. /** @hidden */
  82206. _currentEmitRate1: number;
  82207. /** @hidden */
  82208. _currentEmitRate2: number;
  82209. /** @hidden */
  82210. _currentStartSizeGradient: Nullable<FactorGradient>;
  82211. /** @hidden */
  82212. _currentStartSize1: number;
  82213. /** @hidden */
  82214. _currentStartSize2: number;
  82215. private readonly _rawTextureWidth;
  82216. private _rampGradientsTexture;
  82217. private _useRampGradients;
  82218. /** Gets or sets a boolean indicating that ramp gradients must be used
  82219. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  82220. */
  82221. useRampGradients: boolean;
  82222. /**
  82223. * 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.
  82224. * 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: [])
  82225. */
  82226. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  82227. private _subEmitters;
  82228. /**
  82229. * @hidden
  82230. * If the particle systems emitter should be disposed when the particle system is disposed
  82231. */
  82232. _disposeEmitterOnDispose: boolean;
  82233. /**
  82234. * The current active Sub-systems, this property is used by the root particle system only.
  82235. */
  82236. activeSubSystems: Array<ParticleSystem>;
  82237. private _rootParticleSystem;
  82238. /**
  82239. * Gets the current list of active particles
  82240. */
  82241. readonly particles: Particle[];
  82242. /**
  82243. * Returns the string "ParticleSystem"
  82244. * @returns a string containing the class name
  82245. */
  82246. getClassName(): string;
  82247. /**
  82248. * Instantiates a particle system.
  82249. * 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.
  82250. * @param name The name of the particle system
  82251. * @param capacity The max number of particles alive at the same time
  82252. * @param scene The scene the particle system belongs to
  82253. * @param customEffect a custom effect used to change the way particles are rendered by default
  82254. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  82255. * @param epsilon Offset used to render the particles
  82256. */
  82257. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  82258. private _addFactorGradient;
  82259. private _removeFactorGradient;
  82260. /**
  82261. * Adds a new life time gradient
  82262. * @param gradient defines the gradient to use (between 0 and 1)
  82263. * @param factor defines the life time factor to affect to the specified gradient
  82264. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82265. * @returns the current particle system
  82266. */
  82267. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82268. /**
  82269. * Remove a specific life time gradient
  82270. * @param gradient defines the gradient to remove
  82271. * @returns the current particle system
  82272. */
  82273. removeLifeTimeGradient(gradient: number): IParticleSystem;
  82274. /**
  82275. * Adds a new size gradient
  82276. * @param gradient defines the gradient to use (between 0 and 1)
  82277. * @param factor defines the size factor to affect to the specified gradient
  82278. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82279. * @returns the current particle system
  82280. */
  82281. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82282. /**
  82283. * Remove a specific size gradient
  82284. * @param gradient defines the gradient to remove
  82285. * @returns the current particle system
  82286. */
  82287. removeSizeGradient(gradient: number): IParticleSystem;
  82288. /**
  82289. * Adds a new color remap gradient
  82290. * @param gradient defines the gradient to use (between 0 and 1)
  82291. * @param min defines the color remap minimal range
  82292. * @param max defines the color remap maximal range
  82293. * @returns the current particle system
  82294. */
  82295. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82296. /**
  82297. * Remove a specific color remap gradient
  82298. * @param gradient defines the gradient to remove
  82299. * @returns the current particle system
  82300. */
  82301. removeColorRemapGradient(gradient: number): IParticleSystem;
  82302. /**
  82303. * Adds a new alpha remap gradient
  82304. * @param gradient defines the gradient to use (between 0 and 1)
  82305. * @param min defines the alpha remap minimal range
  82306. * @param max defines the alpha remap maximal range
  82307. * @returns the current particle system
  82308. */
  82309. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  82310. /**
  82311. * Remove a specific alpha remap gradient
  82312. * @param gradient defines the gradient to remove
  82313. * @returns the current particle system
  82314. */
  82315. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  82316. /**
  82317. * Adds a new angular speed gradient
  82318. * @param gradient defines the gradient to use (between 0 and 1)
  82319. * @param factor defines the angular speed to affect to the specified gradient
  82320. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82321. * @returns the current particle system
  82322. */
  82323. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82324. /**
  82325. * Remove a specific angular speed gradient
  82326. * @param gradient defines the gradient to remove
  82327. * @returns the current particle system
  82328. */
  82329. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  82330. /**
  82331. * Adds a new velocity gradient
  82332. * @param gradient defines the gradient to use (between 0 and 1)
  82333. * @param factor defines the velocity to affect to the specified gradient
  82334. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82335. * @returns the current particle system
  82336. */
  82337. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82338. /**
  82339. * Remove a specific velocity gradient
  82340. * @param gradient defines the gradient to remove
  82341. * @returns the current particle system
  82342. */
  82343. removeVelocityGradient(gradient: number): IParticleSystem;
  82344. /**
  82345. * Adds a new limit velocity gradient
  82346. * @param gradient defines the gradient to use (between 0 and 1)
  82347. * @param factor defines the limit velocity value to affect to the specified gradient
  82348. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82349. * @returns the current particle system
  82350. */
  82351. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82352. /**
  82353. * Remove a specific limit velocity gradient
  82354. * @param gradient defines the gradient to remove
  82355. * @returns the current particle system
  82356. */
  82357. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  82358. /**
  82359. * Adds a new drag gradient
  82360. * @param gradient defines the gradient to use (between 0 and 1)
  82361. * @param factor defines the drag value to affect to the specified gradient
  82362. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82363. * @returns the current particle system
  82364. */
  82365. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82366. /**
  82367. * Remove a specific drag gradient
  82368. * @param gradient defines the gradient to remove
  82369. * @returns the current particle system
  82370. */
  82371. removeDragGradient(gradient: number): IParticleSystem;
  82372. /**
  82373. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  82374. * @param gradient defines the gradient to use (between 0 and 1)
  82375. * @param factor defines the emit rate value to affect to the specified gradient
  82376. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82377. * @returns the current particle system
  82378. */
  82379. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82380. /**
  82381. * Remove a specific emit rate gradient
  82382. * @param gradient defines the gradient to remove
  82383. * @returns the current particle system
  82384. */
  82385. removeEmitRateGradient(gradient: number): IParticleSystem;
  82386. /**
  82387. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  82388. * @param gradient defines the gradient to use (between 0 and 1)
  82389. * @param factor defines the start size value to affect to the specified gradient
  82390. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  82391. * @returns the current particle system
  82392. */
  82393. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  82394. /**
  82395. * Remove a specific start size gradient
  82396. * @param gradient defines the gradient to remove
  82397. * @returns the current particle system
  82398. */
  82399. removeStartSizeGradient(gradient: number): IParticleSystem;
  82400. private _createRampGradientTexture;
  82401. /**
  82402. * Gets the current list of ramp gradients.
  82403. * You must use addRampGradient and removeRampGradient to udpate this list
  82404. * @returns the list of ramp gradients
  82405. */
  82406. getRampGradients(): Nullable<Array<Color3Gradient>>;
  82407. /**
  82408. * Adds a new ramp gradient used to remap particle colors
  82409. * @param gradient defines the gradient to use (between 0 and 1)
  82410. * @param color defines the color to affect to the specified gradient
  82411. * @returns the current particle system
  82412. */
  82413. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  82414. /**
  82415. * Remove a specific ramp gradient
  82416. * @param gradient defines the gradient to remove
  82417. * @returns the current particle system
  82418. */
  82419. removeRampGradient(gradient: number): ParticleSystem;
  82420. /**
  82421. * Adds a new color gradient
  82422. * @param gradient defines the gradient to use (between 0 and 1)
  82423. * @param color1 defines the color to affect to the specified gradient
  82424. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  82425. * @returns this particle system
  82426. */
  82427. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  82428. /**
  82429. * Remove a specific color gradient
  82430. * @param gradient defines the gradient to remove
  82431. * @returns this particle system
  82432. */
  82433. removeColorGradient(gradient: number): IParticleSystem;
  82434. private _fetchR;
  82435. protected _reset(): void;
  82436. private _resetEffect;
  82437. private _createVertexBuffers;
  82438. private _createIndexBuffer;
  82439. /**
  82440. * Gets the maximum number of particles active at the same time.
  82441. * @returns The max number of active particles.
  82442. */
  82443. getCapacity(): number;
  82444. /**
  82445. * Gets whether there are still active particles in the system.
  82446. * @returns True if it is alive, otherwise false.
  82447. */
  82448. isAlive(): boolean;
  82449. /**
  82450. * Gets if the system has been started. (Note: this will still be true after stop is called)
  82451. * @returns True if it has been started, otherwise false.
  82452. */
  82453. isStarted(): boolean;
  82454. private _prepareSubEmitterInternalArray;
  82455. /**
  82456. * Starts the particle system and begins to emit
  82457. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  82458. */
  82459. start(delay?: number): void;
  82460. /**
  82461. * Stops the particle system.
  82462. * @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.
  82463. */
  82464. stop(stopSubEmitters?: boolean): void;
  82465. /**
  82466. * Remove all active particles
  82467. */
  82468. reset(): void;
  82469. /**
  82470. * @hidden (for internal use only)
  82471. */
  82472. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  82473. /**
  82474. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  82475. * Its lifetime will start back at 0.
  82476. */
  82477. recycleParticle: (particle: Particle) => void;
  82478. private _stopSubEmitters;
  82479. private _createParticle;
  82480. private _removeFromRoot;
  82481. private _emitFromParticle;
  82482. private _update;
  82483. /** @hidden */
  82484. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  82485. /** @hidden */
  82486. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  82487. /** @hidden */
  82488. private _getEffect;
  82489. /**
  82490. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  82491. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  82492. */
  82493. animate(preWarmOnly?: boolean): void;
  82494. private _appendParticleVertices;
  82495. /**
  82496. * Rebuilds the particle system.
  82497. */
  82498. rebuild(): void;
  82499. /**
  82500. * Is this system ready to be used/rendered
  82501. * @return true if the system is ready
  82502. */
  82503. isReady(): boolean;
  82504. private _render;
  82505. /**
  82506. * Renders the particle system in its current state.
  82507. * @returns the current number of particles
  82508. */
  82509. render(): number;
  82510. /**
  82511. * Disposes the particle system and free the associated resources
  82512. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  82513. */
  82514. dispose(disposeTexture?: boolean): void;
  82515. /**
  82516. * Clones the particle system.
  82517. * @param name The name of the cloned object
  82518. * @param newEmitter The new emitter to use
  82519. * @returns the cloned particle system
  82520. */
  82521. clone(name: string, newEmitter: any): ParticleSystem;
  82522. /**
  82523. * Serializes the particle system to a JSON object.
  82524. * @returns the JSON object
  82525. */
  82526. serialize(): any;
  82527. /** @hidden */
  82528. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  82529. /** @hidden */
  82530. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  82531. /**
  82532. * Parses a JSON object to create a particle system.
  82533. * @param parsedParticleSystem The JSON object to parse
  82534. * @param scene The scene to create the particle system in
  82535. * @param rootUrl The root url to use to load external dependencies like texture
  82536. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  82537. * @returns the Parsed particle system
  82538. */
  82539. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  82540. }
  82541. }
  82542. declare module BABYLON {
  82543. /**
  82544. * A particle represents one of the element emitted by a particle system.
  82545. * This is mainly define by its coordinates, direction, velocity and age.
  82546. */
  82547. export class Particle {
  82548. /**
  82549. * The particle system the particle belongs to.
  82550. */
  82551. particleSystem: ParticleSystem;
  82552. private static _Count;
  82553. /**
  82554. * Unique ID of the particle
  82555. */
  82556. id: number;
  82557. /**
  82558. * The world position of the particle in the scene.
  82559. */
  82560. position: Vector3;
  82561. /**
  82562. * The world direction of the particle in the scene.
  82563. */
  82564. direction: Vector3;
  82565. /**
  82566. * The color of the particle.
  82567. */
  82568. color: Color4;
  82569. /**
  82570. * The color change of the particle per step.
  82571. */
  82572. colorStep: Color4;
  82573. /**
  82574. * Defines how long will the life of the particle be.
  82575. */
  82576. lifeTime: number;
  82577. /**
  82578. * The current age of the particle.
  82579. */
  82580. age: number;
  82581. /**
  82582. * The current size of the particle.
  82583. */
  82584. size: number;
  82585. /**
  82586. * The current scale of the particle.
  82587. */
  82588. scale: Vector2;
  82589. /**
  82590. * The current angle of the particle.
  82591. */
  82592. angle: number;
  82593. /**
  82594. * Defines how fast is the angle changing.
  82595. */
  82596. angularSpeed: number;
  82597. /**
  82598. * Defines the cell index used by the particle to be rendered from a sprite.
  82599. */
  82600. cellIndex: number;
  82601. /**
  82602. * The information required to support color remapping
  82603. */
  82604. remapData: Vector4;
  82605. /** @hidden */
  82606. _randomCellOffset?: number;
  82607. /** @hidden */
  82608. _initialDirection: Nullable<Vector3>;
  82609. /** @hidden */
  82610. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  82611. /** @hidden */
  82612. _initialStartSpriteCellID: number;
  82613. /** @hidden */
  82614. _initialEndSpriteCellID: number;
  82615. /** @hidden */
  82616. _currentColorGradient: Nullable<ColorGradient>;
  82617. /** @hidden */
  82618. _currentColor1: Color4;
  82619. /** @hidden */
  82620. _currentColor2: Color4;
  82621. /** @hidden */
  82622. _currentSizeGradient: Nullable<FactorGradient>;
  82623. /** @hidden */
  82624. _currentSize1: number;
  82625. /** @hidden */
  82626. _currentSize2: number;
  82627. /** @hidden */
  82628. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  82629. /** @hidden */
  82630. _currentAngularSpeed1: number;
  82631. /** @hidden */
  82632. _currentAngularSpeed2: number;
  82633. /** @hidden */
  82634. _currentVelocityGradient: Nullable<FactorGradient>;
  82635. /** @hidden */
  82636. _currentVelocity1: number;
  82637. /** @hidden */
  82638. _currentVelocity2: number;
  82639. /** @hidden */
  82640. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  82641. /** @hidden */
  82642. _currentLimitVelocity1: number;
  82643. /** @hidden */
  82644. _currentLimitVelocity2: number;
  82645. /** @hidden */
  82646. _currentDragGradient: Nullable<FactorGradient>;
  82647. /** @hidden */
  82648. _currentDrag1: number;
  82649. /** @hidden */
  82650. _currentDrag2: number;
  82651. /** @hidden */
  82652. _randomNoiseCoordinates1: Vector3;
  82653. /** @hidden */
  82654. _randomNoiseCoordinates2: Vector3;
  82655. /**
  82656. * Creates a new instance Particle
  82657. * @param particleSystem the particle system the particle belongs to
  82658. */
  82659. constructor(
  82660. /**
  82661. * The particle system the particle belongs to.
  82662. */
  82663. particleSystem: ParticleSystem);
  82664. private updateCellInfoFromSystem;
  82665. /**
  82666. * Defines how the sprite cell index is updated for the particle
  82667. */
  82668. updateCellIndex(): void;
  82669. /** @hidden */
  82670. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  82671. /** @hidden */
  82672. _inheritParticleInfoToSubEmitters(): void;
  82673. /** @hidden */
  82674. _reset(): void;
  82675. /**
  82676. * Copy the properties of particle to another one.
  82677. * @param other the particle to copy the information to.
  82678. */
  82679. copyTo(other: Particle): void;
  82680. }
  82681. }
  82682. declare module BABYLON {
  82683. /**
  82684. * Particle emitter represents a volume emitting particles.
  82685. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  82686. */
  82687. export interface IParticleEmitterType {
  82688. /**
  82689. * Called by the particle System when the direction is computed for the created particle.
  82690. * @param worldMatrix is the world matrix of the particle system
  82691. * @param directionToUpdate is the direction vector to update with the result
  82692. * @param particle is the particle we are computed the direction for
  82693. */
  82694. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82695. /**
  82696. * Called by the particle System when the position is computed for the created particle.
  82697. * @param worldMatrix is the world matrix of the particle system
  82698. * @param positionToUpdate is the position vector to update with the result
  82699. * @param particle is the particle we are computed the position for
  82700. */
  82701. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82702. /**
  82703. * Clones the current emitter and returns a copy of it
  82704. * @returns the new emitter
  82705. */
  82706. clone(): IParticleEmitterType;
  82707. /**
  82708. * Called by the GPUParticleSystem to setup the update shader
  82709. * @param effect defines the update shader
  82710. */
  82711. applyToShader(effect: Effect): void;
  82712. /**
  82713. * Returns a string to use to update the GPU particles update shader
  82714. * @returns the effect defines string
  82715. */
  82716. getEffectDefines(): string;
  82717. /**
  82718. * Returns a string representing the class name
  82719. * @returns a string containing the class name
  82720. */
  82721. getClassName(): string;
  82722. /**
  82723. * Serializes the particle system to a JSON object.
  82724. * @returns the JSON object
  82725. */
  82726. serialize(): any;
  82727. /**
  82728. * Parse properties from a JSON object
  82729. * @param serializationObject defines the JSON object
  82730. */
  82731. parse(serializationObject: any): void;
  82732. }
  82733. }
  82734. declare module BABYLON {
  82735. /**
  82736. * Particle emitter emitting particles from the inside of a box.
  82737. * It emits the particles randomly between 2 given directions.
  82738. */
  82739. export class BoxParticleEmitter implements IParticleEmitterType {
  82740. /**
  82741. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82742. */
  82743. direction1: Vector3;
  82744. /**
  82745. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  82746. */
  82747. direction2: Vector3;
  82748. /**
  82749. * 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.
  82750. */
  82751. minEmitBox: Vector3;
  82752. /**
  82753. * 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.
  82754. */
  82755. maxEmitBox: Vector3;
  82756. /**
  82757. * Creates a new instance BoxParticleEmitter
  82758. */
  82759. constructor();
  82760. /**
  82761. * Called by the particle System when the direction is computed for the created particle.
  82762. * @param worldMatrix is the world matrix of the particle system
  82763. * @param directionToUpdate is the direction vector to update with the result
  82764. * @param particle is the particle we are computed the direction for
  82765. */
  82766. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82767. /**
  82768. * Called by the particle System when the position is computed for the created particle.
  82769. * @param worldMatrix is the world matrix of the particle system
  82770. * @param positionToUpdate is the position vector to update with the result
  82771. * @param particle is the particle we are computed the position for
  82772. */
  82773. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82774. /**
  82775. * Clones the current emitter and returns a copy of it
  82776. * @returns the new emitter
  82777. */
  82778. clone(): BoxParticleEmitter;
  82779. /**
  82780. * Called by the GPUParticleSystem to setup the update shader
  82781. * @param effect defines the update shader
  82782. */
  82783. applyToShader(effect: Effect): void;
  82784. /**
  82785. * Returns a string to use to update the GPU particles update shader
  82786. * @returns a string containng the defines string
  82787. */
  82788. getEffectDefines(): string;
  82789. /**
  82790. * Returns the string "BoxParticleEmitter"
  82791. * @returns a string containing the class name
  82792. */
  82793. getClassName(): string;
  82794. /**
  82795. * Serializes the particle system to a JSON object.
  82796. * @returns the JSON object
  82797. */
  82798. serialize(): any;
  82799. /**
  82800. * Parse properties from a JSON object
  82801. * @param serializationObject defines the JSON object
  82802. */
  82803. parse(serializationObject: any): void;
  82804. }
  82805. }
  82806. declare module BABYLON {
  82807. /**
  82808. * Particle emitter emitting particles from the inside of a cone.
  82809. * It emits the particles alongside the cone volume from the base to the particle.
  82810. * The emission direction might be randomized.
  82811. */
  82812. export class ConeParticleEmitter implements IParticleEmitterType {
  82813. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  82814. directionRandomizer: number;
  82815. private _radius;
  82816. private _angle;
  82817. private _height;
  82818. /**
  82819. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  82820. */
  82821. radiusRange: number;
  82822. /**
  82823. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  82824. */
  82825. heightRange: number;
  82826. /**
  82827. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  82828. */
  82829. emitFromSpawnPointOnly: boolean;
  82830. /**
  82831. * Gets or sets the radius of the emission cone
  82832. */
  82833. radius: number;
  82834. /**
  82835. * Gets or sets the angle of the emission cone
  82836. */
  82837. angle: number;
  82838. private _buildHeight;
  82839. /**
  82840. * Creates a new instance ConeParticleEmitter
  82841. * @param radius the radius of the emission cone (1 by default)
  82842. * @param angle the cone base angle (PI by default)
  82843. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  82844. */
  82845. constructor(radius?: number, angle?: number,
  82846. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  82847. directionRandomizer?: number);
  82848. /**
  82849. * Called by the particle System when the direction is computed for the created particle.
  82850. * @param worldMatrix is the world matrix of the particle system
  82851. * @param directionToUpdate is the direction vector to update with the result
  82852. * @param particle is the particle we are computed the direction for
  82853. */
  82854. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82855. /**
  82856. * Called by the particle System when the position is computed for the created particle.
  82857. * @param worldMatrix is the world matrix of the particle system
  82858. * @param positionToUpdate is the position vector to update with the result
  82859. * @param particle is the particle we are computed the position for
  82860. */
  82861. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82862. /**
  82863. * Clones the current emitter and returns a copy of it
  82864. * @returns the new emitter
  82865. */
  82866. clone(): ConeParticleEmitter;
  82867. /**
  82868. * Called by the GPUParticleSystem to setup the update shader
  82869. * @param effect defines the update shader
  82870. */
  82871. applyToShader(effect: Effect): void;
  82872. /**
  82873. * Returns a string to use to update the GPU particles update shader
  82874. * @returns a string containng the defines string
  82875. */
  82876. getEffectDefines(): string;
  82877. /**
  82878. * Returns the string "ConeParticleEmitter"
  82879. * @returns a string containing the class name
  82880. */
  82881. getClassName(): string;
  82882. /**
  82883. * Serializes the particle system to a JSON object.
  82884. * @returns the JSON object
  82885. */
  82886. serialize(): any;
  82887. /**
  82888. * Parse properties from a JSON object
  82889. * @param serializationObject defines the JSON object
  82890. */
  82891. parse(serializationObject: any): void;
  82892. }
  82893. }
  82894. declare module BABYLON {
  82895. /**
  82896. * Particle emitter emitting particles from the inside of a cylinder.
  82897. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  82898. */
  82899. export class CylinderParticleEmitter implements IParticleEmitterType {
  82900. /**
  82901. * The radius of the emission cylinder.
  82902. */
  82903. radius: number;
  82904. /**
  82905. * The height of the emission cylinder.
  82906. */
  82907. height: number;
  82908. /**
  82909. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82910. */
  82911. radiusRange: number;
  82912. /**
  82913. * How much to randomize the particle direction [0-1].
  82914. */
  82915. directionRandomizer: number;
  82916. /**
  82917. * Creates a new instance CylinderParticleEmitter
  82918. * @param radius the radius of the emission cylinder (1 by default)
  82919. * @param height the height of the emission cylinder (1 by default)
  82920. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  82921. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  82922. */
  82923. constructor(
  82924. /**
  82925. * The radius of the emission cylinder.
  82926. */
  82927. radius?: number,
  82928. /**
  82929. * The height of the emission cylinder.
  82930. */
  82931. height?: number,
  82932. /**
  82933. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  82934. */
  82935. radiusRange?: number,
  82936. /**
  82937. * How much to randomize the particle direction [0-1].
  82938. */
  82939. directionRandomizer?: number);
  82940. /**
  82941. * Called by the particle System when the direction is computed for the created particle.
  82942. * @param worldMatrix is the world matrix of the particle system
  82943. * @param directionToUpdate is the direction vector to update with the result
  82944. * @param particle is the particle we are computed the direction for
  82945. */
  82946. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  82947. /**
  82948. * Called by the particle System when the position is computed for the created particle.
  82949. * @param worldMatrix is the world matrix of the particle system
  82950. * @param positionToUpdate is the position vector to update with the result
  82951. * @param particle is the particle we are computed the position for
  82952. */
  82953. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  82954. /**
  82955. * Clones the current emitter and returns a copy of it
  82956. * @returns the new emitter
  82957. */
  82958. clone(): CylinderParticleEmitter;
  82959. /**
  82960. * Called by the GPUParticleSystem to setup the update shader
  82961. * @param effect defines the update shader
  82962. */
  82963. applyToShader(effect: Effect): void;
  82964. /**
  82965. * Returns a string to use to update the GPU particles update shader
  82966. * @returns a string containng the defines string
  82967. */
  82968. getEffectDefines(): string;
  82969. /**
  82970. * Returns the string "CylinderParticleEmitter"
  82971. * @returns a string containing the class name
  82972. */
  82973. getClassName(): string;
  82974. /**
  82975. * Serializes the particle system to a JSON object.
  82976. * @returns the JSON object
  82977. */
  82978. serialize(): any;
  82979. /**
  82980. * Parse properties from a JSON object
  82981. * @param serializationObject defines the JSON object
  82982. */
  82983. parse(serializationObject: any): void;
  82984. }
  82985. /**
  82986. * Particle emitter emitting particles from the inside of a cylinder.
  82987. * It emits the particles randomly between two vectors.
  82988. */
  82989. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  82990. /**
  82991. * The min limit of the emission direction.
  82992. */
  82993. direction1: Vector3;
  82994. /**
  82995. * The max limit of the emission direction.
  82996. */
  82997. direction2: Vector3;
  82998. /**
  82999. * Creates a new instance CylinderDirectedParticleEmitter
  83000. * @param radius the radius of the emission cylinder (1 by default)
  83001. * @param height the height of the emission cylinder (1 by default)
  83002. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83003. * @param direction1 the min limit of the emission direction (up vector by default)
  83004. * @param direction2 the max limit of the emission direction (up vector by default)
  83005. */
  83006. constructor(radius?: number, height?: number, radiusRange?: number,
  83007. /**
  83008. * The min limit of the emission direction.
  83009. */
  83010. direction1?: Vector3,
  83011. /**
  83012. * The max limit of the emission direction.
  83013. */
  83014. direction2?: Vector3);
  83015. /**
  83016. * Called by the particle System when the direction is computed for the created particle.
  83017. * @param worldMatrix is the world matrix of the particle system
  83018. * @param directionToUpdate is the direction vector to update with the result
  83019. * @param particle is the particle we are computed the direction for
  83020. */
  83021. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83022. /**
  83023. * Clones the current emitter and returns a copy of it
  83024. * @returns the new emitter
  83025. */
  83026. clone(): CylinderDirectedParticleEmitter;
  83027. /**
  83028. * Called by the GPUParticleSystem to setup the update shader
  83029. * @param effect defines the update shader
  83030. */
  83031. applyToShader(effect: Effect): void;
  83032. /**
  83033. * Returns a string to use to update the GPU particles update shader
  83034. * @returns a string containng the defines string
  83035. */
  83036. getEffectDefines(): string;
  83037. /**
  83038. * Returns the string "CylinderDirectedParticleEmitter"
  83039. * @returns a string containing the class name
  83040. */
  83041. getClassName(): string;
  83042. /**
  83043. * Serializes the particle system to a JSON object.
  83044. * @returns the JSON object
  83045. */
  83046. serialize(): any;
  83047. /**
  83048. * Parse properties from a JSON object
  83049. * @param serializationObject defines the JSON object
  83050. */
  83051. parse(serializationObject: any): void;
  83052. }
  83053. }
  83054. declare module BABYLON {
  83055. /**
  83056. * Particle emitter emitting particles from the inside of a hemisphere.
  83057. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  83058. */
  83059. export class HemisphericParticleEmitter implements IParticleEmitterType {
  83060. /**
  83061. * The radius of the emission hemisphere.
  83062. */
  83063. radius: number;
  83064. /**
  83065. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83066. */
  83067. radiusRange: number;
  83068. /**
  83069. * How much to randomize the particle direction [0-1].
  83070. */
  83071. directionRandomizer: number;
  83072. /**
  83073. * Creates a new instance HemisphericParticleEmitter
  83074. * @param radius the radius of the emission hemisphere (1 by default)
  83075. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83076. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83077. */
  83078. constructor(
  83079. /**
  83080. * The radius of the emission hemisphere.
  83081. */
  83082. radius?: number,
  83083. /**
  83084. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83085. */
  83086. radiusRange?: number,
  83087. /**
  83088. * How much to randomize the particle direction [0-1].
  83089. */
  83090. directionRandomizer?: number);
  83091. /**
  83092. * Called by the particle System when the direction is computed for the created particle.
  83093. * @param worldMatrix is the world matrix of the particle system
  83094. * @param directionToUpdate is the direction vector to update with the result
  83095. * @param particle is the particle we are computed the direction for
  83096. */
  83097. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83098. /**
  83099. * Called by the particle System when the position is computed for the created particle.
  83100. * @param worldMatrix is the world matrix of the particle system
  83101. * @param positionToUpdate is the position vector to update with the result
  83102. * @param particle is the particle we are computed the position for
  83103. */
  83104. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83105. /**
  83106. * Clones the current emitter and returns a copy of it
  83107. * @returns the new emitter
  83108. */
  83109. clone(): HemisphericParticleEmitter;
  83110. /**
  83111. * Called by the GPUParticleSystem to setup the update shader
  83112. * @param effect defines the update shader
  83113. */
  83114. applyToShader(effect: Effect): void;
  83115. /**
  83116. * Returns a string to use to update the GPU particles update shader
  83117. * @returns a string containng the defines string
  83118. */
  83119. getEffectDefines(): string;
  83120. /**
  83121. * Returns the string "HemisphericParticleEmitter"
  83122. * @returns a string containing the class name
  83123. */
  83124. getClassName(): string;
  83125. /**
  83126. * Serializes the particle system to a JSON object.
  83127. * @returns the JSON object
  83128. */
  83129. serialize(): any;
  83130. /**
  83131. * Parse properties from a JSON object
  83132. * @param serializationObject defines the JSON object
  83133. */
  83134. parse(serializationObject: any): void;
  83135. }
  83136. }
  83137. declare module BABYLON {
  83138. /**
  83139. * Particle emitter emitting particles from a point.
  83140. * It emits the particles randomly between 2 given directions.
  83141. */
  83142. export class PointParticleEmitter implements IParticleEmitterType {
  83143. /**
  83144. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83145. */
  83146. direction1: Vector3;
  83147. /**
  83148. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83149. */
  83150. direction2: Vector3;
  83151. /**
  83152. * Creates a new instance PointParticleEmitter
  83153. */
  83154. constructor();
  83155. /**
  83156. * Called by the particle System when the direction is computed for the created particle.
  83157. * @param worldMatrix is the world matrix of the particle system
  83158. * @param directionToUpdate is the direction vector to update with the result
  83159. * @param particle is the particle we are computed the direction for
  83160. */
  83161. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83162. /**
  83163. * Called by the particle System when the position is computed for the created particle.
  83164. * @param worldMatrix is the world matrix of the particle system
  83165. * @param positionToUpdate is the position vector to update with the result
  83166. * @param particle is the particle we are computed the position for
  83167. */
  83168. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83169. /**
  83170. * Clones the current emitter and returns a copy of it
  83171. * @returns the new emitter
  83172. */
  83173. clone(): PointParticleEmitter;
  83174. /**
  83175. * Called by the GPUParticleSystem to setup the update shader
  83176. * @param effect defines the update shader
  83177. */
  83178. applyToShader(effect: Effect): void;
  83179. /**
  83180. * Returns a string to use to update the GPU particles update shader
  83181. * @returns a string containng the defines string
  83182. */
  83183. getEffectDefines(): string;
  83184. /**
  83185. * Returns the string "PointParticleEmitter"
  83186. * @returns a string containing the class name
  83187. */
  83188. getClassName(): string;
  83189. /**
  83190. * Serializes the particle system to a JSON object.
  83191. * @returns the JSON object
  83192. */
  83193. serialize(): any;
  83194. /**
  83195. * Parse properties from a JSON object
  83196. * @param serializationObject defines the JSON object
  83197. */
  83198. parse(serializationObject: any): void;
  83199. }
  83200. }
  83201. declare module BABYLON {
  83202. /**
  83203. * Particle emitter emitting particles from the inside of a sphere.
  83204. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  83205. */
  83206. export class SphereParticleEmitter implements IParticleEmitterType {
  83207. /**
  83208. * The radius of the emission sphere.
  83209. */
  83210. radius: number;
  83211. /**
  83212. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83213. */
  83214. radiusRange: number;
  83215. /**
  83216. * How much to randomize the particle direction [0-1].
  83217. */
  83218. directionRandomizer: number;
  83219. /**
  83220. * Creates a new instance SphereParticleEmitter
  83221. * @param radius the radius of the emission sphere (1 by default)
  83222. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83223. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  83224. */
  83225. constructor(
  83226. /**
  83227. * The radius of the emission sphere.
  83228. */
  83229. radius?: number,
  83230. /**
  83231. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  83232. */
  83233. radiusRange?: number,
  83234. /**
  83235. * How much to randomize the particle direction [0-1].
  83236. */
  83237. directionRandomizer?: number);
  83238. /**
  83239. * Called by the particle System when the direction is computed for the created particle.
  83240. * @param worldMatrix is the world matrix of the particle system
  83241. * @param directionToUpdate is the direction vector to update with the result
  83242. * @param particle is the particle we are computed the direction for
  83243. */
  83244. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83245. /**
  83246. * Called by the particle System when the position is computed for the created particle.
  83247. * @param worldMatrix is the world matrix of the particle system
  83248. * @param positionToUpdate is the position vector to update with the result
  83249. * @param particle is the particle we are computed the position for
  83250. */
  83251. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  83252. /**
  83253. * Clones the current emitter and returns a copy of it
  83254. * @returns the new emitter
  83255. */
  83256. clone(): SphereParticleEmitter;
  83257. /**
  83258. * Called by the GPUParticleSystem to setup the update shader
  83259. * @param effect defines the update shader
  83260. */
  83261. applyToShader(effect: Effect): void;
  83262. /**
  83263. * Returns a string to use to update the GPU particles update shader
  83264. * @returns a string containng the defines string
  83265. */
  83266. getEffectDefines(): string;
  83267. /**
  83268. * Returns the string "SphereParticleEmitter"
  83269. * @returns a string containing the class name
  83270. */
  83271. getClassName(): string;
  83272. /**
  83273. * Serializes the particle system to a JSON object.
  83274. * @returns the JSON object
  83275. */
  83276. serialize(): any;
  83277. /**
  83278. * Parse properties from a JSON object
  83279. * @param serializationObject defines the JSON object
  83280. */
  83281. parse(serializationObject: any): void;
  83282. }
  83283. /**
  83284. * Particle emitter emitting particles from the inside of a sphere.
  83285. * It emits the particles randomly between two vectors.
  83286. */
  83287. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  83288. /**
  83289. * The min limit of the emission direction.
  83290. */
  83291. direction1: Vector3;
  83292. /**
  83293. * The max limit of the emission direction.
  83294. */
  83295. direction2: Vector3;
  83296. /**
  83297. * Creates a new instance SphereDirectedParticleEmitter
  83298. * @param radius the radius of the emission sphere (1 by default)
  83299. * @param direction1 the min limit of the emission direction (up vector by default)
  83300. * @param direction2 the max limit of the emission direction (up vector by default)
  83301. */
  83302. constructor(radius?: number,
  83303. /**
  83304. * The min limit of the emission direction.
  83305. */
  83306. direction1?: Vector3,
  83307. /**
  83308. * The max limit of the emission direction.
  83309. */
  83310. direction2?: Vector3);
  83311. /**
  83312. * Called by the particle System when the direction is computed for the created particle.
  83313. * @param worldMatrix is the world matrix of the particle system
  83314. * @param directionToUpdate is the direction vector to update with the result
  83315. * @param particle is the particle we are computed the direction for
  83316. */
  83317. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  83318. /**
  83319. * Clones the current emitter and returns a copy of it
  83320. * @returns the new emitter
  83321. */
  83322. clone(): SphereDirectedParticleEmitter;
  83323. /**
  83324. * Called by the GPUParticleSystem to setup the update shader
  83325. * @param effect defines the update shader
  83326. */
  83327. applyToShader(effect: Effect): void;
  83328. /**
  83329. * Returns a string to use to update the GPU particles update shader
  83330. * @returns a string containng the defines string
  83331. */
  83332. getEffectDefines(): string;
  83333. /**
  83334. * Returns the string "SphereDirectedParticleEmitter"
  83335. * @returns a string containing the class name
  83336. */
  83337. getClassName(): string;
  83338. /**
  83339. * Serializes the particle system to a JSON object.
  83340. * @returns the JSON object
  83341. */
  83342. serialize(): any;
  83343. /**
  83344. * Parse properties from a JSON object
  83345. * @param serializationObject defines the JSON object
  83346. */
  83347. parse(serializationObject: any): void;
  83348. }
  83349. }
  83350. declare module BABYLON {
  83351. /**
  83352. * Interface representing a particle system in Babylon.js.
  83353. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  83354. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  83355. */
  83356. export interface IParticleSystem {
  83357. /**
  83358. * List of animations used by the particle system.
  83359. */
  83360. animations: Animation[];
  83361. /**
  83362. * The id of the Particle system.
  83363. */
  83364. id: string;
  83365. /**
  83366. * The name of the Particle system.
  83367. */
  83368. name: string;
  83369. /**
  83370. * The emitter represents the Mesh or position we are attaching the particle system to.
  83371. */
  83372. emitter: Nullable<AbstractMesh | Vector3>;
  83373. /**
  83374. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83375. */
  83376. isBillboardBased: boolean;
  83377. /**
  83378. * The rendering group used by the Particle system to chose when to render.
  83379. */
  83380. renderingGroupId: number;
  83381. /**
  83382. * The layer mask we are rendering the particles through.
  83383. */
  83384. layerMask: number;
  83385. /**
  83386. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83387. */
  83388. updateSpeed: number;
  83389. /**
  83390. * The amount of time the particle system is running (depends of the overall update speed).
  83391. */
  83392. targetStopDuration: number;
  83393. /**
  83394. * The texture used to render each particle. (this can be a spritesheet)
  83395. */
  83396. particleTexture: Nullable<Texture>;
  83397. /**
  83398. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  83399. */
  83400. blendMode: number;
  83401. /**
  83402. * Minimum life time of emitting particles.
  83403. */
  83404. minLifeTime: number;
  83405. /**
  83406. * Maximum life time of emitting particles.
  83407. */
  83408. maxLifeTime: number;
  83409. /**
  83410. * Minimum Size of emitting particles.
  83411. */
  83412. minSize: number;
  83413. /**
  83414. * Maximum Size of emitting particles.
  83415. */
  83416. maxSize: number;
  83417. /**
  83418. * Minimum scale of emitting particles on X axis.
  83419. */
  83420. minScaleX: number;
  83421. /**
  83422. * Maximum scale of emitting particles on X axis.
  83423. */
  83424. maxScaleX: number;
  83425. /**
  83426. * Minimum scale of emitting particles on Y axis.
  83427. */
  83428. minScaleY: number;
  83429. /**
  83430. * Maximum scale of emitting particles on Y axis.
  83431. */
  83432. maxScaleY: number;
  83433. /**
  83434. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83435. */
  83436. color1: Color4;
  83437. /**
  83438. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  83439. */
  83440. color2: Color4;
  83441. /**
  83442. * Color the particle will have at the end of its lifetime.
  83443. */
  83444. colorDead: Color4;
  83445. /**
  83446. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  83447. */
  83448. emitRate: number;
  83449. /**
  83450. * You can use gravity if you want to give an orientation to your particles.
  83451. */
  83452. gravity: Vector3;
  83453. /**
  83454. * Minimum power of emitting particles.
  83455. */
  83456. minEmitPower: number;
  83457. /**
  83458. * Maximum power of emitting particles.
  83459. */
  83460. maxEmitPower: number;
  83461. /**
  83462. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83463. */
  83464. minAngularSpeed: number;
  83465. /**
  83466. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83467. */
  83468. maxAngularSpeed: number;
  83469. /**
  83470. * Gets or sets the minimal initial rotation in radians.
  83471. */
  83472. minInitialRotation: number;
  83473. /**
  83474. * Gets or sets the maximal initial rotation in radians.
  83475. */
  83476. maxInitialRotation: number;
  83477. /**
  83478. * The particle emitter type defines the emitter used by the particle system.
  83479. * It can be for example box, sphere, or cone...
  83480. */
  83481. particleEmitterType: Nullable<IParticleEmitterType>;
  83482. /**
  83483. * Defines the delay in milliseconds before starting the system (0 by default)
  83484. */
  83485. startDelay: number;
  83486. /**
  83487. * 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
  83488. */
  83489. preWarmCycles: number;
  83490. /**
  83491. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  83492. */
  83493. preWarmStepOffset: number;
  83494. /**
  83495. * 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)
  83496. */
  83497. spriteCellChangeSpeed: number;
  83498. /**
  83499. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  83500. */
  83501. startSpriteCellID: number;
  83502. /**
  83503. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  83504. */
  83505. endSpriteCellID: number;
  83506. /**
  83507. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  83508. */
  83509. spriteCellWidth: number;
  83510. /**
  83511. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  83512. */
  83513. spriteCellHeight: number;
  83514. /**
  83515. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  83516. */
  83517. spriteRandomStartCell: boolean;
  83518. /**
  83519. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  83520. */
  83521. isAnimationSheetEnabled: boolean;
  83522. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  83523. translationPivot: Vector2;
  83524. /**
  83525. * Gets or sets a texture used to add random noise to particle positions
  83526. */
  83527. noiseTexture: Nullable<BaseTexture>;
  83528. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83529. noiseStrength: Vector3;
  83530. /**
  83531. * Gets or sets the billboard mode to use when isBillboardBased = true.
  83532. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  83533. */
  83534. billboardMode: number;
  83535. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  83536. limitVelocityDamping: number;
  83537. /**
  83538. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  83539. */
  83540. beginAnimationOnStart: boolean;
  83541. /**
  83542. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  83543. */
  83544. beginAnimationFrom: number;
  83545. /**
  83546. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  83547. */
  83548. beginAnimationTo: number;
  83549. /**
  83550. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  83551. */
  83552. beginAnimationLoop: boolean;
  83553. /**
  83554. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  83555. */
  83556. disposeOnStop: boolean;
  83557. /**
  83558. * Gets the maximum number of particles active at the same time.
  83559. * @returns The max number of active particles.
  83560. */
  83561. getCapacity(): number;
  83562. /**
  83563. * Gets if the system has been started. (Note: this will still be true after stop is called)
  83564. * @returns True if it has been started, otherwise false.
  83565. */
  83566. isStarted(): boolean;
  83567. /**
  83568. * Animates the particle system for this frame.
  83569. */
  83570. animate(): void;
  83571. /**
  83572. * Renders the particle system in its current state.
  83573. * @returns the current number of particles
  83574. */
  83575. render(): number;
  83576. /**
  83577. * Dispose the particle system and frees its associated resources.
  83578. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  83579. */
  83580. dispose(disposeTexture?: boolean): void;
  83581. /**
  83582. * Clones the particle system.
  83583. * @param name The name of the cloned object
  83584. * @param newEmitter The new emitter to use
  83585. * @returns the cloned particle system
  83586. */
  83587. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  83588. /**
  83589. * Serializes the particle system to a JSON object.
  83590. * @returns the JSON object
  83591. */
  83592. serialize(): any;
  83593. /**
  83594. * Rebuild the particle system
  83595. */
  83596. rebuild(): void;
  83597. /**
  83598. * Starts the particle system and begins to emit
  83599. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  83600. */
  83601. start(delay?: number): void;
  83602. /**
  83603. * Stops the particle system.
  83604. */
  83605. stop(): void;
  83606. /**
  83607. * Remove all active particles
  83608. */
  83609. reset(): void;
  83610. /**
  83611. * Is this system ready to be used/rendered
  83612. * @return true if the system is ready
  83613. */
  83614. isReady(): boolean;
  83615. /**
  83616. * Adds a new color gradient
  83617. * @param gradient defines the gradient to use (between 0 and 1)
  83618. * @param color1 defines the color to affect to the specified gradient
  83619. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  83620. * @returns the current particle system
  83621. */
  83622. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  83623. /**
  83624. * Remove a specific color gradient
  83625. * @param gradient defines the gradient to remove
  83626. * @returns the current particle system
  83627. */
  83628. removeColorGradient(gradient: number): IParticleSystem;
  83629. /**
  83630. * Adds a new size gradient
  83631. * @param gradient defines the gradient to use (between 0 and 1)
  83632. * @param factor defines the size factor to affect to the specified gradient
  83633. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83634. * @returns the current particle system
  83635. */
  83636. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83637. /**
  83638. * Remove a specific size gradient
  83639. * @param gradient defines the gradient to remove
  83640. * @returns the current particle system
  83641. */
  83642. removeSizeGradient(gradient: number): IParticleSystem;
  83643. /**
  83644. * Gets the current list of color gradients.
  83645. * You must use addColorGradient and removeColorGradient to udpate this list
  83646. * @returns the list of color gradients
  83647. */
  83648. getColorGradients(): Nullable<Array<ColorGradient>>;
  83649. /**
  83650. * Gets the current list of size gradients.
  83651. * You must use addSizeGradient and removeSizeGradient to udpate this list
  83652. * @returns the list of size gradients
  83653. */
  83654. getSizeGradients(): Nullable<Array<FactorGradient>>;
  83655. /**
  83656. * Gets the current list of angular speed gradients.
  83657. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  83658. * @returns the list of angular speed gradients
  83659. */
  83660. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  83661. /**
  83662. * Adds a new angular speed gradient
  83663. * @param gradient defines the gradient to use (between 0 and 1)
  83664. * @param factor defines the angular speed to affect to the specified gradient
  83665. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83666. * @returns the current particle system
  83667. */
  83668. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83669. /**
  83670. * Remove a specific angular speed gradient
  83671. * @param gradient defines the gradient to remove
  83672. * @returns the current particle system
  83673. */
  83674. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  83675. /**
  83676. * Gets the current list of velocity gradients.
  83677. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  83678. * @returns the list of velocity gradients
  83679. */
  83680. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  83681. /**
  83682. * Adds a new velocity gradient
  83683. * @param gradient defines the gradient to use (between 0 and 1)
  83684. * @param factor defines the velocity to affect to the specified gradient
  83685. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83686. * @returns the current particle system
  83687. */
  83688. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83689. /**
  83690. * Remove a specific velocity gradient
  83691. * @param gradient defines the gradient to remove
  83692. * @returns the current particle system
  83693. */
  83694. removeVelocityGradient(gradient: number): IParticleSystem;
  83695. /**
  83696. * Gets the current list of limit velocity gradients.
  83697. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  83698. * @returns the list of limit velocity gradients
  83699. */
  83700. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  83701. /**
  83702. * Adds a new limit velocity gradient
  83703. * @param gradient defines the gradient to use (between 0 and 1)
  83704. * @param factor defines the limit velocity to affect to the specified gradient
  83705. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83706. * @returns the current particle system
  83707. */
  83708. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83709. /**
  83710. * Remove a specific limit velocity gradient
  83711. * @param gradient defines the gradient to remove
  83712. * @returns the current particle system
  83713. */
  83714. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  83715. /**
  83716. * Adds a new drag gradient
  83717. * @param gradient defines the gradient to use (between 0 and 1)
  83718. * @param factor defines the drag to affect to the specified gradient
  83719. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83720. * @returns the current particle system
  83721. */
  83722. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83723. /**
  83724. * Remove a specific drag gradient
  83725. * @param gradient defines the gradient to remove
  83726. * @returns the current particle system
  83727. */
  83728. removeDragGradient(gradient: number): IParticleSystem;
  83729. /**
  83730. * Gets the current list of drag gradients.
  83731. * You must use addDragGradient and removeDragGradient to udpate this list
  83732. * @returns the list of drag gradients
  83733. */
  83734. getDragGradients(): Nullable<Array<FactorGradient>>;
  83735. /**
  83736. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  83737. * @param gradient defines the gradient to use (between 0 and 1)
  83738. * @param factor defines the emit rate to affect to the specified gradient
  83739. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83740. * @returns the current particle system
  83741. */
  83742. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83743. /**
  83744. * Remove a specific emit rate gradient
  83745. * @param gradient defines the gradient to remove
  83746. * @returns the current particle system
  83747. */
  83748. removeEmitRateGradient(gradient: number): IParticleSystem;
  83749. /**
  83750. * Gets the current list of emit rate gradients.
  83751. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  83752. * @returns the list of emit rate gradients
  83753. */
  83754. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  83755. /**
  83756. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  83757. * @param gradient defines the gradient to use (between 0 and 1)
  83758. * @param factor defines the start size to affect to the specified gradient
  83759. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83760. * @returns the current particle system
  83761. */
  83762. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83763. /**
  83764. * Remove a specific start size gradient
  83765. * @param gradient defines the gradient to remove
  83766. * @returns the current particle system
  83767. */
  83768. removeStartSizeGradient(gradient: number): IParticleSystem;
  83769. /**
  83770. * Gets the current list of start size gradients.
  83771. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  83772. * @returns the list of start size gradients
  83773. */
  83774. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  83775. /**
  83776. * Adds a new life time gradient
  83777. * @param gradient defines the gradient to use (between 0 and 1)
  83778. * @param factor defines the life time factor to affect to the specified gradient
  83779. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83780. * @returns the current particle system
  83781. */
  83782. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83783. /**
  83784. * Remove a specific life time gradient
  83785. * @param gradient defines the gradient to remove
  83786. * @returns the current particle system
  83787. */
  83788. removeLifeTimeGradient(gradient: number): IParticleSystem;
  83789. /**
  83790. * Gets the current list of life time gradients.
  83791. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  83792. * @returns the list of life time gradients
  83793. */
  83794. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  83795. /**
  83796. * Gets the current list of color gradients.
  83797. * You must use addColorGradient and removeColorGradient to udpate this list
  83798. * @returns the list of color gradients
  83799. */
  83800. getColorGradients(): Nullable<Array<ColorGradient>>;
  83801. /**
  83802. * Adds a new ramp gradient used to remap particle colors
  83803. * @param gradient defines the gradient to use (between 0 and 1)
  83804. * @param color defines the color to affect to the specified gradient
  83805. * @returns the current particle system
  83806. */
  83807. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  83808. /**
  83809. * Gets the current list of ramp gradients.
  83810. * You must use addRampGradient and removeRampGradient to udpate this list
  83811. * @returns the list of ramp gradients
  83812. */
  83813. getRampGradients(): Nullable<Array<Color3Gradient>>;
  83814. /** Gets or sets a boolean indicating that ramp gradients must be used
  83815. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  83816. */
  83817. useRampGradients: boolean;
  83818. /**
  83819. * Adds a new color remap gradient
  83820. * @param gradient defines the gradient to use (between 0 and 1)
  83821. * @param min defines the color remap minimal range
  83822. * @param max defines the color remap maximal range
  83823. * @returns the current particle system
  83824. */
  83825. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83826. /**
  83827. * Gets the current list of color remap gradients.
  83828. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  83829. * @returns the list of color remap gradients
  83830. */
  83831. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  83832. /**
  83833. * Adds a new alpha remap gradient
  83834. * @param gradient defines the gradient to use (between 0 and 1)
  83835. * @param min defines the alpha remap minimal range
  83836. * @param max defines the alpha remap maximal range
  83837. * @returns the current particle system
  83838. */
  83839. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83840. /**
  83841. * Gets the current list of alpha remap gradients.
  83842. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  83843. * @returns the list of alpha remap gradients
  83844. */
  83845. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  83846. /**
  83847. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  83848. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83849. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83850. * @returns the emitter
  83851. */
  83852. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  83853. /**
  83854. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  83855. * @param radius The radius of the hemisphere to emit from
  83856. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83857. * @returns the emitter
  83858. */
  83859. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  83860. /**
  83861. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  83862. * @param radius The radius of the sphere to emit from
  83863. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83864. * @returns the emitter
  83865. */
  83866. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  83867. /**
  83868. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  83869. * @param radius The radius of the sphere to emit from
  83870. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  83871. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  83872. * @returns the emitter
  83873. */
  83874. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  83875. /**
  83876. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  83877. * @param radius The radius of the emission cylinder
  83878. * @param height The height of the emission cylinder
  83879. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  83880. * @param directionRandomizer How much to randomize the particle direction [0-1]
  83881. * @returns the emitter
  83882. */
  83883. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  83884. /**
  83885. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  83886. * @param radius The radius of the cylinder to emit from
  83887. * @param height The height of the emission cylinder
  83888. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83889. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  83890. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  83891. * @returns the emitter
  83892. */
  83893. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  83894. /**
  83895. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  83896. * @param radius The radius of the cone to emit from
  83897. * @param angle The base angle of the cone
  83898. * @returns the emitter
  83899. */
  83900. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  83901. /**
  83902. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  83903. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83904. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83905. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83906. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83907. * @returns the emitter
  83908. */
  83909. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  83910. /**
  83911. * Get hosting scene
  83912. * @returns the scene
  83913. */
  83914. getScene(): Scene;
  83915. }
  83916. }
  83917. declare module BABYLON {
  83918. /** @hidden */
  83919. export var linePixelShader: {
  83920. name: string;
  83921. shader: string;
  83922. };
  83923. }
  83924. declare module BABYLON {
  83925. /** @hidden */
  83926. export var lineVertexShader: {
  83927. name: string;
  83928. shader: string;
  83929. };
  83930. }
  83931. declare module BABYLON {
  83932. interface AbstractMesh {
  83933. /**
  83934. * Gets the edgesRenderer associated with the mesh
  83935. */
  83936. edgesRenderer: Nullable<EdgesRenderer>;
  83937. }
  83938. interface LinesMesh {
  83939. /**
  83940. * Enables the edge rendering mode on the mesh.
  83941. * This mode makes the mesh edges visible
  83942. * @param epsilon defines the maximal distance between two angles to detect a face
  83943. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  83944. * @returns the currentAbstractMesh
  83945. * @see https://www.babylonjs-playground.com/#19O9TU#0
  83946. */
  83947. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  83948. }
  83949. interface InstancedLinesMesh {
  83950. /**
  83951. * Enables the edge rendering mode on the mesh.
  83952. * This mode makes the mesh edges visible
  83953. * @param epsilon defines the maximal distance between two angles to detect a face
  83954. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  83955. * @returns the current InstancedLinesMesh
  83956. * @see https://www.babylonjs-playground.com/#19O9TU#0
  83957. */
  83958. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  83959. }
  83960. /**
  83961. * Defines the minimum contract an Edges renderer should follow.
  83962. */
  83963. export interface IEdgesRenderer extends IDisposable {
  83964. /**
  83965. * Gets or sets a boolean indicating if the edgesRenderer is active
  83966. */
  83967. isEnabled: boolean;
  83968. /**
  83969. * Renders the edges of the attached mesh,
  83970. */
  83971. render(): void;
  83972. /**
  83973. * Checks wether or not the edges renderer is ready to render.
  83974. * @return true if ready, otherwise false.
  83975. */
  83976. isReady(): boolean;
  83977. }
  83978. /**
  83979. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  83980. */
  83981. export class EdgesRenderer implements IEdgesRenderer {
  83982. /**
  83983. * Define the size of the edges with an orthographic camera
  83984. */
  83985. edgesWidthScalerForOrthographic: number;
  83986. /**
  83987. * Define the size of the edges with a perspective camera
  83988. */
  83989. edgesWidthScalerForPerspective: number;
  83990. protected _source: AbstractMesh;
  83991. protected _linesPositions: number[];
  83992. protected _linesNormals: number[];
  83993. protected _linesIndices: number[];
  83994. protected _epsilon: number;
  83995. protected _indicesCount: number;
  83996. protected _lineShader: ShaderMaterial;
  83997. protected _ib: DataBuffer;
  83998. protected _buffers: {
  83999. [key: string]: Nullable<VertexBuffer>;
  84000. };
  84001. protected _checkVerticesInsteadOfIndices: boolean;
  84002. private _meshRebuildObserver;
  84003. private _meshDisposeObserver;
  84004. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  84005. isEnabled: boolean;
  84006. /**
  84007. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  84008. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  84009. * @param source Mesh used to create edges
  84010. * @param epsilon sum of angles in adjacency to check for edge
  84011. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  84012. * @param generateEdgesLines - should generate Lines or only prepare resources.
  84013. */
  84014. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  84015. protected _prepareRessources(): void;
  84016. /** @hidden */
  84017. _rebuild(): void;
  84018. /**
  84019. * Releases the required resources for the edges renderer
  84020. */
  84021. dispose(): void;
  84022. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  84023. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  84024. /**
  84025. * Checks if the pair of p0 and p1 is en edge
  84026. * @param faceIndex
  84027. * @param edge
  84028. * @param faceNormals
  84029. * @param p0
  84030. * @param p1
  84031. * @private
  84032. */
  84033. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  84034. /**
  84035. * push line into the position, normal and index buffer
  84036. * @protected
  84037. */
  84038. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  84039. /**
  84040. * Generates lines edges from adjacencjes
  84041. * @private
  84042. */
  84043. _generateEdgesLines(): void;
  84044. /**
  84045. * Checks wether or not the edges renderer is ready to render.
  84046. * @return true if ready, otherwise false.
  84047. */
  84048. isReady(): boolean;
  84049. /**
  84050. * Renders the edges of the attached mesh,
  84051. */
  84052. render(): void;
  84053. }
  84054. /**
  84055. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  84056. */
  84057. export class LineEdgesRenderer extends EdgesRenderer {
  84058. /**
  84059. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  84060. * @param source LineMesh used to generate edges
  84061. * @param epsilon not important (specified angle for edge detection)
  84062. * @param checkVerticesInsteadOfIndices not important for LineMesh
  84063. */
  84064. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  84065. /**
  84066. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  84067. */
  84068. _generateEdgesLines(): void;
  84069. }
  84070. }
  84071. declare module BABYLON {
  84072. /**
  84073. * This represents the object necessary to create a rendering group.
  84074. * This is exclusively used and created by the rendering manager.
  84075. * To modify the behavior, you use the available helpers in your scene or meshes.
  84076. * @hidden
  84077. */
  84078. export class RenderingGroup {
  84079. index: number;
  84080. private static _zeroVector;
  84081. private _scene;
  84082. private _opaqueSubMeshes;
  84083. private _transparentSubMeshes;
  84084. private _alphaTestSubMeshes;
  84085. private _depthOnlySubMeshes;
  84086. private _particleSystems;
  84087. private _spriteManagers;
  84088. private _opaqueSortCompareFn;
  84089. private _alphaTestSortCompareFn;
  84090. private _transparentSortCompareFn;
  84091. private _renderOpaque;
  84092. private _renderAlphaTest;
  84093. private _renderTransparent;
  84094. /** @hidden */
  84095. _edgesRenderers: SmartArray<IEdgesRenderer>;
  84096. onBeforeTransparentRendering: () => void;
  84097. /**
  84098. * Set the opaque sort comparison function.
  84099. * If null the sub meshes will be render in the order they were created
  84100. */
  84101. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84102. /**
  84103. * Set the alpha test sort comparison function.
  84104. * If null the sub meshes will be render in the order they were created
  84105. */
  84106. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84107. /**
  84108. * Set the transparent sort comparison function.
  84109. * If null the sub meshes will be render in the order they were created
  84110. */
  84111. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  84112. /**
  84113. * Creates a new rendering group.
  84114. * @param index The rendering group index
  84115. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  84116. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  84117. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  84118. */
  84119. 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>);
  84120. /**
  84121. * Render all the sub meshes contained in the group.
  84122. * @param customRenderFunction Used to override the default render behaviour of the group.
  84123. * @returns true if rendered some submeshes.
  84124. */
  84125. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  84126. /**
  84127. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  84128. * @param subMeshes The submeshes to render
  84129. */
  84130. private renderOpaqueSorted;
  84131. /**
  84132. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  84133. * @param subMeshes The submeshes to render
  84134. */
  84135. private renderAlphaTestSorted;
  84136. /**
  84137. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  84138. * @param subMeshes The submeshes to render
  84139. */
  84140. private renderTransparentSorted;
  84141. /**
  84142. * Renders the submeshes in a specified order.
  84143. * @param subMeshes The submeshes to sort before render
  84144. * @param sortCompareFn The comparison function use to sort
  84145. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  84146. * @param transparent Specifies to activate blending if true
  84147. */
  84148. private static renderSorted;
  84149. /**
  84150. * Renders the submeshes in the order they were dispatched (no sort applied).
  84151. * @param subMeshes The submeshes to render
  84152. */
  84153. private static renderUnsorted;
  84154. /**
  84155. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84156. * are rendered back to front if in the same alpha index.
  84157. *
  84158. * @param a The first submesh
  84159. * @param b The second submesh
  84160. * @returns The result of the comparison
  84161. */
  84162. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  84163. /**
  84164. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84165. * are rendered back to front.
  84166. *
  84167. * @param a The first submesh
  84168. * @param b The second submesh
  84169. * @returns The result of the comparison
  84170. */
  84171. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  84172. /**
  84173. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  84174. * are rendered front to back (prevent overdraw).
  84175. *
  84176. * @param a The first submesh
  84177. * @param b The second submesh
  84178. * @returns The result of the comparison
  84179. */
  84180. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  84181. /**
  84182. * Resets the different lists of submeshes to prepare a new frame.
  84183. */
  84184. prepare(): void;
  84185. dispose(): void;
  84186. /**
  84187. * Inserts the submesh in its correct queue depending on its material.
  84188. * @param subMesh The submesh to dispatch
  84189. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84190. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84191. */
  84192. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84193. dispatchSprites(spriteManager: ISpriteManager): void;
  84194. dispatchParticles(particleSystem: IParticleSystem): void;
  84195. private _renderParticles;
  84196. private _renderSprites;
  84197. }
  84198. }
  84199. declare module BABYLON {
  84200. /**
  84201. * Interface describing the different options available in the rendering manager
  84202. * regarding Auto Clear between groups.
  84203. */
  84204. export interface IRenderingManagerAutoClearSetup {
  84205. /**
  84206. * Defines whether or not autoclear is enable.
  84207. */
  84208. autoClear: boolean;
  84209. /**
  84210. * Defines whether or not to autoclear the depth buffer.
  84211. */
  84212. depth: boolean;
  84213. /**
  84214. * Defines whether or not to autoclear the stencil buffer.
  84215. */
  84216. stencil: boolean;
  84217. }
  84218. /**
  84219. * This class is used by the onRenderingGroupObservable
  84220. */
  84221. export class RenderingGroupInfo {
  84222. /**
  84223. * The Scene that being rendered
  84224. */
  84225. scene: Scene;
  84226. /**
  84227. * The camera currently used for the rendering pass
  84228. */
  84229. camera: Nullable<Camera>;
  84230. /**
  84231. * The ID of the renderingGroup being processed
  84232. */
  84233. renderingGroupId: number;
  84234. }
  84235. /**
  84236. * This is the manager responsible of all the rendering for meshes sprites and particles.
  84237. * It is enable to manage the different groups as well as the different necessary sort functions.
  84238. * This should not be used directly aside of the few static configurations
  84239. */
  84240. export class RenderingManager {
  84241. /**
  84242. * The max id used for rendering groups (not included)
  84243. */
  84244. static MAX_RENDERINGGROUPS: number;
  84245. /**
  84246. * The min id used for rendering groups (included)
  84247. */
  84248. static MIN_RENDERINGGROUPS: number;
  84249. /**
  84250. * Used to globally prevent autoclearing scenes.
  84251. */
  84252. static AUTOCLEAR: boolean;
  84253. /**
  84254. * @hidden
  84255. */
  84256. _useSceneAutoClearSetup: boolean;
  84257. private _scene;
  84258. private _renderingGroups;
  84259. private _depthStencilBufferAlreadyCleaned;
  84260. private _autoClearDepthStencil;
  84261. private _customOpaqueSortCompareFn;
  84262. private _customAlphaTestSortCompareFn;
  84263. private _customTransparentSortCompareFn;
  84264. private _renderingGroupInfo;
  84265. /**
  84266. * Instantiates a new rendering group for a particular scene
  84267. * @param scene Defines the scene the groups belongs to
  84268. */
  84269. constructor(scene: Scene);
  84270. private _clearDepthStencilBuffer;
  84271. /**
  84272. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  84273. * @hidden
  84274. */
  84275. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  84276. /**
  84277. * Resets the different information of the group to prepare a new frame
  84278. * @hidden
  84279. */
  84280. reset(): void;
  84281. /**
  84282. * Dispose and release the group and its associated resources.
  84283. * @hidden
  84284. */
  84285. dispose(): void;
  84286. /**
  84287. * Clear the info related to rendering groups preventing retention points during dispose.
  84288. */
  84289. freeRenderingGroups(): void;
  84290. private _prepareRenderingGroup;
  84291. /**
  84292. * Add a sprite manager to the rendering manager in order to render it this frame.
  84293. * @param spriteManager Define the sprite manager to render
  84294. */
  84295. dispatchSprites(spriteManager: ISpriteManager): void;
  84296. /**
  84297. * Add a particle system to the rendering manager in order to render it this frame.
  84298. * @param particleSystem Define the particle system to render
  84299. */
  84300. dispatchParticles(particleSystem: IParticleSystem): void;
  84301. /**
  84302. * Add a submesh to the manager in order to render it this frame
  84303. * @param subMesh The submesh to dispatch
  84304. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  84305. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  84306. */
  84307. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  84308. /**
  84309. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84310. * This allowed control for front to back rendering or reversly depending of the special needs.
  84311. *
  84312. * @param renderingGroupId The rendering group id corresponding to its index
  84313. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84314. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84315. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84316. */
  84317. 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;
  84318. /**
  84319. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84320. *
  84321. * @param renderingGroupId The rendering group id corresponding to its index
  84322. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  84323. * @param depth Automatically clears depth between groups if true and autoClear is true.
  84324. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  84325. */
  84326. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  84327. /**
  84328. * Gets the current auto clear configuration for one rendering group of the rendering
  84329. * manager.
  84330. * @param index the rendering group index to get the information for
  84331. * @returns The auto clear setup for the requested rendering group
  84332. */
  84333. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  84334. }
  84335. }
  84336. declare module BABYLON {
  84337. /**
  84338. * This Helps creating a texture that will be created from a camera in your scene.
  84339. * It is basically a dynamic texture that could be used to create special effects for instance.
  84340. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  84341. */
  84342. export class RenderTargetTexture extends Texture {
  84343. isCube: boolean;
  84344. /**
  84345. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  84346. */
  84347. static readonly REFRESHRATE_RENDER_ONCE: number;
  84348. /**
  84349. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  84350. */
  84351. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  84352. /**
  84353. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  84354. * the central point of your effect and can save a lot of performances.
  84355. */
  84356. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  84357. /**
  84358. * Use this predicate to dynamically define the list of mesh you want to render.
  84359. * If set, the renderList property will be overwritten.
  84360. */
  84361. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  84362. private _renderList;
  84363. /**
  84364. * Use this list to define the list of mesh you want to render.
  84365. */
  84366. renderList: Nullable<Array<AbstractMesh>>;
  84367. private _hookArray;
  84368. /**
  84369. * Define if particles should be rendered in your texture.
  84370. */
  84371. renderParticles: boolean;
  84372. /**
  84373. * Define if sprites should be rendered in your texture.
  84374. */
  84375. renderSprites: boolean;
  84376. /**
  84377. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  84378. */
  84379. coordinatesMode: number;
  84380. /**
  84381. * Define the camera used to render the texture.
  84382. */
  84383. activeCamera: Nullable<Camera>;
  84384. /**
  84385. * Override the render function of the texture with your own one.
  84386. */
  84387. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  84388. /**
  84389. * Define if camera post processes should be use while rendering the texture.
  84390. */
  84391. useCameraPostProcesses: boolean;
  84392. /**
  84393. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  84394. */
  84395. ignoreCameraViewport: boolean;
  84396. private _postProcessManager;
  84397. private _postProcesses;
  84398. private _resizeObserver;
  84399. /**
  84400. * An event triggered when the texture is unbind.
  84401. */
  84402. onBeforeBindObservable: Observable<RenderTargetTexture>;
  84403. /**
  84404. * An event triggered when the texture is unbind.
  84405. */
  84406. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  84407. private _onAfterUnbindObserver;
  84408. /**
  84409. * Set a after unbind callback in the texture.
  84410. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  84411. */
  84412. onAfterUnbind: () => void;
  84413. /**
  84414. * An event triggered before rendering the texture
  84415. */
  84416. onBeforeRenderObservable: Observable<number>;
  84417. private _onBeforeRenderObserver;
  84418. /**
  84419. * Set a before render callback in the texture.
  84420. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  84421. */
  84422. onBeforeRender: (faceIndex: number) => void;
  84423. /**
  84424. * An event triggered after rendering the texture
  84425. */
  84426. onAfterRenderObservable: Observable<number>;
  84427. private _onAfterRenderObserver;
  84428. /**
  84429. * Set a after render callback in the texture.
  84430. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  84431. */
  84432. onAfterRender: (faceIndex: number) => void;
  84433. /**
  84434. * An event triggered after the texture clear
  84435. */
  84436. onClearObservable: Observable<Engine>;
  84437. private _onClearObserver;
  84438. /**
  84439. * Set a clear callback in the texture.
  84440. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  84441. */
  84442. onClear: (Engine: Engine) => void;
  84443. /**
  84444. * Define the clear color of the Render Target if it should be different from the scene.
  84445. */
  84446. clearColor: Color4;
  84447. protected _size: number | {
  84448. width: number;
  84449. height: number;
  84450. };
  84451. protected _initialSizeParameter: number | {
  84452. width: number;
  84453. height: number;
  84454. } | {
  84455. ratio: number;
  84456. };
  84457. protected _sizeRatio: Nullable<number>;
  84458. /** @hidden */
  84459. _generateMipMaps: boolean;
  84460. protected _renderingManager: RenderingManager;
  84461. /** @hidden */
  84462. _waitingRenderList: string[];
  84463. protected _doNotChangeAspectRatio: boolean;
  84464. protected _currentRefreshId: number;
  84465. protected _refreshRate: number;
  84466. protected _textureMatrix: Matrix;
  84467. protected _samples: number;
  84468. protected _renderTargetOptions: RenderTargetCreationOptions;
  84469. /**
  84470. * Gets render target creation options that were used.
  84471. */
  84472. readonly renderTargetOptions: RenderTargetCreationOptions;
  84473. protected _engine: Engine;
  84474. protected _onRatioRescale(): void;
  84475. /**
  84476. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  84477. * It must define where the camera used to render the texture is set
  84478. */
  84479. boundingBoxPosition: Vector3;
  84480. private _boundingBoxSize;
  84481. /**
  84482. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  84483. * When defined, the cubemap will switch to local mode
  84484. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  84485. * @example https://www.babylonjs-playground.com/#RNASML
  84486. */
  84487. boundingBoxSize: Vector3;
  84488. /**
  84489. * In case the RTT has been created with a depth texture, get the associated
  84490. * depth texture.
  84491. * Otherwise, return null.
  84492. */
  84493. depthStencilTexture: Nullable<InternalTexture>;
  84494. /**
  84495. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  84496. * or used a shadow, depth texture...
  84497. * @param name The friendly name of the texture
  84498. * @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)
  84499. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  84500. * @param generateMipMaps True if mip maps need to be generated after render.
  84501. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  84502. * @param type The type of the buffer in the RTT (int, half float, float...)
  84503. * @param isCube True if a cube texture needs to be created
  84504. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  84505. * @param generateDepthBuffer True to generate a depth buffer
  84506. * @param generateStencilBuffer True to generate a stencil buffer
  84507. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  84508. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  84509. * @param delayAllocation if the texture allocation should be delayed (default: false)
  84510. */
  84511. constructor(name: string, size: number | {
  84512. width: number;
  84513. height: number;
  84514. } | {
  84515. ratio: number;
  84516. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  84517. /**
  84518. * Creates a depth stencil texture.
  84519. * This is only available in WebGL 2 or with the depth texture extension available.
  84520. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  84521. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  84522. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  84523. */
  84524. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  84525. private _processSizeParameter;
  84526. /**
  84527. * Define the number of samples to use in case of MSAA.
  84528. * It defaults to one meaning no MSAA has been enabled.
  84529. */
  84530. samples: number;
  84531. /**
  84532. * Resets the refresh counter of the texture and start bak from scratch.
  84533. * Could be useful to regenerate the texture if it is setup to render only once.
  84534. */
  84535. resetRefreshCounter(): void;
  84536. /**
  84537. * Define the refresh rate of the texture or the rendering frequency.
  84538. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84539. */
  84540. refreshRate: number;
  84541. /**
  84542. * Adds a post process to the render target rendering passes.
  84543. * @param postProcess define the post process to add
  84544. */
  84545. addPostProcess(postProcess: PostProcess): void;
  84546. /**
  84547. * Clear all the post processes attached to the render target
  84548. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  84549. */
  84550. clearPostProcesses(dispose?: boolean): void;
  84551. /**
  84552. * Remove one of the post process from the list of attached post processes to the texture
  84553. * @param postProcess define the post process to remove from the list
  84554. */
  84555. removePostProcess(postProcess: PostProcess): void;
  84556. /** @hidden */
  84557. _shouldRender(): boolean;
  84558. /**
  84559. * Gets the actual render size of the texture.
  84560. * @returns the width of the render size
  84561. */
  84562. getRenderSize(): number;
  84563. /**
  84564. * Gets the actual render width of the texture.
  84565. * @returns the width of the render size
  84566. */
  84567. getRenderWidth(): number;
  84568. /**
  84569. * Gets the actual render height of the texture.
  84570. * @returns the height of the render size
  84571. */
  84572. getRenderHeight(): number;
  84573. /**
  84574. * Get if the texture can be rescaled or not.
  84575. */
  84576. readonly canRescale: boolean;
  84577. /**
  84578. * Resize the texture using a ratio.
  84579. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  84580. */
  84581. scale(ratio: number): void;
  84582. /**
  84583. * Get the texture reflection matrix used to rotate/transform the reflection.
  84584. * @returns the reflection matrix
  84585. */
  84586. getReflectionTextureMatrix(): Matrix;
  84587. /**
  84588. * Resize the texture to a new desired size.
  84589. * Be carrefull as it will recreate all the data in the new texture.
  84590. * @param size Define the new size. It can be:
  84591. * - a number for squared texture,
  84592. * - an object containing { width: number, height: number }
  84593. * - or an object containing a ratio { ratio: number }
  84594. */
  84595. resize(size: number | {
  84596. width: number;
  84597. height: number;
  84598. } | {
  84599. ratio: number;
  84600. }): void;
  84601. /**
  84602. * Renders all the objects from the render list into the texture.
  84603. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  84604. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  84605. */
  84606. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  84607. private _bestReflectionRenderTargetDimension;
  84608. /**
  84609. * @hidden
  84610. * @param faceIndex face index to bind to if this is a cubetexture
  84611. */
  84612. _bindFrameBuffer(faceIndex?: number): void;
  84613. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  84614. private renderToTarget;
  84615. /**
  84616. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  84617. * This allowed control for front to back rendering or reversly depending of the special needs.
  84618. *
  84619. * @param renderingGroupId The rendering group id corresponding to its index
  84620. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  84621. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  84622. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  84623. */
  84624. 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;
  84625. /**
  84626. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  84627. *
  84628. * @param renderingGroupId The rendering group id corresponding to its index
  84629. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  84630. */
  84631. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  84632. /**
  84633. * Clones the texture.
  84634. * @returns the cloned texture
  84635. */
  84636. clone(): RenderTargetTexture;
  84637. /**
  84638. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  84639. * @returns The JSON representation of the texture
  84640. */
  84641. serialize(): any;
  84642. /**
  84643. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  84644. */
  84645. disposeFramebufferObjects(): void;
  84646. /**
  84647. * Dispose the texture and release its associated resources.
  84648. */
  84649. dispose(): void;
  84650. /** @hidden */
  84651. _rebuild(): void;
  84652. /**
  84653. * Clear the info related to rendering groups preventing retention point in material dispose.
  84654. */
  84655. freeRenderingGroups(): void;
  84656. /**
  84657. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  84658. * @returns the view count
  84659. */
  84660. getViewCount(): number;
  84661. }
  84662. }
  84663. declare module BABYLON {
  84664. /**
  84665. * Base class for the main features of a material in Babylon.js
  84666. */
  84667. export class Material implements IAnimatable {
  84668. /**
  84669. * Returns the triangle fill mode
  84670. */
  84671. static readonly TriangleFillMode: number;
  84672. /**
  84673. * Returns the wireframe mode
  84674. */
  84675. static readonly WireFrameFillMode: number;
  84676. /**
  84677. * Returns the point fill mode
  84678. */
  84679. static readonly PointFillMode: number;
  84680. /**
  84681. * Returns the point list draw mode
  84682. */
  84683. static readonly PointListDrawMode: number;
  84684. /**
  84685. * Returns the line list draw mode
  84686. */
  84687. static readonly LineListDrawMode: number;
  84688. /**
  84689. * Returns the line loop draw mode
  84690. */
  84691. static readonly LineLoopDrawMode: number;
  84692. /**
  84693. * Returns the line strip draw mode
  84694. */
  84695. static readonly LineStripDrawMode: number;
  84696. /**
  84697. * Returns the triangle strip draw mode
  84698. */
  84699. static readonly TriangleStripDrawMode: number;
  84700. /**
  84701. * Returns the triangle fan draw mode
  84702. */
  84703. static readonly TriangleFanDrawMode: number;
  84704. /**
  84705. * Stores the clock-wise side orientation
  84706. */
  84707. static readonly ClockWiseSideOrientation: number;
  84708. /**
  84709. * Stores the counter clock-wise side orientation
  84710. */
  84711. static readonly CounterClockWiseSideOrientation: number;
  84712. /**
  84713. * The dirty texture flag value
  84714. */
  84715. static readonly TextureDirtyFlag: number;
  84716. /**
  84717. * The dirty light flag value
  84718. */
  84719. static readonly LightDirtyFlag: number;
  84720. /**
  84721. * The dirty fresnel flag value
  84722. */
  84723. static readonly FresnelDirtyFlag: number;
  84724. /**
  84725. * The dirty attribute flag value
  84726. */
  84727. static readonly AttributesDirtyFlag: number;
  84728. /**
  84729. * The dirty misc flag value
  84730. */
  84731. static readonly MiscDirtyFlag: number;
  84732. /**
  84733. * The all dirty flag value
  84734. */
  84735. static readonly AllDirtyFlag: number;
  84736. /**
  84737. * The ID of the material
  84738. */
  84739. id: string;
  84740. /**
  84741. * Gets or sets the unique id of the material
  84742. */
  84743. uniqueId: number;
  84744. /**
  84745. * The name of the material
  84746. */
  84747. name: string;
  84748. /**
  84749. * Gets or sets user defined metadata
  84750. */
  84751. metadata: any;
  84752. /**
  84753. * For internal use only. Please do not use.
  84754. */
  84755. reservedDataStore: any;
  84756. /**
  84757. * Specifies if the ready state should be checked on each call
  84758. */
  84759. checkReadyOnEveryCall: boolean;
  84760. /**
  84761. * Specifies if the ready state should be checked once
  84762. */
  84763. checkReadyOnlyOnce: boolean;
  84764. /**
  84765. * The state of the material
  84766. */
  84767. state: string;
  84768. /**
  84769. * The alpha value of the material
  84770. */
  84771. protected _alpha: number;
  84772. /**
  84773. * List of inspectable custom properties (used by the Inspector)
  84774. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84775. */
  84776. inspectableCustomProperties: IInspectable[];
  84777. /**
  84778. * Sets the alpha value of the material
  84779. */
  84780. /**
  84781. * Gets the alpha value of the material
  84782. */
  84783. alpha: number;
  84784. /**
  84785. * Specifies if back face culling is enabled
  84786. */
  84787. protected _backFaceCulling: boolean;
  84788. /**
  84789. * Sets the back-face culling state
  84790. */
  84791. /**
  84792. * Gets the back-face culling state
  84793. */
  84794. backFaceCulling: boolean;
  84795. /**
  84796. * Stores the value for side orientation
  84797. */
  84798. sideOrientation: number;
  84799. /**
  84800. * Callback triggered when the material is compiled
  84801. */
  84802. onCompiled: Nullable<(effect: Effect) => void>;
  84803. /**
  84804. * Callback triggered when an error occurs
  84805. */
  84806. onError: Nullable<(effect: Effect, errors: string) => void>;
  84807. /**
  84808. * Callback triggered to get the render target textures
  84809. */
  84810. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  84811. /**
  84812. * Gets a boolean indicating that current material needs to register RTT
  84813. */
  84814. readonly hasRenderTargetTextures: boolean;
  84815. /**
  84816. * Specifies if the material should be serialized
  84817. */
  84818. doNotSerialize: boolean;
  84819. /**
  84820. * @hidden
  84821. */
  84822. _storeEffectOnSubMeshes: boolean;
  84823. /**
  84824. * Stores the animations for the material
  84825. */
  84826. animations: Nullable<Array<Animation>>;
  84827. /**
  84828. * An event triggered when the material is disposed
  84829. */
  84830. onDisposeObservable: Observable<Material>;
  84831. /**
  84832. * An observer which watches for dispose events
  84833. */
  84834. private _onDisposeObserver;
  84835. private _onUnBindObservable;
  84836. /**
  84837. * Called during a dispose event
  84838. */
  84839. onDispose: () => void;
  84840. private _onBindObservable;
  84841. /**
  84842. * An event triggered when the material is bound
  84843. */
  84844. readonly onBindObservable: Observable<AbstractMesh>;
  84845. /**
  84846. * An observer which watches for bind events
  84847. */
  84848. private _onBindObserver;
  84849. /**
  84850. * Called during a bind event
  84851. */
  84852. onBind: (Mesh: AbstractMesh) => void;
  84853. /**
  84854. * An event triggered when the material is unbound
  84855. */
  84856. readonly onUnBindObservable: Observable<Material>;
  84857. /**
  84858. * Stores the value of the alpha mode
  84859. */
  84860. private _alphaMode;
  84861. /**
  84862. * Sets the value of the alpha mode.
  84863. *
  84864. * | Value | Type | Description |
  84865. * | --- | --- | --- |
  84866. * | 0 | ALPHA_DISABLE | |
  84867. * | 1 | ALPHA_ADD | |
  84868. * | 2 | ALPHA_COMBINE | |
  84869. * | 3 | ALPHA_SUBTRACT | |
  84870. * | 4 | ALPHA_MULTIPLY | |
  84871. * | 5 | ALPHA_MAXIMIZED | |
  84872. * | 6 | ALPHA_ONEONE | |
  84873. * | 7 | ALPHA_PREMULTIPLIED | |
  84874. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  84875. * | 9 | ALPHA_INTERPOLATE | |
  84876. * | 10 | ALPHA_SCREENMODE | |
  84877. *
  84878. */
  84879. /**
  84880. * Gets the value of the alpha mode
  84881. */
  84882. alphaMode: number;
  84883. /**
  84884. * Stores the state of the need depth pre-pass value
  84885. */
  84886. private _needDepthPrePass;
  84887. /**
  84888. * Sets the need depth pre-pass value
  84889. */
  84890. /**
  84891. * Gets the depth pre-pass value
  84892. */
  84893. needDepthPrePass: boolean;
  84894. /**
  84895. * Specifies if depth writing should be disabled
  84896. */
  84897. disableDepthWrite: boolean;
  84898. /**
  84899. * Specifies if depth writing should be forced
  84900. */
  84901. forceDepthWrite: boolean;
  84902. /**
  84903. * Specifies if there should be a separate pass for culling
  84904. */
  84905. separateCullingPass: boolean;
  84906. /**
  84907. * Stores the state specifing if fog should be enabled
  84908. */
  84909. private _fogEnabled;
  84910. /**
  84911. * Sets the state for enabling fog
  84912. */
  84913. /**
  84914. * Gets the value of the fog enabled state
  84915. */
  84916. fogEnabled: boolean;
  84917. /**
  84918. * Stores the size of points
  84919. */
  84920. pointSize: number;
  84921. /**
  84922. * Stores the z offset value
  84923. */
  84924. zOffset: number;
  84925. /**
  84926. * Gets a value specifying if wireframe mode is enabled
  84927. */
  84928. /**
  84929. * Sets the state of wireframe mode
  84930. */
  84931. wireframe: boolean;
  84932. /**
  84933. * Gets the value specifying if point clouds are enabled
  84934. */
  84935. /**
  84936. * Sets the state of point cloud mode
  84937. */
  84938. pointsCloud: boolean;
  84939. /**
  84940. * Gets the material fill mode
  84941. */
  84942. /**
  84943. * Sets the material fill mode
  84944. */
  84945. fillMode: number;
  84946. /**
  84947. * @hidden
  84948. * Stores the effects for the material
  84949. */
  84950. _effect: Nullable<Effect>;
  84951. /**
  84952. * @hidden
  84953. * Specifies if the material was previously ready
  84954. */
  84955. _wasPreviouslyReady: boolean;
  84956. /**
  84957. * Specifies if uniform buffers should be used
  84958. */
  84959. private _useUBO;
  84960. /**
  84961. * Stores a reference to the scene
  84962. */
  84963. private _scene;
  84964. /**
  84965. * Stores the fill mode state
  84966. */
  84967. private _fillMode;
  84968. /**
  84969. * Specifies if the depth write state should be cached
  84970. */
  84971. private _cachedDepthWriteState;
  84972. /**
  84973. * Stores the uniform buffer
  84974. */
  84975. protected _uniformBuffer: UniformBuffer;
  84976. /** @hidden */
  84977. _indexInSceneMaterialArray: number;
  84978. /** @hidden */
  84979. meshMap: Nullable<{
  84980. [id: string]: AbstractMesh | undefined;
  84981. }>;
  84982. /**
  84983. * Creates a material instance
  84984. * @param name defines the name of the material
  84985. * @param scene defines the scene to reference
  84986. * @param doNotAdd specifies if the material should be added to the scene
  84987. */
  84988. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  84989. /**
  84990. * Returns a string representation of the current material
  84991. * @param fullDetails defines a boolean indicating which levels of logging is desired
  84992. * @returns a string with material information
  84993. */
  84994. toString(fullDetails?: boolean): string;
  84995. /**
  84996. * Gets the class name of the material
  84997. * @returns a string with the class name of the material
  84998. */
  84999. getClassName(): string;
  85000. /**
  85001. * Specifies if updates for the material been locked
  85002. */
  85003. readonly isFrozen: boolean;
  85004. /**
  85005. * Locks updates for the material
  85006. */
  85007. freeze(): void;
  85008. /**
  85009. * Unlocks updates for the material
  85010. */
  85011. unfreeze(): void;
  85012. /**
  85013. * Specifies if the material is ready to be used
  85014. * @param mesh defines the mesh to check
  85015. * @param useInstances specifies if instances should be used
  85016. * @returns a boolean indicating if the material is ready to be used
  85017. */
  85018. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  85019. /**
  85020. * Specifies that the submesh is ready to be used
  85021. * @param mesh defines the mesh to check
  85022. * @param subMesh defines which submesh to check
  85023. * @param useInstances specifies that instances should be used
  85024. * @returns a boolean indicating that the submesh is ready or not
  85025. */
  85026. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  85027. /**
  85028. * Returns the material effect
  85029. * @returns the effect associated with the material
  85030. */
  85031. getEffect(): Nullable<Effect>;
  85032. /**
  85033. * Returns the current scene
  85034. * @returns a Scene
  85035. */
  85036. getScene(): Scene;
  85037. /**
  85038. * Specifies if the material will require alpha blending
  85039. * @returns a boolean specifying if alpha blending is needed
  85040. */
  85041. needAlphaBlending(): boolean;
  85042. /**
  85043. * Specifies if the mesh will require alpha blending
  85044. * @param mesh defines the mesh to check
  85045. * @returns a boolean specifying if alpha blending is needed for the mesh
  85046. */
  85047. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  85048. /**
  85049. * Specifies if this material should be rendered in alpha test mode
  85050. * @returns a boolean specifying if an alpha test is needed.
  85051. */
  85052. needAlphaTesting(): boolean;
  85053. /**
  85054. * Gets the texture used for the alpha test
  85055. * @returns the texture to use for alpha testing
  85056. */
  85057. getAlphaTestTexture(): Nullable<BaseTexture>;
  85058. /**
  85059. * Marks the material to indicate that it needs to be re-calculated
  85060. */
  85061. markDirty(): void;
  85062. /** @hidden */
  85063. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  85064. /**
  85065. * Binds the material to the mesh
  85066. * @param world defines the world transformation matrix
  85067. * @param mesh defines the mesh to bind the material to
  85068. */
  85069. bind(world: Matrix, mesh?: Mesh): void;
  85070. /**
  85071. * Binds the submesh to the material
  85072. * @param world defines the world transformation matrix
  85073. * @param mesh defines the mesh containing the submesh
  85074. * @param subMesh defines the submesh to bind the material to
  85075. */
  85076. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  85077. /**
  85078. * Binds the world matrix to the material
  85079. * @param world defines the world transformation matrix
  85080. */
  85081. bindOnlyWorldMatrix(world: Matrix): void;
  85082. /**
  85083. * Binds the scene's uniform buffer to the effect.
  85084. * @param effect defines the effect to bind to the scene uniform buffer
  85085. * @param sceneUbo defines the uniform buffer storing scene data
  85086. */
  85087. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  85088. /**
  85089. * Binds the view matrix to the effect
  85090. * @param effect defines the effect to bind the view matrix to
  85091. */
  85092. bindView(effect: Effect): void;
  85093. /**
  85094. * Binds the view projection matrix to the effect
  85095. * @param effect defines the effect to bind the view projection matrix to
  85096. */
  85097. bindViewProjection(effect: Effect): void;
  85098. /**
  85099. * Specifies if material alpha testing should be turned on for the mesh
  85100. * @param mesh defines the mesh to check
  85101. */
  85102. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  85103. /**
  85104. * Processes to execute after binding the material to a mesh
  85105. * @param mesh defines the rendered mesh
  85106. */
  85107. protected _afterBind(mesh?: Mesh): void;
  85108. /**
  85109. * Unbinds the material from the mesh
  85110. */
  85111. unbind(): void;
  85112. /**
  85113. * Gets the active textures from the material
  85114. * @returns an array of textures
  85115. */
  85116. getActiveTextures(): BaseTexture[];
  85117. /**
  85118. * Specifies if the material uses a texture
  85119. * @param texture defines the texture to check against the material
  85120. * @returns a boolean specifying if the material uses the texture
  85121. */
  85122. hasTexture(texture: BaseTexture): boolean;
  85123. /**
  85124. * Makes a duplicate of the material, and gives it a new name
  85125. * @param name defines the new name for the duplicated material
  85126. * @returns the cloned material
  85127. */
  85128. clone(name: string): Nullable<Material>;
  85129. /**
  85130. * Gets the meshes bound to the material
  85131. * @returns an array of meshes bound to the material
  85132. */
  85133. getBindedMeshes(): AbstractMesh[];
  85134. /**
  85135. * Force shader compilation
  85136. * @param mesh defines the mesh associated with this material
  85137. * @param onCompiled defines a function to execute once the material is compiled
  85138. * @param options defines the options to configure the compilation
  85139. */
  85140. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  85141. clipPlane: boolean;
  85142. }>): void;
  85143. /**
  85144. * Force shader compilation
  85145. * @param mesh defines the mesh that will use this material
  85146. * @param options defines additional options for compiling the shaders
  85147. * @returns a promise that resolves when the compilation completes
  85148. */
  85149. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  85150. clipPlane: boolean;
  85151. }>): Promise<void>;
  85152. private static readonly _AllDirtyCallBack;
  85153. private static readonly _ImageProcessingDirtyCallBack;
  85154. private static readonly _TextureDirtyCallBack;
  85155. private static readonly _FresnelDirtyCallBack;
  85156. private static readonly _MiscDirtyCallBack;
  85157. private static readonly _LightsDirtyCallBack;
  85158. private static readonly _AttributeDirtyCallBack;
  85159. private static _FresnelAndMiscDirtyCallBack;
  85160. private static _TextureAndMiscDirtyCallBack;
  85161. private static readonly _DirtyCallbackArray;
  85162. private static readonly _RunDirtyCallBacks;
  85163. /**
  85164. * Marks a define in the material to indicate that it needs to be re-computed
  85165. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  85166. */
  85167. markAsDirty(flag: number): void;
  85168. /**
  85169. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  85170. * @param func defines a function which checks material defines against the submeshes
  85171. */
  85172. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  85173. /**
  85174. * Indicates that we need to re-calculated for all submeshes
  85175. */
  85176. protected _markAllSubMeshesAsAllDirty(): void;
  85177. /**
  85178. * Indicates that image processing needs to be re-calculated for all submeshes
  85179. */
  85180. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  85181. /**
  85182. * Indicates that textures need to be re-calculated for all submeshes
  85183. */
  85184. protected _markAllSubMeshesAsTexturesDirty(): void;
  85185. /**
  85186. * Indicates that fresnel needs to be re-calculated for all submeshes
  85187. */
  85188. protected _markAllSubMeshesAsFresnelDirty(): void;
  85189. /**
  85190. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  85191. */
  85192. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  85193. /**
  85194. * Indicates that lights need to be re-calculated for all submeshes
  85195. */
  85196. protected _markAllSubMeshesAsLightsDirty(): void;
  85197. /**
  85198. * Indicates that attributes need to be re-calculated for all submeshes
  85199. */
  85200. protected _markAllSubMeshesAsAttributesDirty(): void;
  85201. /**
  85202. * Indicates that misc needs to be re-calculated for all submeshes
  85203. */
  85204. protected _markAllSubMeshesAsMiscDirty(): void;
  85205. /**
  85206. * Indicates that textures and misc need to be re-calculated for all submeshes
  85207. */
  85208. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  85209. /**
  85210. * Disposes the material
  85211. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85212. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  85213. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  85214. */
  85215. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  85216. /** @hidden */
  85217. private releaseVertexArrayObject;
  85218. /**
  85219. * Serializes this material
  85220. * @returns the serialized material object
  85221. */
  85222. serialize(): any;
  85223. /**
  85224. * Creates a material from parsed material data
  85225. * @param parsedMaterial defines parsed material data
  85226. * @param scene defines the hosting scene
  85227. * @param rootUrl defines the root URL to use to load textures
  85228. * @returns a new material
  85229. */
  85230. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  85231. }
  85232. }
  85233. declare module BABYLON {
  85234. /**
  85235. * Base class for submeshes
  85236. */
  85237. export class BaseSubMesh {
  85238. /** @hidden */
  85239. _materialDefines: Nullable<MaterialDefines>;
  85240. /** @hidden */
  85241. _materialEffect: Nullable<Effect>;
  85242. /**
  85243. * Gets associated effect
  85244. */
  85245. readonly effect: Nullable<Effect>;
  85246. /**
  85247. * Sets associated effect (effect used to render this submesh)
  85248. * @param effect defines the effect to associate with
  85249. * @param defines defines the set of defines used to compile this effect
  85250. */
  85251. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  85252. }
  85253. /**
  85254. * Defines a subdivision inside a mesh
  85255. */
  85256. export class SubMesh extends BaseSubMesh implements ICullable {
  85257. /** the material index to use */
  85258. materialIndex: number;
  85259. /** vertex index start */
  85260. verticesStart: number;
  85261. /** vertices count */
  85262. verticesCount: number;
  85263. /** index start */
  85264. indexStart: number;
  85265. /** indices count */
  85266. indexCount: number;
  85267. /** @hidden */
  85268. _linesIndexCount: number;
  85269. private _mesh;
  85270. private _renderingMesh;
  85271. private _boundingInfo;
  85272. private _linesIndexBuffer;
  85273. /** @hidden */
  85274. _lastColliderWorldVertices: Nullable<Vector3[]>;
  85275. /** @hidden */
  85276. _trianglePlanes: Plane[];
  85277. /** @hidden */
  85278. _lastColliderTransformMatrix: Nullable<Matrix>;
  85279. /** @hidden */
  85280. _renderId: number;
  85281. /** @hidden */
  85282. _alphaIndex: number;
  85283. /** @hidden */
  85284. _distanceToCamera: number;
  85285. /** @hidden */
  85286. _id: number;
  85287. private _currentMaterial;
  85288. /**
  85289. * Add a new submesh to a mesh
  85290. * @param materialIndex defines the material index to use
  85291. * @param verticesStart defines vertex index start
  85292. * @param verticesCount defines vertices count
  85293. * @param indexStart defines index start
  85294. * @param indexCount defines indices count
  85295. * @param mesh defines the parent mesh
  85296. * @param renderingMesh defines an optional rendering mesh
  85297. * @param createBoundingBox defines if bounding box should be created for this submesh
  85298. * @returns the new submesh
  85299. */
  85300. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  85301. /**
  85302. * Creates a new submesh
  85303. * @param materialIndex defines the material index to use
  85304. * @param verticesStart defines vertex index start
  85305. * @param verticesCount defines vertices count
  85306. * @param indexStart defines index start
  85307. * @param indexCount defines indices count
  85308. * @param mesh defines the parent mesh
  85309. * @param renderingMesh defines an optional rendering mesh
  85310. * @param createBoundingBox defines if bounding box should be created for this submesh
  85311. */
  85312. constructor(
  85313. /** the material index to use */
  85314. materialIndex: number,
  85315. /** vertex index start */
  85316. verticesStart: number,
  85317. /** vertices count */
  85318. verticesCount: number,
  85319. /** index start */
  85320. indexStart: number,
  85321. /** indices count */
  85322. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  85323. /**
  85324. * Returns true if this submesh covers the entire parent mesh
  85325. * @ignorenaming
  85326. */
  85327. readonly IsGlobal: boolean;
  85328. /**
  85329. * Returns the submesh BoudingInfo object
  85330. * @returns current bounding info (or mesh's one if the submesh is global)
  85331. */
  85332. getBoundingInfo(): BoundingInfo;
  85333. /**
  85334. * Sets the submesh BoundingInfo
  85335. * @param boundingInfo defines the new bounding info to use
  85336. * @returns the SubMesh
  85337. */
  85338. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  85339. /**
  85340. * Returns the mesh of the current submesh
  85341. * @return the parent mesh
  85342. */
  85343. getMesh(): AbstractMesh;
  85344. /**
  85345. * Returns the rendering mesh of the submesh
  85346. * @returns the rendering mesh (could be different from parent mesh)
  85347. */
  85348. getRenderingMesh(): Mesh;
  85349. /**
  85350. * Returns the submesh material
  85351. * @returns null or the current material
  85352. */
  85353. getMaterial(): Nullable<Material>;
  85354. /**
  85355. * Sets a new updated BoundingInfo object to the submesh
  85356. * @param data defines an optional position array to use to determine the bounding info
  85357. * @returns the SubMesh
  85358. */
  85359. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  85360. /** @hidden */
  85361. _checkCollision(collider: Collider): boolean;
  85362. /**
  85363. * Updates the submesh BoundingInfo
  85364. * @param world defines the world matrix to use to update the bounding info
  85365. * @returns the submesh
  85366. */
  85367. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  85368. /**
  85369. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  85370. * @param frustumPlanes defines the frustum planes
  85371. * @returns true if the submesh is intersecting with the frustum
  85372. */
  85373. isInFrustum(frustumPlanes: Plane[]): boolean;
  85374. /**
  85375. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  85376. * @param frustumPlanes defines the frustum planes
  85377. * @returns true if the submesh is inside the frustum
  85378. */
  85379. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  85380. /**
  85381. * Renders the submesh
  85382. * @param enableAlphaMode defines if alpha needs to be used
  85383. * @returns the submesh
  85384. */
  85385. render(enableAlphaMode: boolean): SubMesh;
  85386. /**
  85387. * @hidden
  85388. */
  85389. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  85390. /**
  85391. * Checks if the submesh intersects with a ray
  85392. * @param ray defines the ray to test
  85393. * @returns true is the passed ray intersects the submesh bounding box
  85394. */
  85395. canIntersects(ray: Ray): boolean;
  85396. /**
  85397. * Intersects current submesh with a ray
  85398. * @param ray defines the ray to test
  85399. * @param positions defines mesh's positions array
  85400. * @param indices defines mesh's indices array
  85401. * @param fastCheck defines if only bounding info should be used
  85402. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  85403. * @returns intersection info or null if no intersection
  85404. */
  85405. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  85406. /** @hidden */
  85407. private _intersectLines;
  85408. /** @hidden */
  85409. private _intersectUnIndexedLines;
  85410. /** @hidden */
  85411. private _intersectTriangles;
  85412. /** @hidden */
  85413. private _intersectUnIndexedTriangles;
  85414. /** @hidden */
  85415. _rebuild(): void;
  85416. /**
  85417. * Creates a new submesh from the passed mesh
  85418. * @param newMesh defines the new hosting mesh
  85419. * @param newRenderingMesh defines an optional rendering mesh
  85420. * @returns the new submesh
  85421. */
  85422. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  85423. /**
  85424. * Release associated resources
  85425. */
  85426. dispose(): void;
  85427. /**
  85428. * Gets the class name
  85429. * @returns the string "SubMesh".
  85430. */
  85431. getClassName(): string;
  85432. /**
  85433. * Creates a new submesh from indices data
  85434. * @param materialIndex the index of the main mesh material
  85435. * @param startIndex the index where to start the copy in the mesh indices array
  85436. * @param indexCount the number of indices to copy then from the startIndex
  85437. * @param mesh the main mesh to create the submesh from
  85438. * @param renderingMesh the optional rendering mesh
  85439. * @returns a new submesh
  85440. */
  85441. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  85442. }
  85443. }
  85444. declare module BABYLON {
  85445. /**
  85446. * Class used to store geometry data (vertex buffers + index buffer)
  85447. */
  85448. export class Geometry implements IGetSetVerticesData {
  85449. /**
  85450. * Gets or sets the ID of the geometry
  85451. */
  85452. id: string;
  85453. /**
  85454. * Gets or sets the unique ID of the geometry
  85455. */
  85456. uniqueId: number;
  85457. /**
  85458. * Gets the delay loading state of the geometry (none by default which means not delayed)
  85459. */
  85460. delayLoadState: number;
  85461. /**
  85462. * Gets the file containing the data to load when running in delay load state
  85463. */
  85464. delayLoadingFile: Nullable<string>;
  85465. /**
  85466. * Callback called when the geometry is updated
  85467. */
  85468. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  85469. private _scene;
  85470. private _engine;
  85471. private _meshes;
  85472. private _totalVertices;
  85473. /** @hidden */
  85474. _indices: IndicesArray;
  85475. /** @hidden */
  85476. _vertexBuffers: {
  85477. [key: string]: VertexBuffer;
  85478. };
  85479. private _isDisposed;
  85480. private _extend;
  85481. private _boundingBias;
  85482. /** @hidden */
  85483. _delayInfo: Array<string>;
  85484. private _indexBuffer;
  85485. private _indexBufferIsUpdatable;
  85486. /** @hidden */
  85487. _boundingInfo: Nullable<BoundingInfo>;
  85488. /** @hidden */
  85489. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  85490. /** @hidden */
  85491. _softwareSkinningFrameId: number;
  85492. private _vertexArrayObjects;
  85493. private _updatable;
  85494. /** @hidden */
  85495. _positions: Nullable<Vector3[]>;
  85496. /**
  85497. * 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
  85498. */
  85499. /**
  85500. * 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
  85501. */
  85502. boundingBias: Vector2;
  85503. /**
  85504. * Static function used to attach a new empty geometry to a mesh
  85505. * @param mesh defines the mesh to attach the geometry to
  85506. * @returns the new Geometry
  85507. */
  85508. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  85509. /**
  85510. * Creates a new geometry
  85511. * @param id defines the unique ID
  85512. * @param scene defines the hosting scene
  85513. * @param vertexData defines the VertexData used to get geometry data
  85514. * @param updatable defines if geometry must be updatable (false by default)
  85515. * @param mesh defines the mesh that will be associated with the geometry
  85516. */
  85517. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  85518. /**
  85519. * Gets the current extend of the geometry
  85520. */
  85521. readonly extend: {
  85522. minimum: Vector3;
  85523. maximum: Vector3;
  85524. };
  85525. /**
  85526. * Gets the hosting scene
  85527. * @returns the hosting Scene
  85528. */
  85529. getScene(): Scene;
  85530. /**
  85531. * Gets the hosting engine
  85532. * @returns the hosting Engine
  85533. */
  85534. getEngine(): Engine;
  85535. /**
  85536. * Defines if the geometry is ready to use
  85537. * @returns true if the geometry is ready to be used
  85538. */
  85539. isReady(): boolean;
  85540. /**
  85541. * Gets a value indicating that the geometry should not be serialized
  85542. */
  85543. readonly doNotSerialize: boolean;
  85544. /** @hidden */
  85545. _rebuild(): void;
  85546. /**
  85547. * Affects all geometry data in one call
  85548. * @param vertexData defines the geometry data
  85549. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  85550. */
  85551. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  85552. /**
  85553. * Set specific vertex data
  85554. * @param kind defines the data kind (Position, normal, etc...)
  85555. * @param data defines the vertex data to use
  85556. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85557. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85558. */
  85559. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  85560. /**
  85561. * Removes a specific vertex data
  85562. * @param kind defines the data kind (Position, normal, etc...)
  85563. */
  85564. removeVerticesData(kind: string): void;
  85565. /**
  85566. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  85567. * @param buffer defines the vertex buffer to use
  85568. * @param totalVertices defines the total number of vertices for position kind (could be null)
  85569. */
  85570. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  85571. /**
  85572. * Update a specific vertex buffer
  85573. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  85574. * It will do nothing if the buffer is not updatable
  85575. * @param kind defines the data kind (Position, normal, etc...)
  85576. * @param data defines the data to use
  85577. * @param offset defines the offset in the target buffer where to store the data
  85578. * @param useBytes set to true if the offset is in bytes
  85579. */
  85580. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  85581. /**
  85582. * Update a specific vertex buffer
  85583. * This function will create a new buffer if the current one is not updatable
  85584. * @param kind defines the data kind (Position, normal, etc...)
  85585. * @param data defines the data to use
  85586. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  85587. */
  85588. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  85589. private _updateBoundingInfo;
  85590. /** @hidden */
  85591. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  85592. /**
  85593. * Gets total number of vertices
  85594. * @returns the total number of vertices
  85595. */
  85596. getTotalVertices(): number;
  85597. /**
  85598. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85599. * @param kind defines the data kind (Position, normal, etc...)
  85600. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85601. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85602. * @returns a float array containing vertex data
  85603. */
  85604. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85605. /**
  85606. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  85607. * @param kind defines the data kind (Position, normal, etc...)
  85608. * @returns true if the vertex buffer with the specified kind is updatable
  85609. */
  85610. isVertexBufferUpdatable(kind: string): boolean;
  85611. /**
  85612. * Gets a specific vertex buffer
  85613. * @param kind defines the data kind (Position, normal, etc...)
  85614. * @returns a VertexBuffer
  85615. */
  85616. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  85617. /**
  85618. * Returns all vertex buffers
  85619. * @return an object holding all vertex buffers indexed by kind
  85620. */
  85621. getVertexBuffers(): Nullable<{
  85622. [key: string]: VertexBuffer;
  85623. }>;
  85624. /**
  85625. * Gets a boolean indicating if specific vertex buffer is present
  85626. * @param kind defines the data kind (Position, normal, etc...)
  85627. * @returns true if data is present
  85628. */
  85629. isVerticesDataPresent(kind: string): boolean;
  85630. /**
  85631. * Gets a list of all attached data kinds (Position, normal, etc...)
  85632. * @returns a list of string containing all kinds
  85633. */
  85634. getVerticesDataKinds(): string[];
  85635. /**
  85636. * Update index buffer
  85637. * @param indices defines the indices to store in the index buffer
  85638. * @param offset defines the offset in the target buffer where to store the data
  85639. * @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)
  85640. */
  85641. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  85642. /**
  85643. * Creates a new index buffer
  85644. * @param indices defines the indices to store in the index buffer
  85645. * @param totalVertices defines the total number of vertices (could be null)
  85646. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85647. */
  85648. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  85649. /**
  85650. * Return the total number of indices
  85651. * @returns the total number of indices
  85652. */
  85653. getTotalIndices(): number;
  85654. /**
  85655. * Gets the index buffer array
  85656. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85657. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85658. * @returns the index buffer array
  85659. */
  85660. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  85661. /**
  85662. * Gets the index buffer
  85663. * @return the index buffer
  85664. */
  85665. getIndexBuffer(): Nullable<DataBuffer>;
  85666. /** @hidden */
  85667. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  85668. /**
  85669. * Release the associated resources for a specific mesh
  85670. * @param mesh defines the source mesh
  85671. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  85672. */
  85673. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  85674. /**
  85675. * Apply current geometry to a given mesh
  85676. * @param mesh defines the mesh to apply geometry to
  85677. */
  85678. applyToMesh(mesh: Mesh): void;
  85679. private _updateExtend;
  85680. private _applyToMesh;
  85681. private notifyUpdate;
  85682. /**
  85683. * Load the geometry if it was flagged as delay loaded
  85684. * @param scene defines the hosting scene
  85685. * @param onLoaded defines a callback called when the geometry is loaded
  85686. */
  85687. load(scene: Scene, onLoaded?: () => void): void;
  85688. private _queueLoad;
  85689. /**
  85690. * Invert the geometry to move from a right handed system to a left handed one.
  85691. */
  85692. toLeftHanded(): void;
  85693. /** @hidden */
  85694. _resetPointsArrayCache(): void;
  85695. /** @hidden */
  85696. _generatePointsArray(): boolean;
  85697. /**
  85698. * Gets a value indicating if the geometry is disposed
  85699. * @returns true if the geometry was disposed
  85700. */
  85701. isDisposed(): boolean;
  85702. private _disposeVertexArrayObjects;
  85703. /**
  85704. * Free all associated resources
  85705. */
  85706. dispose(): void;
  85707. /**
  85708. * Clone the current geometry into a new geometry
  85709. * @param id defines the unique ID of the new geometry
  85710. * @returns a new geometry object
  85711. */
  85712. copy(id: string): Geometry;
  85713. /**
  85714. * Serialize the current geometry info (and not the vertices data) into a JSON object
  85715. * @return a JSON representation of the current geometry data (without the vertices data)
  85716. */
  85717. serialize(): any;
  85718. private toNumberArray;
  85719. /**
  85720. * Serialize all vertices data into a JSON oject
  85721. * @returns a JSON representation of the current geometry data
  85722. */
  85723. serializeVerticeData(): any;
  85724. /**
  85725. * Extracts a clone of a mesh geometry
  85726. * @param mesh defines the source mesh
  85727. * @param id defines the unique ID of the new geometry object
  85728. * @returns the new geometry object
  85729. */
  85730. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  85731. /**
  85732. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  85733. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  85734. * Be aware Math.random() could cause collisions, but:
  85735. * "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"
  85736. * @returns a string containing a new GUID
  85737. */
  85738. static RandomId(): string;
  85739. /** @hidden */
  85740. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  85741. private static _CleanMatricesWeights;
  85742. /**
  85743. * Create a new geometry from persisted data (Using .babylon file format)
  85744. * @param parsedVertexData defines the persisted data
  85745. * @param scene defines the hosting scene
  85746. * @param rootUrl defines the root url to use to load assets (like delayed data)
  85747. * @returns the new geometry object
  85748. */
  85749. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  85750. }
  85751. }
  85752. declare module BABYLON {
  85753. /**
  85754. * Define an interface for all classes that will get and set the data on vertices
  85755. */
  85756. export interface IGetSetVerticesData {
  85757. /**
  85758. * Gets a boolean indicating if specific vertex data is present
  85759. * @param kind defines the vertex data kind to use
  85760. * @returns true is data kind is present
  85761. */
  85762. isVerticesDataPresent(kind: string): boolean;
  85763. /**
  85764. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85765. * @param kind defines the data kind (Position, normal, etc...)
  85766. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85767. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85768. * @returns a float array containing vertex data
  85769. */
  85770. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85771. /**
  85772. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  85773. * @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.
  85774. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85775. * @returns the indices array or an empty array if the mesh has no geometry
  85776. */
  85777. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  85778. /**
  85779. * Set specific vertex data
  85780. * @param kind defines the data kind (Position, normal, etc...)
  85781. * @param data defines the vertex data to use
  85782. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85783. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85784. */
  85785. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  85786. /**
  85787. * Update a specific associated vertex buffer
  85788. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  85789. * - VertexBuffer.PositionKind
  85790. * - VertexBuffer.UVKind
  85791. * - VertexBuffer.UV2Kind
  85792. * - VertexBuffer.UV3Kind
  85793. * - VertexBuffer.UV4Kind
  85794. * - VertexBuffer.UV5Kind
  85795. * - VertexBuffer.UV6Kind
  85796. * - VertexBuffer.ColorKind
  85797. * - VertexBuffer.MatricesIndicesKind
  85798. * - VertexBuffer.MatricesIndicesExtraKind
  85799. * - VertexBuffer.MatricesWeightsKind
  85800. * - VertexBuffer.MatricesWeightsExtraKind
  85801. * @param data defines the data source
  85802. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  85803. * @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)
  85804. */
  85805. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  85806. /**
  85807. * Creates a new index buffer
  85808. * @param indices defines the indices to store in the index buffer
  85809. * @param totalVertices defines the total number of vertices (could be null)
  85810. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85811. */
  85812. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  85813. }
  85814. /**
  85815. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  85816. */
  85817. export class VertexData {
  85818. /**
  85819. * Mesh side orientation : usually the external or front surface
  85820. */
  85821. static readonly FRONTSIDE: number;
  85822. /**
  85823. * Mesh side orientation : usually the internal or back surface
  85824. */
  85825. static readonly BACKSIDE: number;
  85826. /**
  85827. * Mesh side orientation : both internal and external or front and back surfaces
  85828. */
  85829. static readonly DOUBLESIDE: number;
  85830. /**
  85831. * Mesh side orientation : by default, `FRONTSIDE`
  85832. */
  85833. static readonly DEFAULTSIDE: number;
  85834. /**
  85835. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  85836. */
  85837. positions: Nullable<FloatArray>;
  85838. /**
  85839. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  85840. */
  85841. normals: Nullable<FloatArray>;
  85842. /**
  85843. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  85844. */
  85845. tangents: Nullable<FloatArray>;
  85846. /**
  85847. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85848. */
  85849. uvs: Nullable<FloatArray>;
  85850. /**
  85851. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85852. */
  85853. uvs2: Nullable<FloatArray>;
  85854. /**
  85855. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85856. */
  85857. uvs3: Nullable<FloatArray>;
  85858. /**
  85859. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85860. */
  85861. uvs4: Nullable<FloatArray>;
  85862. /**
  85863. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85864. */
  85865. uvs5: Nullable<FloatArray>;
  85866. /**
  85867. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85868. */
  85869. uvs6: Nullable<FloatArray>;
  85870. /**
  85871. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  85872. */
  85873. colors: Nullable<FloatArray>;
  85874. /**
  85875. * 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).
  85876. */
  85877. matricesIndices: Nullable<FloatArray>;
  85878. /**
  85879. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  85880. */
  85881. matricesWeights: Nullable<FloatArray>;
  85882. /**
  85883. * An array extending the number of possible indices
  85884. */
  85885. matricesIndicesExtra: Nullable<FloatArray>;
  85886. /**
  85887. * An array extending the number of possible weights when the number of indices is extended
  85888. */
  85889. matricesWeightsExtra: Nullable<FloatArray>;
  85890. /**
  85891. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  85892. */
  85893. indices: Nullable<IndicesArray>;
  85894. /**
  85895. * Uses the passed data array to set the set the values for the specified kind of data
  85896. * @param data a linear array of floating numbers
  85897. * @param kind the type of data that is being set, eg positions, colors etc
  85898. */
  85899. set(data: FloatArray, kind: string): void;
  85900. /**
  85901. * Associates the vertexData to the passed Mesh.
  85902. * Sets it as updatable or not (default `false`)
  85903. * @param mesh the mesh the vertexData is applied to
  85904. * @param updatable when used and having the value true allows new data to update the vertexData
  85905. * @returns the VertexData
  85906. */
  85907. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  85908. /**
  85909. * Associates the vertexData to the passed Geometry.
  85910. * Sets it as updatable or not (default `false`)
  85911. * @param geometry the geometry the vertexData is applied to
  85912. * @param updatable when used and having the value true allows new data to update the vertexData
  85913. * @returns VertexData
  85914. */
  85915. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  85916. /**
  85917. * Updates the associated mesh
  85918. * @param mesh the mesh to be updated
  85919. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  85920. * @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
  85921. * @returns VertexData
  85922. */
  85923. updateMesh(mesh: Mesh): VertexData;
  85924. /**
  85925. * Updates the associated geometry
  85926. * @param geometry the geometry to be updated
  85927. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  85928. * @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
  85929. * @returns VertexData.
  85930. */
  85931. updateGeometry(geometry: Geometry): VertexData;
  85932. private _applyTo;
  85933. private _update;
  85934. /**
  85935. * Transforms each position and each normal of the vertexData according to the passed Matrix
  85936. * @param matrix the transforming matrix
  85937. * @returns the VertexData
  85938. */
  85939. transform(matrix: Matrix): VertexData;
  85940. /**
  85941. * Merges the passed VertexData into the current one
  85942. * @param other the VertexData to be merged into the current one
  85943. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  85944. * @returns the modified VertexData
  85945. */
  85946. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  85947. private _mergeElement;
  85948. private _validate;
  85949. /**
  85950. * Serializes the VertexData
  85951. * @returns a serialized object
  85952. */
  85953. serialize(): any;
  85954. /**
  85955. * Extracts the vertexData from a mesh
  85956. * @param mesh the mesh from which to extract the VertexData
  85957. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  85958. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  85959. * @returns the object VertexData associated to the passed mesh
  85960. */
  85961. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  85962. /**
  85963. * Extracts the vertexData from the geometry
  85964. * @param geometry the geometry from which to extract the VertexData
  85965. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  85966. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  85967. * @returns the object VertexData associated to the passed mesh
  85968. */
  85969. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  85970. private static _ExtractFrom;
  85971. /**
  85972. * Creates the VertexData for a Ribbon
  85973. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  85974. * * pathArray array of paths, each of which an array of successive Vector3
  85975. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  85976. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  85977. * * 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
  85978. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85979. * * 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)
  85980. * * 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)
  85981. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  85982. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  85983. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  85984. * @returns the VertexData of the ribbon
  85985. */
  85986. static CreateRibbon(options: {
  85987. pathArray: Vector3[][];
  85988. closeArray?: boolean;
  85989. closePath?: boolean;
  85990. offset?: number;
  85991. sideOrientation?: number;
  85992. frontUVs?: Vector4;
  85993. backUVs?: Vector4;
  85994. invertUV?: boolean;
  85995. uvs?: Vector2[];
  85996. colors?: Color4[];
  85997. }): VertexData;
  85998. /**
  85999. * Creates the VertexData for a box
  86000. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86001. * * size sets the width, height and depth of the box to the value of size, optional default 1
  86002. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  86003. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  86004. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  86005. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  86006. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  86007. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86008. * * 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)
  86009. * * 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)
  86010. * @returns the VertexData of the box
  86011. */
  86012. static CreateBox(options: {
  86013. size?: number;
  86014. width?: number;
  86015. height?: number;
  86016. depth?: number;
  86017. faceUV?: Vector4[];
  86018. faceColors?: Color4[];
  86019. sideOrientation?: number;
  86020. frontUVs?: Vector4;
  86021. backUVs?: Vector4;
  86022. }): VertexData;
  86023. /**
  86024. * Creates the VertexData for a tiled box
  86025. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86026. * * faceTiles sets the pattern, tile size and number of tiles for a face
  86027. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  86028. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  86029. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86030. * @returns the VertexData of the box
  86031. */
  86032. static CreateTiledBox(options: {
  86033. pattern?: number;
  86034. width?: number;
  86035. height?: number;
  86036. depth?: number;
  86037. tileSize?: number;
  86038. tileWidth?: number;
  86039. tileHeight?: number;
  86040. alignHorizontal?: number;
  86041. alignVertical?: number;
  86042. faceUV?: Vector4[];
  86043. faceColors?: Color4[];
  86044. sideOrientation?: number;
  86045. }): VertexData;
  86046. /**
  86047. * Creates the VertexData for a tiled plane
  86048. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86049. * * pattern a limited pattern arrangement depending on the number
  86050. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  86051. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  86052. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  86053. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86054. * * 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)
  86055. * * 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)
  86056. * @returns the VertexData of the tiled plane
  86057. */
  86058. static CreateTiledPlane(options: {
  86059. pattern?: number;
  86060. tileSize?: number;
  86061. tileWidth?: number;
  86062. tileHeight?: number;
  86063. size?: number;
  86064. width?: number;
  86065. height?: number;
  86066. alignHorizontal?: number;
  86067. alignVertical?: number;
  86068. sideOrientation?: number;
  86069. frontUVs?: Vector4;
  86070. backUVs?: Vector4;
  86071. }): VertexData;
  86072. /**
  86073. * Creates the VertexData for an ellipsoid, defaults to a sphere
  86074. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86075. * * segments sets the number of horizontal strips optional, default 32
  86076. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  86077. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  86078. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  86079. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  86080. * * 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
  86081. * * 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
  86082. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86083. * * 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)
  86084. * * 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)
  86085. * @returns the VertexData of the ellipsoid
  86086. */
  86087. static CreateSphere(options: {
  86088. segments?: number;
  86089. diameter?: number;
  86090. diameterX?: number;
  86091. diameterY?: number;
  86092. diameterZ?: number;
  86093. arc?: number;
  86094. slice?: number;
  86095. sideOrientation?: number;
  86096. frontUVs?: Vector4;
  86097. backUVs?: Vector4;
  86098. }): VertexData;
  86099. /**
  86100. * Creates the VertexData for a cylinder, cone or prism
  86101. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86102. * * height sets the height (y direction) of the cylinder, optional, default 2
  86103. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  86104. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  86105. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  86106. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  86107. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  86108. * * 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
  86109. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86110. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86111. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  86112. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  86113. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86114. * * 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)
  86115. * * 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)
  86116. * @returns the VertexData of the cylinder, cone or prism
  86117. */
  86118. static CreateCylinder(options: {
  86119. height?: number;
  86120. diameterTop?: number;
  86121. diameterBottom?: number;
  86122. diameter?: number;
  86123. tessellation?: number;
  86124. subdivisions?: number;
  86125. arc?: number;
  86126. faceColors?: Color4[];
  86127. faceUV?: Vector4[];
  86128. hasRings?: boolean;
  86129. enclose?: boolean;
  86130. sideOrientation?: number;
  86131. frontUVs?: Vector4;
  86132. backUVs?: Vector4;
  86133. }): VertexData;
  86134. /**
  86135. * Creates the VertexData for a torus
  86136. * @param options an object used to set the following optional parameters for the box, required but can be empty
  86137. * * diameter the diameter of the torus, optional default 1
  86138. * * thickness the diameter of the tube forming the torus, optional default 0.5
  86139. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  86140. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86141. * * 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)
  86142. * * 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)
  86143. * @returns the VertexData of the torus
  86144. */
  86145. static CreateTorus(options: {
  86146. diameter?: number;
  86147. thickness?: number;
  86148. tessellation?: number;
  86149. sideOrientation?: number;
  86150. frontUVs?: Vector4;
  86151. backUVs?: Vector4;
  86152. }): VertexData;
  86153. /**
  86154. * Creates the VertexData of the LineSystem
  86155. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  86156. * - lines an array of lines, each line being an array of successive Vector3
  86157. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  86158. * @returns the VertexData of the LineSystem
  86159. */
  86160. static CreateLineSystem(options: {
  86161. lines: Vector3[][];
  86162. colors?: Nullable<Color4[][]>;
  86163. }): VertexData;
  86164. /**
  86165. * Create the VertexData for a DashedLines
  86166. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  86167. * - points an array successive Vector3
  86168. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  86169. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  86170. * - dashNb the intended total number of dashes, optional, default 200
  86171. * @returns the VertexData for the DashedLines
  86172. */
  86173. static CreateDashedLines(options: {
  86174. points: Vector3[];
  86175. dashSize?: number;
  86176. gapSize?: number;
  86177. dashNb?: number;
  86178. }): VertexData;
  86179. /**
  86180. * Creates the VertexData for a Ground
  86181. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86182. * - width the width (x direction) of the ground, optional, default 1
  86183. * - height the height (z direction) of the ground, optional, default 1
  86184. * - subdivisions the number of subdivisions per side, optional, default 1
  86185. * @returns the VertexData of the Ground
  86186. */
  86187. static CreateGround(options: {
  86188. width?: number;
  86189. height?: number;
  86190. subdivisions?: number;
  86191. subdivisionsX?: number;
  86192. subdivisionsY?: number;
  86193. }): VertexData;
  86194. /**
  86195. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  86196. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  86197. * * xmin the ground minimum X coordinate, optional, default -1
  86198. * * zmin the ground minimum Z coordinate, optional, default -1
  86199. * * xmax the ground maximum X coordinate, optional, default 1
  86200. * * zmax the ground maximum Z coordinate, optional, default 1
  86201. * * 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}
  86202. * * 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}
  86203. * @returns the VertexData of the TiledGround
  86204. */
  86205. static CreateTiledGround(options: {
  86206. xmin: number;
  86207. zmin: number;
  86208. xmax: number;
  86209. zmax: number;
  86210. subdivisions?: {
  86211. w: number;
  86212. h: number;
  86213. };
  86214. precision?: {
  86215. w: number;
  86216. h: number;
  86217. };
  86218. }): VertexData;
  86219. /**
  86220. * Creates the VertexData of the Ground designed from a heightmap
  86221. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  86222. * * width the width (x direction) of the ground
  86223. * * height the height (z direction) of the ground
  86224. * * subdivisions the number of subdivisions per side
  86225. * * minHeight the minimum altitude on the ground, optional, default 0
  86226. * * maxHeight the maximum altitude on the ground, optional default 1
  86227. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  86228. * * buffer the array holding the image color data
  86229. * * bufferWidth the width of image
  86230. * * bufferHeight the height of image
  86231. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  86232. * @returns the VertexData of the Ground designed from a heightmap
  86233. */
  86234. static CreateGroundFromHeightMap(options: {
  86235. width: number;
  86236. height: number;
  86237. subdivisions: number;
  86238. minHeight: number;
  86239. maxHeight: number;
  86240. colorFilter: Color3;
  86241. buffer: Uint8Array;
  86242. bufferWidth: number;
  86243. bufferHeight: number;
  86244. alphaFilter: number;
  86245. }): VertexData;
  86246. /**
  86247. * Creates the VertexData for a Plane
  86248. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  86249. * * size sets the width and height of the plane to the value of size, optional default 1
  86250. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  86251. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  86252. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86253. * * 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)
  86254. * * 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)
  86255. * @returns the VertexData of the box
  86256. */
  86257. static CreatePlane(options: {
  86258. size?: number;
  86259. width?: number;
  86260. height?: number;
  86261. sideOrientation?: number;
  86262. frontUVs?: Vector4;
  86263. backUVs?: Vector4;
  86264. }): VertexData;
  86265. /**
  86266. * Creates the VertexData of the Disc or regular Polygon
  86267. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  86268. * * radius the radius of the disc, optional default 0.5
  86269. * * tessellation the number of polygon sides, optional, default 64
  86270. * * 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
  86271. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86272. * * 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)
  86273. * * 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)
  86274. * @returns the VertexData of the box
  86275. */
  86276. static CreateDisc(options: {
  86277. radius?: number;
  86278. tessellation?: number;
  86279. arc?: number;
  86280. sideOrientation?: number;
  86281. frontUVs?: Vector4;
  86282. backUVs?: Vector4;
  86283. }): VertexData;
  86284. /**
  86285. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  86286. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  86287. * @param polygon a mesh built from polygonTriangulation.build()
  86288. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86289. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86290. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86291. * @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)
  86292. * @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)
  86293. * @returns the VertexData of the Polygon
  86294. */
  86295. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  86296. /**
  86297. * Creates the VertexData of the IcoSphere
  86298. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  86299. * * radius the radius of the IcoSphere, optional default 1
  86300. * * radiusX allows stretching in the x direction, optional, default radius
  86301. * * radiusY allows stretching in the y direction, optional, default radius
  86302. * * radiusZ allows stretching in the z direction, optional, default radius
  86303. * * flat when true creates a flat shaded mesh, optional, default true
  86304. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86305. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86306. * * 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)
  86307. * * 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)
  86308. * @returns the VertexData of the IcoSphere
  86309. */
  86310. static CreateIcoSphere(options: {
  86311. radius?: number;
  86312. radiusX?: number;
  86313. radiusY?: number;
  86314. radiusZ?: number;
  86315. flat?: boolean;
  86316. subdivisions?: number;
  86317. sideOrientation?: number;
  86318. frontUVs?: Vector4;
  86319. backUVs?: Vector4;
  86320. }): VertexData;
  86321. /**
  86322. * Creates the VertexData for a Polyhedron
  86323. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  86324. * * type provided types are:
  86325. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  86326. * * 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)
  86327. * * size the size of the IcoSphere, optional default 1
  86328. * * sizeX allows stretching in the x direction, optional, default size
  86329. * * sizeY allows stretching in the y direction, optional, default size
  86330. * * sizeZ allows stretching in the z direction, optional, default size
  86331. * * 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
  86332. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  86333. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  86334. * * flat when true creates a flat shaded mesh, optional, default true
  86335. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  86336. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86337. * * 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)
  86338. * * 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)
  86339. * @returns the VertexData of the Polyhedron
  86340. */
  86341. static CreatePolyhedron(options: {
  86342. type?: number;
  86343. size?: number;
  86344. sizeX?: number;
  86345. sizeY?: number;
  86346. sizeZ?: number;
  86347. custom?: any;
  86348. faceUV?: Vector4[];
  86349. faceColors?: Color4[];
  86350. flat?: boolean;
  86351. sideOrientation?: number;
  86352. frontUVs?: Vector4;
  86353. backUVs?: Vector4;
  86354. }): VertexData;
  86355. /**
  86356. * Creates the VertexData for a TorusKnot
  86357. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  86358. * * radius the radius of the torus knot, optional, default 2
  86359. * * tube the thickness of the tube, optional, default 0.5
  86360. * * radialSegments the number of sides on each tube segments, optional, default 32
  86361. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  86362. * * p the number of windings around the z axis, optional, default 2
  86363. * * q the number of windings around the x axis, optional, default 3
  86364. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86365. * * 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)
  86366. * * 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)
  86367. * @returns the VertexData of the Torus Knot
  86368. */
  86369. static CreateTorusKnot(options: {
  86370. radius?: number;
  86371. tube?: number;
  86372. radialSegments?: number;
  86373. tubularSegments?: number;
  86374. p?: number;
  86375. q?: number;
  86376. sideOrientation?: number;
  86377. frontUVs?: Vector4;
  86378. backUVs?: Vector4;
  86379. }): VertexData;
  86380. /**
  86381. * Compute normals for given positions and indices
  86382. * @param positions an array of vertex positions, [...., x, y, z, ......]
  86383. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  86384. * @param normals an array of vertex normals, [...., x, y, z, ......]
  86385. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  86386. * * facetNormals : optional array of facet normals (vector3)
  86387. * * facetPositions : optional array of facet positions (vector3)
  86388. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  86389. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  86390. * * bInfo : optional bounding info, required for facetPartitioning computation
  86391. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  86392. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  86393. * * useRightHandedSystem: optional boolean to for right handed system computation
  86394. * * depthSort : optional boolean to enable the facet depth sort computation
  86395. * * distanceTo : optional Vector3 to compute the facet depth from this location
  86396. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  86397. */
  86398. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  86399. facetNormals?: any;
  86400. facetPositions?: any;
  86401. facetPartitioning?: any;
  86402. ratio?: number;
  86403. bInfo?: any;
  86404. bbSize?: Vector3;
  86405. subDiv?: any;
  86406. useRightHandedSystem?: boolean;
  86407. depthSort?: boolean;
  86408. distanceTo?: Vector3;
  86409. depthSortedFacets?: any;
  86410. }): void;
  86411. /** @hidden */
  86412. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  86413. /**
  86414. * Applies VertexData created from the imported parameters to the geometry
  86415. * @param parsedVertexData the parsed data from an imported file
  86416. * @param geometry the geometry to apply the VertexData to
  86417. */
  86418. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  86419. }
  86420. }
  86421. declare module BABYLON {
  86422. /**
  86423. * Class containing static functions to help procedurally build meshes
  86424. */
  86425. export class DiscBuilder {
  86426. /**
  86427. * Creates a plane polygonal mesh. By default, this is a disc
  86428. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  86429. * * 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
  86430. * * 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
  86431. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  86432. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  86433. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  86434. * @param name defines the name of the mesh
  86435. * @param options defines the options used to create the mesh
  86436. * @param scene defines the hosting scene
  86437. * @returns the plane polygonal mesh
  86438. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  86439. */
  86440. static CreateDisc(name: string, options: {
  86441. radius?: number;
  86442. tessellation?: number;
  86443. arc?: number;
  86444. updatable?: boolean;
  86445. sideOrientation?: number;
  86446. frontUVs?: Vector4;
  86447. backUVs?: Vector4;
  86448. }, scene?: Nullable<Scene>): Mesh;
  86449. }
  86450. }
  86451. declare module BABYLON {
  86452. /**
  86453. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  86454. *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.
  86455. * The SPS is also a particle system. It provides some methods to manage the particles.
  86456. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  86457. *
  86458. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  86459. */
  86460. export class SolidParticleSystem implements IDisposable {
  86461. /**
  86462. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  86463. * Example : var p = SPS.particles[i];
  86464. */
  86465. particles: SolidParticle[];
  86466. /**
  86467. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  86468. */
  86469. nbParticles: number;
  86470. /**
  86471. * If the particles must ever face the camera (default false). Useful for planar particles.
  86472. */
  86473. billboard: boolean;
  86474. /**
  86475. * Recompute normals when adding a shape
  86476. */
  86477. recomputeNormals: boolean;
  86478. /**
  86479. * This a counter ofr your own usage. It's not set by any SPS functions.
  86480. */
  86481. counter: number;
  86482. /**
  86483. * The SPS name. This name is also given to the underlying mesh.
  86484. */
  86485. name: string;
  86486. /**
  86487. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  86488. */
  86489. mesh: Mesh;
  86490. /**
  86491. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  86492. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  86493. */
  86494. vars: any;
  86495. /**
  86496. * This array is populated when the SPS is set as 'pickable'.
  86497. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  86498. * Each element of this array is an object `{idx: int, faceId: int}`.
  86499. * `idx` is the picked particle index in the `SPS.particles` array
  86500. * `faceId` is the picked face index counted within this particle.
  86501. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  86502. */
  86503. pickedParticles: {
  86504. idx: number;
  86505. faceId: number;
  86506. }[];
  86507. /**
  86508. * This array is populated when `enableDepthSort` is set to true.
  86509. * Each element of this array is an instance of the class DepthSortedParticle.
  86510. */
  86511. depthSortedParticles: DepthSortedParticle[];
  86512. /**
  86513. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  86514. * @hidden
  86515. */
  86516. _bSphereOnly: boolean;
  86517. /**
  86518. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  86519. * @hidden
  86520. */
  86521. _bSphereRadiusFactor: number;
  86522. private _scene;
  86523. private _positions;
  86524. private _indices;
  86525. private _normals;
  86526. private _colors;
  86527. private _uvs;
  86528. private _indices32;
  86529. private _positions32;
  86530. private _normals32;
  86531. private _fixedNormal32;
  86532. private _colors32;
  86533. private _uvs32;
  86534. private _index;
  86535. private _updatable;
  86536. private _pickable;
  86537. private _isVisibilityBoxLocked;
  86538. private _alwaysVisible;
  86539. private _depthSort;
  86540. private _shapeCounter;
  86541. private _copy;
  86542. private _color;
  86543. private _computeParticleColor;
  86544. private _computeParticleTexture;
  86545. private _computeParticleRotation;
  86546. private _computeParticleVertex;
  86547. private _computeBoundingBox;
  86548. private _depthSortParticles;
  86549. private _camera;
  86550. private _mustUnrotateFixedNormals;
  86551. private _particlesIntersect;
  86552. private _needs32Bits;
  86553. /**
  86554. * Creates a SPS (Solid Particle System) object.
  86555. * @param name (String) is the SPS name, this will be the underlying mesh name.
  86556. * @param scene (Scene) is the scene in which the SPS is added.
  86557. * @param options defines the options of the sps e.g.
  86558. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  86559. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  86560. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  86561. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  86562. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  86563. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  86564. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  86565. */
  86566. constructor(name: string, scene: Scene, options?: {
  86567. updatable?: boolean;
  86568. isPickable?: boolean;
  86569. enableDepthSort?: boolean;
  86570. particleIntersection?: boolean;
  86571. boundingSphereOnly?: boolean;
  86572. bSphereRadiusFactor?: number;
  86573. });
  86574. /**
  86575. * Builds the SPS underlying mesh. Returns a standard Mesh.
  86576. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  86577. * @returns the created mesh
  86578. */
  86579. buildMesh(): Mesh;
  86580. /**
  86581. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  86582. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  86583. * Thus the particles generated from `digest()` have their property `position` set yet.
  86584. * @param mesh ( Mesh ) is the mesh to be digested
  86585. * @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
  86586. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  86587. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  86588. * @returns the current SPS
  86589. */
  86590. digest(mesh: Mesh, options?: {
  86591. facetNb?: number;
  86592. number?: number;
  86593. delta?: number;
  86594. }): SolidParticleSystem;
  86595. private _unrotateFixedNormals;
  86596. private _resetCopy;
  86597. private _meshBuilder;
  86598. private _posToShape;
  86599. private _uvsToShapeUV;
  86600. private _addParticle;
  86601. /**
  86602. * Adds some particles to the SPS from the model shape. Returns the shape id.
  86603. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  86604. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  86605. * @param nb (positive integer) the number of particles to be created from this model
  86606. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  86607. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  86608. * @returns the number of shapes in the system
  86609. */
  86610. addShape(mesh: Mesh, nb: number, options?: {
  86611. positionFunction?: any;
  86612. vertexFunction?: any;
  86613. }): number;
  86614. private _rebuildParticle;
  86615. /**
  86616. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  86617. * @returns the SPS.
  86618. */
  86619. rebuildMesh(): SolidParticleSystem;
  86620. /**
  86621. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  86622. * This method calls `updateParticle()` for each particle of the SPS.
  86623. * For an animated SPS, it is usually called within the render loop.
  86624. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  86625. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  86626. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  86627. * @returns the SPS.
  86628. */
  86629. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  86630. /**
  86631. * Disposes the SPS.
  86632. */
  86633. dispose(): void;
  86634. /**
  86635. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  86636. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86637. * @returns the SPS.
  86638. */
  86639. refreshVisibleSize(): SolidParticleSystem;
  86640. /**
  86641. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  86642. * @param size the size (float) of the visibility box
  86643. * note : this doesn't lock the SPS mesh bounding box.
  86644. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86645. */
  86646. setVisibilityBox(size: number): void;
  86647. /**
  86648. * Gets whether the SPS as always visible or not
  86649. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86650. */
  86651. /**
  86652. * Sets the SPS as always visible or not
  86653. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86654. */
  86655. isAlwaysVisible: boolean;
  86656. /**
  86657. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  86658. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86659. */
  86660. /**
  86661. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  86662. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  86663. */
  86664. isVisibilityBoxLocked: boolean;
  86665. /**
  86666. * Tells to `setParticles()` to compute the particle rotations or not.
  86667. * Default value : true. The SPS is faster when it's set to false.
  86668. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  86669. */
  86670. /**
  86671. * Gets if `setParticles()` computes the particle rotations or not.
  86672. * Default value : true. The SPS is faster when it's set to false.
  86673. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  86674. */
  86675. computeParticleRotation: boolean;
  86676. /**
  86677. * Tells to `setParticles()` to compute the particle colors or not.
  86678. * Default value : true. The SPS is faster when it's set to false.
  86679. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  86680. */
  86681. /**
  86682. * Gets if `setParticles()` computes the particle colors or not.
  86683. * Default value : true. The SPS is faster when it's set to false.
  86684. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  86685. */
  86686. computeParticleColor: boolean;
  86687. /**
  86688. * Gets if `setParticles()` computes the particle textures or not.
  86689. * Default value : true. The SPS is faster when it's set to false.
  86690. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  86691. */
  86692. computeParticleTexture: boolean;
  86693. /**
  86694. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  86695. * Default value : false. The SPS is faster when it's set to false.
  86696. * Note : the particle custom vertex positions aren't stored values.
  86697. */
  86698. /**
  86699. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  86700. * Default value : false. The SPS is faster when it's set to false.
  86701. * Note : the particle custom vertex positions aren't stored values.
  86702. */
  86703. computeParticleVertex: boolean;
  86704. /**
  86705. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  86706. */
  86707. /**
  86708. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  86709. */
  86710. computeBoundingBox: boolean;
  86711. /**
  86712. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  86713. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  86714. * Default : `true`
  86715. */
  86716. /**
  86717. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  86718. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  86719. * Default : `true`
  86720. */
  86721. depthSortParticles: boolean;
  86722. /**
  86723. * This function does nothing. It may be overwritten to set all the particle first values.
  86724. * The SPS doesn't call this function, you may have to call it by your own.
  86725. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  86726. */
  86727. initParticles(): void;
  86728. /**
  86729. * This function does nothing. It may be overwritten to recycle a particle.
  86730. * The SPS doesn't call this function, you may have to call it by your own.
  86731. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  86732. * @param particle The particle to recycle
  86733. * @returns the recycled particle
  86734. */
  86735. recycleParticle(particle: SolidParticle): SolidParticle;
  86736. /**
  86737. * Updates a particle : this function should be overwritten by the user.
  86738. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  86739. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  86740. * @example : just set a particle position or velocity and recycle conditions
  86741. * @param particle The particle to update
  86742. * @returns the updated particle
  86743. */
  86744. updateParticle(particle: SolidParticle): SolidParticle;
  86745. /**
  86746. * Updates a vertex of a particle : it can be overwritten by the user.
  86747. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  86748. * @param particle the current particle
  86749. * @param vertex the current index of the current particle
  86750. * @param pt the index of the current vertex in the particle shape
  86751. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  86752. * @example : just set a vertex particle position
  86753. * @returns the updated vertex
  86754. */
  86755. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  86756. /**
  86757. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  86758. * This does nothing and may be overwritten by the user.
  86759. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86760. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86761. * @param update the boolean update value actually passed to setParticles()
  86762. */
  86763. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  86764. /**
  86765. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  86766. * This will be passed three parameters.
  86767. * This does nothing and may be overwritten by the user.
  86768. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86769. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86770. * @param update the boolean update value actually passed to setParticles()
  86771. */
  86772. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  86773. }
  86774. }
  86775. declare module BABYLON {
  86776. /**
  86777. * Represents one particle of a solid particle system.
  86778. */
  86779. export class SolidParticle {
  86780. /**
  86781. * particle global index
  86782. */
  86783. idx: number;
  86784. /**
  86785. * The color of the particle
  86786. */
  86787. color: Nullable<Color4>;
  86788. /**
  86789. * The world space position of the particle.
  86790. */
  86791. position: Vector3;
  86792. /**
  86793. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  86794. */
  86795. rotation: Vector3;
  86796. /**
  86797. * The world space rotation quaternion of the particle.
  86798. */
  86799. rotationQuaternion: Nullable<Quaternion>;
  86800. /**
  86801. * The scaling of the particle.
  86802. */
  86803. scaling: Vector3;
  86804. /**
  86805. * The uvs of the particle.
  86806. */
  86807. uvs: Vector4;
  86808. /**
  86809. * The current speed of the particle.
  86810. */
  86811. velocity: Vector3;
  86812. /**
  86813. * The pivot point in the particle local space.
  86814. */
  86815. pivot: Vector3;
  86816. /**
  86817. * Must the particle be translated from its pivot point in its local space ?
  86818. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  86819. * Default : false
  86820. */
  86821. translateFromPivot: boolean;
  86822. /**
  86823. * Is the particle active or not ?
  86824. */
  86825. alive: boolean;
  86826. /**
  86827. * Is the particle visible or not ?
  86828. */
  86829. isVisible: boolean;
  86830. /**
  86831. * Index of this particle in the global "positions" array (Internal use)
  86832. * @hidden
  86833. */
  86834. _pos: number;
  86835. /**
  86836. * @hidden Index of this particle in the global "indices" array (Internal use)
  86837. */
  86838. _ind: number;
  86839. /**
  86840. * @hidden ModelShape of this particle (Internal use)
  86841. */
  86842. _model: ModelShape;
  86843. /**
  86844. * ModelShape id of this particle
  86845. */
  86846. shapeId: number;
  86847. /**
  86848. * Index of the particle in its shape id (Internal use)
  86849. */
  86850. idxInShape: number;
  86851. /**
  86852. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  86853. */
  86854. _modelBoundingInfo: BoundingInfo;
  86855. /**
  86856. * @hidden Particle BoundingInfo object (Internal use)
  86857. */
  86858. _boundingInfo: BoundingInfo;
  86859. /**
  86860. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  86861. */
  86862. _sps: SolidParticleSystem;
  86863. /**
  86864. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  86865. */
  86866. _stillInvisible: boolean;
  86867. /**
  86868. * @hidden Last computed particle rotation matrix
  86869. */
  86870. _rotationMatrix: number[];
  86871. /**
  86872. * Parent particle Id, if any.
  86873. * Default null.
  86874. */
  86875. parentId: Nullable<number>;
  86876. /**
  86877. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  86878. * The possible values are :
  86879. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  86880. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  86881. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  86882. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  86883. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  86884. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  86885. * */
  86886. cullingStrategy: number;
  86887. /**
  86888. * @hidden Internal global position in the SPS.
  86889. */
  86890. _globalPosition: Vector3;
  86891. /**
  86892. * Creates a Solid Particle object.
  86893. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  86894. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  86895. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  86896. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  86897. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  86898. * @param shapeId (integer) is the model shape identifier in the SPS.
  86899. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  86900. * @param sps defines the sps it is associated to
  86901. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  86902. */
  86903. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  86904. /**
  86905. * Legacy support, changed scale to scaling
  86906. */
  86907. /**
  86908. * Legacy support, changed scale to scaling
  86909. */
  86910. scale: Vector3;
  86911. /**
  86912. * Legacy support, changed quaternion to rotationQuaternion
  86913. */
  86914. /**
  86915. * Legacy support, changed quaternion to rotationQuaternion
  86916. */
  86917. quaternion: Nullable<Quaternion>;
  86918. /**
  86919. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  86920. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  86921. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  86922. * @returns true if it intersects
  86923. */
  86924. intersectsMesh(target: Mesh | SolidParticle): boolean;
  86925. /**
  86926. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  86927. * A particle is in the frustum if its bounding box intersects the frustum
  86928. * @param frustumPlanes defines the frustum to test
  86929. * @returns true if the particle is in the frustum planes
  86930. */
  86931. isInFrustum(frustumPlanes: Plane[]): boolean;
  86932. /**
  86933. * get the rotation matrix of the particle
  86934. * @hidden
  86935. */
  86936. getRotationMatrix(m: Matrix): void;
  86937. }
  86938. /**
  86939. * Represents the shape of the model used by one particle of a solid particle system.
  86940. * SPS internal tool, don't use it manually.
  86941. */
  86942. export class ModelShape {
  86943. /**
  86944. * The shape id
  86945. * @hidden
  86946. */
  86947. shapeID: number;
  86948. /**
  86949. * flat array of model positions (internal use)
  86950. * @hidden
  86951. */
  86952. _shape: Vector3[];
  86953. /**
  86954. * flat array of model UVs (internal use)
  86955. * @hidden
  86956. */
  86957. _shapeUV: number[];
  86958. /**
  86959. * length of the shape in the model indices array (internal use)
  86960. * @hidden
  86961. */
  86962. _indicesLength: number;
  86963. /**
  86964. * Custom position function (internal use)
  86965. * @hidden
  86966. */
  86967. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  86968. /**
  86969. * Custom vertex function (internal use)
  86970. * @hidden
  86971. */
  86972. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  86973. /**
  86974. * 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.
  86975. * SPS internal tool, don't use it manually.
  86976. * @hidden
  86977. */
  86978. 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>);
  86979. }
  86980. /**
  86981. * Represents a Depth Sorted Particle in the solid particle system.
  86982. */
  86983. export class DepthSortedParticle {
  86984. /**
  86985. * Index of the particle in the "indices" array
  86986. */
  86987. ind: number;
  86988. /**
  86989. * Length of the particle shape in the "indices" array
  86990. */
  86991. indicesLength: number;
  86992. /**
  86993. * Squared distance from the particle to the camera
  86994. */
  86995. sqDistance: number;
  86996. }
  86997. }
  86998. declare module BABYLON {
  86999. /**
  87000. * @hidden
  87001. */
  87002. export class _MeshCollisionData {
  87003. _checkCollisions: boolean;
  87004. _collisionMask: number;
  87005. _collisionGroup: number;
  87006. _collider: Nullable<Collider>;
  87007. _oldPositionForCollisions: Vector3;
  87008. _diffPositionForCollisions: Vector3;
  87009. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  87010. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  87011. }
  87012. }
  87013. declare module BABYLON {
  87014. /** @hidden */
  87015. class _FacetDataStorage {
  87016. facetPositions: Vector3[];
  87017. facetNormals: Vector3[];
  87018. facetPartitioning: number[][];
  87019. facetNb: number;
  87020. partitioningSubdivisions: number;
  87021. partitioningBBoxRatio: number;
  87022. facetDataEnabled: boolean;
  87023. facetParameters: any;
  87024. bbSize: Vector3;
  87025. subDiv: {
  87026. max: number;
  87027. X: number;
  87028. Y: number;
  87029. Z: number;
  87030. };
  87031. facetDepthSort: boolean;
  87032. facetDepthSortEnabled: boolean;
  87033. depthSortedIndices: IndicesArray;
  87034. depthSortedFacets: {
  87035. ind: number;
  87036. sqDistance: number;
  87037. }[];
  87038. facetDepthSortFunction: (f1: {
  87039. ind: number;
  87040. sqDistance: number;
  87041. }, f2: {
  87042. ind: number;
  87043. sqDistance: number;
  87044. }) => number;
  87045. facetDepthSortFrom: Vector3;
  87046. facetDepthSortOrigin: Vector3;
  87047. invertedMatrix: Matrix;
  87048. }
  87049. /**
  87050. * @hidden
  87051. **/
  87052. class _InternalAbstractMeshDataInfo {
  87053. _hasVertexAlpha: boolean;
  87054. _useVertexColors: boolean;
  87055. _numBoneInfluencers: number;
  87056. _applyFog: boolean;
  87057. _receiveShadows: boolean;
  87058. _facetData: _FacetDataStorage;
  87059. _visibility: number;
  87060. _skeleton: Nullable<Skeleton>;
  87061. _layerMask: number;
  87062. _computeBonesUsingShaders: boolean;
  87063. _isActive: boolean;
  87064. _onlyForInstances: boolean;
  87065. _isActiveIntermediate: boolean;
  87066. _onlyForInstancesIntermediate: boolean;
  87067. }
  87068. /**
  87069. * Class used to store all common mesh properties
  87070. */
  87071. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  87072. /** No occlusion */
  87073. static OCCLUSION_TYPE_NONE: number;
  87074. /** Occlusion set to optimisitic */
  87075. static OCCLUSION_TYPE_OPTIMISTIC: number;
  87076. /** Occlusion set to strict */
  87077. static OCCLUSION_TYPE_STRICT: number;
  87078. /** Use an accurante occlusion algorithm */
  87079. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  87080. /** Use a conservative occlusion algorithm */
  87081. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  87082. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  87083. * Test order :
  87084. * Is the bounding sphere outside the frustum ?
  87085. * If not, are the bounding box vertices outside the frustum ?
  87086. * It not, then the cullable object is in the frustum.
  87087. */
  87088. static readonly CULLINGSTRATEGY_STANDARD: number;
  87089. /** Culling strategy : Bounding Sphere Only.
  87090. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  87091. * It's also less accurate than the standard because some not visible objects can still be selected.
  87092. * Test : is the bounding sphere outside the frustum ?
  87093. * If not, then the cullable object is in the frustum.
  87094. */
  87095. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  87096. /** Culling strategy : Optimistic Inclusion.
  87097. * This in an inclusion test first, then the standard exclusion test.
  87098. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  87099. * 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.
  87100. * Anyway, it's as accurate as the standard strategy.
  87101. * Test :
  87102. * Is the cullable object bounding sphere center in the frustum ?
  87103. * If not, apply the default culling strategy.
  87104. */
  87105. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  87106. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  87107. * This in an inclusion test first, then the bounding sphere only exclusion test.
  87108. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  87109. * 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.
  87110. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  87111. * Test :
  87112. * Is the cullable object bounding sphere center in the frustum ?
  87113. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  87114. */
  87115. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  87116. /**
  87117. * No billboard
  87118. */
  87119. static readonly BILLBOARDMODE_NONE: number;
  87120. /** Billboard on X axis */
  87121. static readonly BILLBOARDMODE_X: number;
  87122. /** Billboard on Y axis */
  87123. static readonly BILLBOARDMODE_Y: number;
  87124. /** Billboard on Z axis */
  87125. static readonly BILLBOARDMODE_Z: number;
  87126. /** Billboard on all axes */
  87127. static readonly BILLBOARDMODE_ALL: number;
  87128. /** @hidden */
  87129. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  87130. /**
  87131. * The culling strategy to use to check whether the mesh must be rendered or not.
  87132. * This value can be changed at any time and will be used on the next render mesh selection.
  87133. * The possible values are :
  87134. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  87135. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  87136. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  87137. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  87138. * Please read each static variable documentation to get details about the culling process.
  87139. * */
  87140. cullingStrategy: number;
  87141. /**
  87142. * Gets the number of facets in the mesh
  87143. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  87144. */
  87145. readonly facetNb: number;
  87146. /**
  87147. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  87148. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  87149. */
  87150. partitioningSubdivisions: number;
  87151. /**
  87152. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  87153. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  87154. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  87155. */
  87156. partitioningBBoxRatio: number;
  87157. /**
  87158. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  87159. * Works only for updatable meshes.
  87160. * Doesn't work with multi-materials
  87161. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  87162. */
  87163. mustDepthSortFacets: boolean;
  87164. /**
  87165. * The location (Vector3) where the facet depth sort must be computed from.
  87166. * By default, the active camera position.
  87167. * Used only when facet depth sort is enabled
  87168. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  87169. */
  87170. facetDepthSortFrom: Vector3;
  87171. /**
  87172. * gets a boolean indicating if facetData is enabled
  87173. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  87174. */
  87175. readonly isFacetDataEnabled: boolean;
  87176. /** @hidden */
  87177. _updateNonUniformScalingState(value: boolean): boolean;
  87178. /**
  87179. * An event triggered when this mesh collides with another one
  87180. */
  87181. onCollideObservable: Observable<AbstractMesh>;
  87182. /** Set a function to call when this mesh collides with another one */
  87183. onCollide: () => void;
  87184. /**
  87185. * An event triggered when the collision's position changes
  87186. */
  87187. onCollisionPositionChangeObservable: Observable<Vector3>;
  87188. /** Set a function to call when the collision's position changes */
  87189. onCollisionPositionChange: () => void;
  87190. /**
  87191. * An event triggered when material is changed
  87192. */
  87193. onMaterialChangedObservable: Observable<AbstractMesh>;
  87194. /**
  87195. * Gets or sets the orientation for POV movement & rotation
  87196. */
  87197. definedFacingForward: boolean;
  87198. /** @hidden */
  87199. _occlusionQuery: Nullable<WebGLQuery>;
  87200. /** @hidden */
  87201. _renderingGroup: Nullable<RenderingGroup>;
  87202. /**
  87203. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  87204. */
  87205. /**
  87206. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  87207. */
  87208. visibility: number;
  87209. /** Gets or sets the alpha index used to sort transparent meshes
  87210. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  87211. */
  87212. alphaIndex: number;
  87213. /**
  87214. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  87215. */
  87216. isVisible: boolean;
  87217. /**
  87218. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  87219. */
  87220. isPickable: boolean;
  87221. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  87222. showSubMeshesBoundingBox: boolean;
  87223. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  87224. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  87225. */
  87226. isBlocker: boolean;
  87227. /**
  87228. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  87229. */
  87230. enablePointerMoveEvents: boolean;
  87231. /**
  87232. * Specifies the rendering group id for this mesh (0 by default)
  87233. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  87234. */
  87235. renderingGroupId: number;
  87236. private _material;
  87237. /** Gets or sets current material */
  87238. material: Nullable<Material>;
  87239. /**
  87240. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  87241. * @see http://doc.babylonjs.com/babylon101/shadows
  87242. */
  87243. receiveShadows: boolean;
  87244. /** Defines color to use when rendering outline */
  87245. outlineColor: Color3;
  87246. /** Define width to use when rendering outline */
  87247. outlineWidth: number;
  87248. /** Defines color to use when rendering overlay */
  87249. overlayColor: Color3;
  87250. /** Defines alpha to use when rendering overlay */
  87251. overlayAlpha: number;
  87252. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  87253. hasVertexAlpha: boolean;
  87254. /** 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) */
  87255. useVertexColors: boolean;
  87256. /**
  87257. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  87258. */
  87259. computeBonesUsingShaders: boolean;
  87260. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  87261. numBoneInfluencers: number;
  87262. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  87263. applyFog: boolean;
  87264. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  87265. useOctreeForRenderingSelection: boolean;
  87266. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  87267. useOctreeForPicking: boolean;
  87268. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  87269. useOctreeForCollisions: boolean;
  87270. /**
  87271. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  87272. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  87273. */
  87274. layerMask: number;
  87275. /**
  87276. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  87277. */
  87278. alwaysSelectAsActiveMesh: boolean;
  87279. /**
  87280. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  87281. */
  87282. doNotSyncBoundingInfo: boolean;
  87283. /**
  87284. * Gets or sets the current action manager
  87285. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87286. */
  87287. actionManager: Nullable<AbstractActionManager>;
  87288. private _meshCollisionData;
  87289. /**
  87290. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  87291. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87292. */
  87293. ellipsoid: Vector3;
  87294. /**
  87295. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  87296. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87297. */
  87298. ellipsoidOffset: Vector3;
  87299. /**
  87300. * Gets or sets a collision mask used to mask collisions (default is -1).
  87301. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  87302. */
  87303. collisionMask: number;
  87304. /**
  87305. * Gets or sets the current collision group mask (-1 by default).
  87306. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  87307. */
  87308. collisionGroup: number;
  87309. /**
  87310. * Defines edge width used when edgesRenderer is enabled
  87311. * @see https://www.babylonjs-playground.com/#10OJSG#13
  87312. */
  87313. edgesWidth: number;
  87314. /**
  87315. * Defines edge color used when edgesRenderer is enabled
  87316. * @see https://www.babylonjs-playground.com/#10OJSG#13
  87317. */
  87318. edgesColor: Color4;
  87319. /** @hidden */
  87320. _edgesRenderer: Nullable<IEdgesRenderer>;
  87321. /** @hidden */
  87322. _masterMesh: Nullable<AbstractMesh>;
  87323. /** @hidden */
  87324. _boundingInfo: Nullable<BoundingInfo>;
  87325. /** @hidden */
  87326. _renderId: number;
  87327. /**
  87328. * Gets or sets the list of subMeshes
  87329. * @see http://doc.babylonjs.com/how_to/multi_materials
  87330. */
  87331. subMeshes: SubMesh[];
  87332. /** @hidden */
  87333. _intersectionsInProgress: AbstractMesh[];
  87334. /** @hidden */
  87335. _unIndexed: boolean;
  87336. /** @hidden */
  87337. _lightSources: Light[];
  87338. /** Gets the list of lights affecting that mesh */
  87339. readonly lightSources: Light[];
  87340. /** @hidden */
  87341. readonly _positions: Nullable<Vector3[]>;
  87342. /** @hidden */
  87343. _waitingData: {
  87344. lods: Nullable<any>;
  87345. actions: Nullable<any>;
  87346. freezeWorldMatrix: Nullable<boolean>;
  87347. };
  87348. /** @hidden */
  87349. _bonesTransformMatrices: Nullable<Float32Array>;
  87350. /** @hidden */
  87351. _transformMatrixTexture: Nullable<RawTexture>;
  87352. /**
  87353. * Gets or sets a skeleton to apply skining transformations
  87354. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  87355. */
  87356. skeleton: Nullable<Skeleton>;
  87357. /**
  87358. * An event triggered when the mesh is rebuilt.
  87359. */
  87360. onRebuildObservable: Observable<AbstractMesh>;
  87361. /**
  87362. * Creates a new AbstractMesh
  87363. * @param name defines the name of the mesh
  87364. * @param scene defines the hosting scene
  87365. */
  87366. constructor(name: string, scene?: Nullable<Scene>);
  87367. /**
  87368. * Returns the string "AbstractMesh"
  87369. * @returns "AbstractMesh"
  87370. */
  87371. getClassName(): string;
  87372. /**
  87373. * Gets a string representation of the current mesh
  87374. * @param fullDetails defines a boolean indicating if full details must be included
  87375. * @returns a string representation of the current mesh
  87376. */
  87377. toString(fullDetails?: boolean): string;
  87378. /**
  87379. * @hidden
  87380. */
  87381. protected _getEffectiveParent(): Nullable<Node>;
  87382. /** @hidden */
  87383. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  87384. /** @hidden */
  87385. _rebuild(): void;
  87386. /** @hidden */
  87387. _resyncLightSources(): void;
  87388. /** @hidden */
  87389. _resyncLighSource(light: Light): void;
  87390. /** @hidden */
  87391. _unBindEffect(): void;
  87392. /** @hidden */
  87393. _removeLightSource(light: Light): void;
  87394. private _markSubMeshesAsDirty;
  87395. /** @hidden */
  87396. _markSubMeshesAsLightDirty(): void;
  87397. /** @hidden */
  87398. _markSubMeshesAsAttributesDirty(): void;
  87399. /** @hidden */
  87400. _markSubMeshesAsMiscDirty(): void;
  87401. /**
  87402. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  87403. */
  87404. scaling: Vector3;
  87405. /**
  87406. * Returns true if the mesh is blocked. Implemented by child classes
  87407. */
  87408. readonly isBlocked: boolean;
  87409. /**
  87410. * Returns the mesh itself by default. Implemented by child classes
  87411. * @param camera defines the camera to use to pick the right LOD level
  87412. * @returns the currentAbstractMesh
  87413. */
  87414. getLOD(camera: Camera): Nullable<AbstractMesh>;
  87415. /**
  87416. * Returns 0 by default. Implemented by child classes
  87417. * @returns an integer
  87418. */
  87419. getTotalVertices(): number;
  87420. /**
  87421. * Returns a positive integer : the total number of indices in this mesh geometry.
  87422. * @returns the numner of indices or zero if the mesh has no geometry.
  87423. */
  87424. getTotalIndices(): number;
  87425. /**
  87426. * Returns null by default. Implemented by child classes
  87427. * @returns null
  87428. */
  87429. getIndices(): Nullable<IndicesArray>;
  87430. /**
  87431. * Returns the array of the requested vertex data kind. Implemented by child classes
  87432. * @param kind defines the vertex data kind to use
  87433. * @returns null
  87434. */
  87435. getVerticesData(kind: string): Nullable<FloatArray>;
  87436. /**
  87437. * Sets the vertex data of the mesh geometry for the requested `kind`.
  87438. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  87439. * Note that a new underlying VertexBuffer object is created each call.
  87440. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  87441. * @param kind defines vertex data kind:
  87442. * * VertexBuffer.PositionKind
  87443. * * VertexBuffer.UVKind
  87444. * * VertexBuffer.UV2Kind
  87445. * * VertexBuffer.UV3Kind
  87446. * * VertexBuffer.UV4Kind
  87447. * * VertexBuffer.UV5Kind
  87448. * * VertexBuffer.UV6Kind
  87449. * * VertexBuffer.ColorKind
  87450. * * VertexBuffer.MatricesIndicesKind
  87451. * * VertexBuffer.MatricesIndicesExtraKind
  87452. * * VertexBuffer.MatricesWeightsKind
  87453. * * VertexBuffer.MatricesWeightsExtraKind
  87454. * @param data defines the data source
  87455. * @param updatable defines if the data must be flagged as updatable (or static)
  87456. * @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
  87457. * @returns the current mesh
  87458. */
  87459. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  87460. /**
  87461. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  87462. * If the mesh has no geometry, it is simply returned as it is.
  87463. * @param kind defines vertex data kind:
  87464. * * VertexBuffer.PositionKind
  87465. * * VertexBuffer.UVKind
  87466. * * VertexBuffer.UV2Kind
  87467. * * VertexBuffer.UV3Kind
  87468. * * VertexBuffer.UV4Kind
  87469. * * VertexBuffer.UV5Kind
  87470. * * VertexBuffer.UV6Kind
  87471. * * VertexBuffer.ColorKind
  87472. * * VertexBuffer.MatricesIndicesKind
  87473. * * VertexBuffer.MatricesIndicesExtraKind
  87474. * * VertexBuffer.MatricesWeightsKind
  87475. * * VertexBuffer.MatricesWeightsExtraKind
  87476. * @param data defines the data source
  87477. * @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
  87478. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  87479. * @returns the current mesh
  87480. */
  87481. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  87482. /**
  87483. * Sets the mesh indices,
  87484. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  87485. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  87486. * @param totalVertices Defines the total number of vertices
  87487. * @returns the current mesh
  87488. */
  87489. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  87490. /**
  87491. * Gets a boolean indicating if specific vertex data is present
  87492. * @param kind defines the vertex data kind to use
  87493. * @returns true is data kind is present
  87494. */
  87495. isVerticesDataPresent(kind: string): boolean;
  87496. /**
  87497. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  87498. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  87499. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  87500. * @returns a BoundingInfo
  87501. */
  87502. getBoundingInfo(): BoundingInfo;
  87503. /**
  87504. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87505. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87506. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87507. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  87508. * @returns the current mesh
  87509. */
  87510. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  87511. /**
  87512. * Overwrite the current bounding info
  87513. * @param boundingInfo defines the new bounding info
  87514. * @returns the current mesh
  87515. */
  87516. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  87517. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  87518. readonly useBones: boolean;
  87519. /** @hidden */
  87520. _preActivate(): void;
  87521. /** @hidden */
  87522. _preActivateForIntermediateRendering(renderId: number): void;
  87523. /** @hidden */
  87524. _activate(renderId: number, intermediateRendering: boolean): boolean;
  87525. /** @hidden */
  87526. _postActivate(): void;
  87527. /** @hidden */
  87528. _freeze(): void;
  87529. /** @hidden */
  87530. _unFreeze(): void;
  87531. /**
  87532. * Gets the current world matrix
  87533. * @returns a Matrix
  87534. */
  87535. getWorldMatrix(): Matrix;
  87536. /** @hidden */
  87537. _getWorldMatrixDeterminant(): number;
  87538. /**
  87539. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  87540. */
  87541. readonly isAnInstance: boolean;
  87542. /**
  87543. * Perform relative position change from the point of view of behind the front of the mesh.
  87544. * This is performed taking into account the meshes current rotation, so you do not have to care.
  87545. * Supports definition of mesh facing forward or backward
  87546. * @param amountRight defines the distance on the right axis
  87547. * @param amountUp defines the distance on the up axis
  87548. * @param amountForward defines the distance on the forward axis
  87549. * @returns the current mesh
  87550. */
  87551. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  87552. /**
  87553. * Calculate relative position change from the point of view of behind the front of the mesh.
  87554. * This is performed taking into account the meshes current rotation, so you do not have to care.
  87555. * Supports definition of mesh facing forward or backward
  87556. * @param amountRight defines the distance on the right axis
  87557. * @param amountUp defines the distance on the up axis
  87558. * @param amountForward defines the distance on the forward axis
  87559. * @returns the new displacement vector
  87560. */
  87561. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  87562. /**
  87563. * Perform relative rotation change from the point of view of behind the front of the mesh.
  87564. * Supports definition of mesh facing forward or backward
  87565. * @param flipBack defines the flip
  87566. * @param twirlClockwise defines the twirl
  87567. * @param tiltRight defines the tilt
  87568. * @returns the current mesh
  87569. */
  87570. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  87571. /**
  87572. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  87573. * Supports definition of mesh facing forward or backward.
  87574. * @param flipBack defines the flip
  87575. * @param twirlClockwise defines the twirl
  87576. * @param tiltRight defines the tilt
  87577. * @returns the new rotation vector
  87578. */
  87579. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  87580. /**
  87581. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  87582. * This means the mesh underlying bounding box and sphere are recomputed.
  87583. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  87584. * @returns the current mesh
  87585. */
  87586. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  87587. /** @hidden */
  87588. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  87589. /** @hidden */
  87590. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  87591. /** @hidden */
  87592. _updateBoundingInfo(): AbstractMesh;
  87593. /** @hidden */
  87594. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  87595. /** @hidden */
  87596. protected _afterComputeWorldMatrix(): void;
  87597. /** @hidden */
  87598. readonly _effectiveMesh: AbstractMesh;
  87599. /**
  87600. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  87601. * A mesh is in the frustum if its bounding box intersects the frustum
  87602. * @param frustumPlanes defines the frustum to test
  87603. * @returns true if the mesh is in the frustum planes
  87604. */
  87605. isInFrustum(frustumPlanes: Plane[]): boolean;
  87606. /**
  87607. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  87608. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  87609. * @param frustumPlanes defines the frustum to test
  87610. * @returns true if the mesh is completely in the frustum planes
  87611. */
  87612. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87613. /**
  87614. * True if the mesh intersects another mesh or a SolidParticle object
  87615. * @param mesh defines a target mesh or SolidParticle to test
  87616. * @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)
  87617. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  87618. * @returns true if there is an intersection
  87619. */
  87620. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  87621. /**
  87622. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  87623. * @param point defines the point to test
  87624. * @returns true if there is an intersection
  87625. */
  87626. intersectsPoint(point: Vector3): boolean;
  87627. /**
  87628. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  87629. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87630. */
  87631. checkCollisions: boolean;
  87632. /**
  87633. * Gets Collider object used to compute collisions (not physics)
  87634. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87635. */
  87636. readonly collider: Nullable<Collider>;
  87637. /**
  87638. * Move the mesh using collision engine
  87639. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  87640. * @param displacement defines the requested displacement vector
  87641. * @returns the current mesh
  87642. */
  87643. moveWithCollisions(displacement: Vector3): AbstractMesh;
  87644. private _onCollisionPositionChange;
  87645. /** @hidden */
  87646. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  87647. /** @hidden */
  87648. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  87649. /** @hidden */
  87650. _checkCollision(collider: Collider): AbstractMesh;
  87651. /** @hidden */
  87652. _generatePointsArray(): boolean;
  87653. /**
  87654. * Checks if the passed Ray intersects with the mesh
  87655. * @param ray defines the ray to use
  87656. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  87657. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  87658. * @returns the picking info
  87659. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87660. */
  87661. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  87662. /**
  87663. * Clones the current mesh
  87664. * @param name defines the mesh name
  87665. * @param newParent defines the new mesh parent
  87666. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  87667. * @returns the new mesh
  87668. */
  87669. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  87670. /**
  87671. * Disposes all the submeshes of the current meshnp
  87672. * @returns the current mesh
  87673. */
  87674. releaseSubMeshes(): AbstractMesh;
  87675. /**
  87676. * Releases resources associated with this abstract mesh.
  87677. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87678. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87679. */
  87680. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87681. /**
  87682. * Adds the passed mesh as a child to the current mesh
  87683. * @param mesh defines the child mesh
  87684. * @returns the current mesh
  87685. */
  87686. addChild(mesh: AbstractMesh): AbstractMesh;
  87687. /**
  87688. * Removes the passed mesh from the current mesh children list
  87689. * @param mesh defines the child mesh
  87690. * @returns the current mesh
  87691. */
  87692. removeChild(mesh: AbstractMesh): AbstractMesh;
  87693. /** @hidden */
  87694. private _initFacetData;
  87695. /**
  87696. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  87697. * This method can be called within the render loop.
  87698. * 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
  87699. * @returns the current mesh
  87700. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87701. */
  87702. updateFacetData(): AbstractMesh;
  87703. /**
  87704. * Returns the facetLocalNormals array.
  87705. * The normals are expressed in the mesh local spac
  87706. * @returns an array of Vector3
  87707. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87708. */
  87709. getFacetLocalNormals(): Vector3[];
  87710. /**
  87711. * Returns the facetLocalPositions array.
  87712. * The facet positions are expressed in the mesh local space
  87713. * @returns an array of Vector3
  87714. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87715. */
  87716. getFacetLocalPositions(): Vector3[];
  87717. /**
  87718. * Returns the facetLocalPartioning array
  87719. * @returns an array of array of numbers
  87720. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87721. */
  87722. getFacetLocalPartitioning(): number[][];
  87723. /**
  87724. * Returns the i-th facet position in the world system.
  87725. * This method allocates a new Vector3 per call
  87726. * @param i defines the facet index
  87727. * @returns a new Vector3
  87728. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87729. */
  87730. getFacetPosition(i: number): Vector3;
  87731. /**
  87732. * Sets the reference Vector3 with the i-th facet position in the world system
  87733. * @param i defines the facet index
  87734. * @param ref defines the target vector
  87735. * @returns the current mesh
  87736. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87737. */
  87738. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  87739. /**
  87740. * Returns the i-th facet normal in the world system.
  87741. * This method allocates a new Vector3 per call
  87742. * @param i defines the facet index
  87743. * @returns a new Vector3
  87744. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87745. */
  87746. getFacetNormal(i: number): Vector3;
  87747. /**
  87748. * Sets the reference Vector3 with the i-th facet normal in the world system
  87749. * @param i defines the facet index
  87750. * @param ref defines the target vector
  87751. * @returns the current mesh
  87752. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87753. */
  87754. getFacetNormalToRef(i: number, ref: Vector3): this;
  87755. /**
  87756. * 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)
  87757. * @param x defines x coordinate
  87758. * @param y defines y coordinate
  87759. * @param z defines z coordinate
  87760. * @returns the array of facet indexes
  87761. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87762. */
  87763. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  87764. /**
  87765. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  87766. * @param projected sets as the (x,y,z) world projection on the facet
  87767. * @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
  87768. * @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
  87769. * @param x defines x coordinate
  87770. * @param y defines y coordinate
  87771. * @param z defines z coordinate
  87772. * @returns the face index if found (or null instead)
  87773. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87774. */
  87775. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  87776. /**
  87777. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  87778. * @param projected sets as the (x,y,z) local projection on the facet
  87779. * @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
  87780. * @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
  87781. * @param x defines x coordinate
  87782. * @param y defines y coordinate
  87783. * @param z defines z coordinate
  87784. * @returns the face index if found (or null instead)
  87785. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87786. */
  87787. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  87788. /**
  87789. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  87790. * @returns the parameters
  87791. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87792. */
  87793. getFacetDataParameters(): any;
  87794. /**
  87795. * Disables the feature FacetData and frees the related memory
  87796. * @returns the current mesh
  87797. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87798. */
  87799. disableFacetData(): AbstractMesh;
  87800. /**
  87801. * Updates the AbstractMesh indices array
  87802. * @param indices defines the data source
  87803. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  87804. * @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)
  87805. * @returns the current mesh
  87806. */
  87807. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  87808. /**
  87809. * Creates new normals data for the mesh
  87810. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  87811. * @returns the current mesh
  87812. */
  87813. createNormals(updatable: boolean): AbstractMesh;
  87814. /**
  87815. * Align the mesh with a normal
  87816. * @param normal defines the normal to use
  87817. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  87818. * @returns the current mesh
  87819. */
  87820. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  87821. /** @hidden */
  87822. _checkOcclusionQuery(): boolean;
  87823. /**
  87824. * Disables the mesh edge rendering mode
  87825. * @returns the currentAbstractMesh
  87826. */
  87827. disableEdgesRendering(): AbstractMesh;
  87828. /**
  87829. * Enables the edge rendering mode on the mesh.
  87830. * This mode makes the mesh edges visible
  87831. * @param epsilon defines the maximal distance between two angles to detect a face
  87832. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  87833. * @returns the currentAbstractMesh
  87834. * @see https://www.babylonjs-playground.com/#19O9TU#0
  87835. */
  87836. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  87837. }
  87838. }
  87839. declare module BABYLON {
  87840. /**
  87841. * Interface used to define ActionEvent
  87842. */
  87843. export interface IActionEvent {
  87844. /** The mesh or sprite that triggered the action */
  87845. source: any;
  87846. /** The X mouse cursor position at the time of the event */
  87847. pointerX: number;
  87848. /** The Y mouse cursor position at the time of the event */
  87849. pointerY: number;
  87850. /** The mesh that is currently pointed at (can be null) */
  87851. meshUnderPointer: Nullable<AbstractMesh>;
  87852. /** the original (browser) event that triggered the ActionEvent */
  87853. sourceEvent?: any;
  87854. /** additional data for the event */
  87855. additionalData?: any;
  87856. }
  87857. /**
  87858. * ActionEvent is the event being sent when an action is triggered.
  87859. */
  87860. export class ActionEvent implements IActionEvent {
  87861. /** The mesh or sprite that triggered the action */
  87862. source: any;
  87863. /** The X mouse cursor position at the time of the event */
  87864. pointerX: number;
  87865. /** The Y mouse cursor position at the time of the event */
  87866. pointerY: number;
  87867. /** The mesh that is currently pointed at (can be null) */
  87868. meshUnderPointer: Nullable<AbstractMesh>;
  87869. /** the original (browser) event that triggered the ActionEvent */
  87870. sourceEvent?: any;
  87871. /** additional data for the event */
  87872. additionalData?: any;
  87873. /**
  87874. * Creates a new ActionEvent
  87875. * @param source The mesh or sprite that triggered the action
  87876. * @param pointerX The X mouse cursor position at the time of the event
  87877. * @param pointerY The Y mouse cursor position at the time of the event
  87878. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  87879. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  87880. * @param additionalData additional data for the event
  87881. */
  87882. constructor(
  87883. /** The mesh or sprite that triggered the action */
  87884. source: any,
  87885. /** The X mouse cursor position at the time of the event */
  87886. pointerX: number,
  87887. /** The Y mouse cursor position at the time of the event */
  87888. pointerY: number,
  87889. /** The mesh that is currently pointed at (can be null) */
  87890. meshUnderPointer: Nullable<AbstractMesh>,
  87891. /** the original (browser) event that triggered the ActionEvent */
  87892. sourceEvent?: any,
  87893. /** additional data for the event */
  87894. additionalData?: any);
  87895. /**
  87896. * Helper function to auto-create an ActionEvent from a source mesh.
  87897. * @param source The source mesh that triggered the event
  87898. * @param evt The original (browser) event
  87899. * @param additionalData additional data for the event
  87900. * @returns the new ActionEvent
  87901. */
  87902. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  87903. /**
  87904. * Helper function to auto-create an ActionEvent from a source sprite
  87905. * @param source The source sprite that triggered the event
  87906. * @param scene Scene associated with the sprite
  87907. * @param evt The original (browser) event
  87908. * @param additionalData additional data for the event
  87909. * @returns the new ActionEvent
  87910. */
  87911. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  87912. /**
  87913. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  87914. * @param scene the scene where the event occurred
  87915. * @param evt The original (browser) event
  87916. * @returns the new ActionEvent
  87917. */
  87918. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  87919. /**
  87920. * Helper function to auto-create an ActionEvent from a primitive
  87921. * @param prim defines the target primitive
  87922. * @param pointerPos defines the pointer position
  87923. * @param evt The original (browser) event
  87924. * @param additionalData additional data for the event
  87925. * @returns the new ActionEvent
  87926. */
  87927. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  87928. }
  87929. }
  87930. declare module BABYLON {
  87931. /**
  87932. * Abstract class used to decouple action Manager from scene and meshes.
  87933. * Do not instantiate.
  87934. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87935. */
  87936. export abstract class AbstractActionManager implements IDisposable {
  87937. /** Gets the list of active triggers */
  87938. static Triggers: {
  87939. [key: string]: number;
  87940. };
  87941. /** Gets the cursor to use when hovering items */
  87942. hoverCursor: string;
  87943. /** Gets the list of actions */
  87944. actions: IAction[];
  87945. /**
  87946. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  87947. */
  87948. isRecursive: boolean;
  87949. /**
  87950. * Releases all associated resources
  87951. */
  87952. abstract dispose(): void;
  87953. /**
  87954. * Does this action manager has pointer triggers
  87955. */
  87956. abstract readonly hasPointerTriggers: boolean;
  87957. /**
  87958. * Does this action manager has pick triggers
  87959. */
  87960. abstract readonly hasPickTriggers: boolean;
  87961. /**
  87962. * Process a specific trigger
  87963. * @param trigger defines the trigger to process
  87964. * @param evt defines the event details to be processed
  87965. */
  87966. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  87967. /**
  87968. * Does this action manager handles actions of any of the given triggers
  87969. * @param triggers defines the triggers to be tested
  87970. * @return a boolean indicating whether one (or more) of the triggers is handled
  87971. */
  87972. abstract hasSpecificTriggers(triggers: number[]): boolean;
  87973. /**
  87974. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  87975. * speed.
  87976. * @param triggerA defines the trigger to be tested
  87977. * @param triggerB defines the trigger to be tested
  87978. * @return a boolean indicating whether one (or more) of the triggers is handled
  87979. */
  87980. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  87981. /**
  87982. * Does this action manager handles actions of a given trigger
  87983. * @param trigger defines the trigger to be tested
  87984. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  87985. * @return whether the trigger is handled
  87986. */
  87987. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  87988. /**
  87989. * Serialize this manager to a JSON object
  87990. * @param name defines the property name to store this manager
  87991. * @returns a JSON representation of this manager
  87992. */
  87993. abstract serialize(name: string): any;
  87994. /**
  87995. * Registers an action to this action manager
  87996. * @param action defines the action to be registered
  87997. * @return the action amended (prepared) after registration
  87998. */
  87999. abstract registerAction(action: IAction): Nullable<IAction>;
  88000. /**
  88001. * Unregisters an action to this action manager
  88002. * @param action defines the action to be unregistered
  88003. * @return a boolean indicating whether the action has been unregistered
  88004. */
  88005. abstract unregisterAction(action: IAction): Boolean;
  88006. /**
  88007. * Does exist one action manager with at least one trigger
  88008. **/
  88009. static readonly HasTriggers: boolean;
  88010. /**
  88011. * Does exist one action manager with at least one pick trigger
  88012. **/
  88013. static readonly HasPickTriggers: boolean;
  88014. /**
  88015. * Does exist one action manager that handles actions of a given trigger
  88016. * @param trigger defines the trigger to be tested
  88017. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  88018. **/
  88019. static HasSpecificTrigger(trigger: number): boolean;
  88020. }
  88021. }
  88022. declare module BABYLON {
  88023. /**
  88024. * Defines how a node can be built from a string name.
  88025. */
  88026. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  88027. /**
  88028. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  88029. */
  88030. export class Node implements IBehaviorAware<Node> {
  88031. /** @hidden */
  88032. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  88033. private static _NodeConstructors;
  88034. /**
  88035. * Add a new node constructor
  88036. * @param type defines the type name of the node to construct
  88037. * @param constructorFunc defines the constructor function
  88038. */
  88039. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  88040. /**
  88041. * Returns a node constructor based on type name
  88042. * @param type defines the type name
  88043. * @param name defines the new node name
  88044. * @param scene defines the hosting scene
  88045. * @param options defines optional options to transmit to constructors
  88046. * @returns the new constructor or null
  88047. */
  88048. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  88049. /**
  88050. * Gets or sets the name of the node
  88051. */
  88052. name: string;
  88053. /**
  88054. * Gets or sets the id of the node
  88055. */
  88056. id: string;
  88057. /**
  88058. * Gets or sets the unique id of the node
  88059. */
  88060. uniqueId: number;
  88061. /**
  88062. * Gets or sets a string used to store user defined state for the node
  88063. */
  88064. state: string;
  88065. /**
  88066. * Gets or sets an object used to store user defined information for the node
  88067. */
  88068. metadata: any;
  88069. /**
  88070. * For internal use only. Please do not use.
  88071. */
  88072. reservedDataStore: any;
  88073. /**
  88074. * List of inspectable custom properties (used by the Inspector)
  88075. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88076. */
  88077. inspectableCustomProperties: IInspectable[];
  88078. /**
  88079. * Gets or sets a boolean used to define if the node must be serialized
  88080. */
  88081. doNotSerialize: boolean;
  88082. /** @hidden */
  88083. _isDisposed: boolean;
  88084. /**
  88085. * Gets a list of Animations associated with the node
  88086. */
  88087. animations: Animation[];
  88088. protected _ranges: {
  88089. [name: string]: Nullable<AnimationRange>;
  88090. };
  88091. /**
  88092. * Callback raised when the node is ready to be used
  88093. */
  88094. onReady: Nullable<(node: Node) => void>;
  88095. private _isEnabled;
  88096. private _isParentEnabled;
  88097. private _isReady;
  88098. /** @hidden */
  88099. _currentRenderId: number;
  88100. private _parentUpdateId;
  88101. /** @hidden */
  88102. _childUpdateId: number;
  88103. /** @hidden */
  88104. _waitingParentId: Nullable<string>;
  88105. /** @hidden */
  88106. _scene: Scene;
  88107. /** @hidden */
  88108. _cache: any;
  88109. private _parentNode;
  88110. private _children;
  88111. /** @hidden */
  88112. _worldMatrix: Matrix;
  88113. /** @hidden */
  88114. _worldMatrixDeterminant: number;
  88115. /** @hidden */
  88116. _worldMatrixDeterminantIsDirty: boolean;
  88117. /** @hidden */
  88118. private _sceneRootNodesIndex;
  88119. /**
  88120. * Gets a boolean indicating if the node has been disposed
  88121. * @returns true if the node was disposed
  88122. */
  88123. isDisposed(): boolean;
  88124. /**
  88125. * Gets or sets the parent of the node (without keeping the current position in the scene)
  88126. * @see https://doc.babylonjs.com/how_to/parenting
  88127. */
  88128. parent: Nullable<Node>;
  88129. private addToSceneRootNodes;
  88130. private removeFromSceneRootNodes;
  88131. private _animationPropertiesOverride;
  88132. /**
  88133. * Gets or sets the animation properties override
  88134. */
  88135. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88136. /**
  88137. * Gets a string idenfifying the name of the class
  88138. * @returns "Node" string
  88139. */
  88140. getClassName(): string;
  88141. /** @hidden */
  88142. readonly _isNode: boolean;
  88143. /**
  88144. * An event triggered when the mesh is disposed
  88145. */
  88146. onDisposeObservable: Observable<Node>;
  88147. private _onDisposeObserver;
  88148. /**
  88149. * Sets a callback that will be raised when the node will be disposed
  88150. */
  88151. onDispose: () => void;
  88152. /**
  88153. * Creates a new Node
  88154. * @param name the name and id to be given to this node
  88155. * @param scene the scene this node will be added to
  88156. * @param addToRootNodes the node will be added to scene.rootNodes
  88157. */
  88158. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  88159. /**
  88160. * Gets the scene of the node
  88161. * @returns a scene
  88162. */
  88163. getScene(): Scene;
  88164. /**
  88165. * Gets the engine of the node
  88166. * @returns a Engine
  88167. */
  88168. getEngine(): Engine;
  88169. private _behaviors;
  88170. /**
  88171. * Attach a behavior to the node
  88172. * @see http://doc.babylonjs.com/features/behaviour
  88173. * @param behavior defines the behavior to attach
  88174. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  88175. * @returns the current Node
  88176. */
  88177. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  88178. /**
  88179. * Remove an attached behavior
  88180. * @see http://doc.babylonjs.com/features/behaviour
  88181. * @param behavior defines the behavior to attach
  88182. * @returns the current Node
  88183. */
  88184. removeBehavior(behavior: Behavior<Node>): Node;
  88185. /**
  88186. * Gets the list of attached behaviors
  88187. * @see http://doc.babylonjs.com/features/behaviour
  88188. */
  88189. readonly behaviors: Behavior<Node>[];
  88190. /**
  88191. * Gets an attached behavior by name
  88192. * @param name defines the name of the behavior to look for
  88193. * @see http://doc.babylonjs.com/features/behaviour
  88194. * @returns null if behavior was not found else the requested behavior
  88195. */
  88196. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  88197. /**
  88198. * Returns the latest update of the World matrix
  88199. * @returns a Matrix
  88200. */
  88201. getWorldMatrix(): Matrix;
  88202. /** @hidden */
  88203. _getWorldMatrixDeterminant(): number;
  88204. /**
  88205. * Returns directly the latest state of the mesh World matrix.
  88206. * A Matrix is returned.
  88207. */
  88208. readonly worldMatrixFromCache: Matrix;
  88209. /** @hidden */
  88210. _initCache(): void;
  88211. /** @hidden */
  88212. updateCache(force?: boolean): void;
  88213. /** @hidden */
  88214. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  88215. /** @hidden */
  88216. _updateCache(ignoreParentClass?: boolean): void;
  88217. /** @hidden */
  88218. _isSynchronized(): boolean;
  88219. /** @hidden */
  88220. _markSyncedWithParent(): void;
  88221. /** @hidden */
  88222. isSynchronizedWithParent(): boolean;
  88223. /** @hidden */
  88224. isSynchronized(): boolean;
  88225. /**
  88226. * Is this node ready to be used/rendered
  88227. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88228. * @return true if the node is ready
  88229. */
  88230. isReady(completeCheck?: boolean): boolean;
  88231. /**
  88232. * Is this node enabled?
  88233. * 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
  88234. * @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
  88235. * @return whether this node (and its parent) is enabled
  88236. */
  88237. isEnabled(checkAncestors?: boolean): boolean;
  88238. /** @hidden */
  88239. protected _syncParentEnabledState(): void;
  88240. /**
  88241. * Set the enabled state of this node
  88242. * @param value defines the new enabled state
  88243. */
  88244. setEnabled(value: boolean): void;
  88245. /**
  88246. * Is this node a descendant of the given node?
  88247. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  88248. * @param ancestor defines the parent node to inspect
  88249. * @returns a boolean indicating if this node is a descendant of the given node
  88250. */
  88251. isDescendantOf(ancestor: Node): boolean;
  88252. /** @hidden */
  88253. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  88254. /**
  88255. * Will return all nodes that have this node as ascendant
  88256. * @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
  88257. * @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
  88258. * @return all children nodes of all types
  88259. */
  88260. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  88261. /**
  88262. * Get all child-meshes of this node
  88263. * @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)
  88264. * @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
  88265. * @returns an array of AbstractMesh
  88266. */
  88267. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  88268. /**
  88269. * Get all direct children of this node
  88270. * @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
  88271. * @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)
  88272. * @returns an array of Node
  88273. */
  88274. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  88275. /** @hidden */
  88276. _setReady(state: boolean): void;
  88277. /**
  88278. * Get an animation by name
  88279. * @param name defines the name of the animation to look for
  88280. * @returns null if not found else the requested animation
  88281. */
  88282. getAnimationByName(name: string): Nullable<Animation>;
  88283. /**
  88284. * Creates an animation range for this node
  88285. * @param name defines the name of the range
  88286. * @param from defines the starting key
  88287. * @param to defines the end key
  88288. */
  88289. createAnimationRange(name: string, from: number, to: number): void;
  88290. /**
  88291. * Delete a specific animation range
  88292. * @param name defines the name of the range to delete
  88293. * @param deleteFrames defines if animation frames from the range must be deleted as well
  88294. */
  88295. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  88296. /**
  88297. * Get an animation range by name
  88298. * @param name defines the name of the animation range to look for
  88299. * @returns null if not found else the requested animation range
  88300. */
  88301. getAnimationRange(name: string): Nullable<AnimationRange>;
  88302. /**
  88303. * Gets the list of all animation ranges defined on this node
  88304. * @returns an array
  88305. */
  88306. getAnimationRanges(): Nullable<AnimationRange>[];
  88307. /**
  88308. * Will start the animation sequence
  88309. * @param name defines the range frames for animation sequence
  88310. * @param loop defines if the animation should loop (false by default)
  88311. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  88312. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  88313. * @returns the object created for this animation. If range does not exist, it will return null
  88314. */
  88315. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  88316. /**
  88317. * Serialize animation ranges into a JSON compatible object
  88318. * @returns serialization object
  88319. */
  88320. serializeAnimationRanges(): any;
  88321. /**
  88322. * Computes the world matrix of the node
  88323. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  88324. * @returns the world matrix
  88325. */
  88326. computeWorldMatrix(force?: boolean): Matrix;
  88327. /**
  88328. * Releases resources associated with this node.
  88329. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88330. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88331. */
  88332. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88333. /**
  88334. * Parse animation range data from a serialization object and store them into a given node
  88335. * @param node defines where to store the animation ranges
  88336. * @param parsedNode defines the serialization object to read data from
  88337. * @param scene defines the hosting scene
  88338. */
  88339. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  88340. /**
  88341. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  88342. * @param includeDescendants Include bounding info from descendants as well (true by default)
  88343. * @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
  88344. * @returns the new bounding vectors
  88345. */
  88346. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  88347. min: Vector3;
  88348. max: Vector3;
  88349. };
  88350. }
  88351. }
  88352. declare module BABYLON {
  88353. /**
  88354. * @hidden
  88355. */
  88356. export class _IAnimationState {
  88357. key: number;
  88358. repeatCount: number;
  88359. workValue?: any;
  88360. loopMode?: number;
  88361. offsetValue?: any;
  88362. highLimitValue?: any;
  88363. }
  88364. /**
  88365. * Class used to store any kind of animation
  88366. */
  88367. export class Animation {
  88368. /**Name of the animation */
  88369. name: string;
  88370. /**Property to animate */
  88371. targetProperty: string;
  88372. /**The frames per second of the animation */
  88373. framePerSecond: number;
  88374. /**The data type of the animation */
  88375. dataType: number;
  88376. /**The loop mode of the animation */
  88377. loopMode?: number | undefined;
  88378. /**Specifies if blending should be enabled */
  88379. enableBlending?: boolean | undefined;
  88380. /**
  88381. * Use matrix interpolation instead of using direct key value when animating matrices
  88382. */
  88383. static AllowMatricesInterpolation: boolean;
  88384. /**
  88385. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  88386. */
  88387. static AllowMatrixDecomposeForInterpolation: boolean;
  88388. /**
  88389. * Stores the key frames of the animation
  88390. */
  88391. private _keys;
  88392. /**
  88393. * Stores the easing function of the animation
  88394. */
  88395. private _easingFunction;
  88396. /**
  88397. * @hidden Internal use only
  88398. */
  88399. _runtimeAnimations: RuntimeAnimation[];
  88400. /**
  88401. * The set of event that will be linked to this animation
  88402. */
  88403. private _events;
  88404. /**
  88405. * Stores an array of target property paths
  88406. */
  88407. targetPropertyPath: string[];
  88408. /**
  88409. * Stores the blending speed of the animation
  88410. */
  88411. blendingSpeed: number;
  88412. /**
  88413. * Stores the animation ranges for the animation
  88414. */
  88415. private _ranges;
  88416. /**
  88417. * @hidden Internal use
  88418. */
  88419. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  88420. /**
  88421. * Sets up an animation
  88422. * @param property The property to animate
  88423. * @param animationType The animation type to apply
  88424. * @param framePerSecond The frames per second of the animation
  88425. * @param easingFunction The easing function used in the animation
  88426. * @returns The created animation
  88427. */
  88428. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  88429. /**
  88430. * Create and start an animation on a node
  88431. * @param name defines the name of the global animation that will be run on all nodes
  88432. * @param node defines the root node where the animation will take place
  88433. * @param targetProperty defines property to animate
  88434. * @param framePerSecond defines the number of frame per second yo use
  88435. * @param totalFrame defines the number of frames in total
  88436. * @param from defines the initial value
  88437. * @param to defines the final value
  88438. * @param loopMode defines which loop mode you want to use (off by default)
  88439. * @param easingFunction defines the easing function to use (linear by default)
  88440. * @param onAnimationEnd defines the callback to call when animation end
  88441. * @returns the animatable created for this animation
  88442. */
  88443. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  88444. /**
  88445. * Create and start an animation on a node and its descendants
  88446. * @param name defines the name of the global animation that will be run on all nodes
  88447. * @param node defines the root node where the animation will take place
  88448. * @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
  88449. * @param targetProperty defines property to animate
  88450. * @param framePerSecond defines the number of frame per second to use
  88451. * @param totalFrame defines the number of frames in total
  88452. * @param from defines the initial value
  88453. * @param to defines the final value
  88454. * @param loopMode defines which loop mode you want to use (off by default)
  88455. * @param easingFunction defines the easing function to use (linear by default)
  88456. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88457. * @returns the list of animatables created for all nodes
  88458. * @example https://www.babylonjs-playground.com/#MH0VLI
  88459. */
  88460. 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[]>;
  88461. /**
  88462. * Creates a new animation, merges it with the existing animations and starts it
  88463. * @param name Name of the animation
  88464. * @param node Node which contains the scene that begins the animations
  88465. * @param targetProperty Specifies which property to animate
  88466. * @param framePerSecond The frames per second of the animation
  88467. * @param totalFrame The total number of frames
  88468. * @param from The frame at the beginning of the animation
  88469. * @param to The frame at the end of the animation
  88470. * @param loopMode Specifies the loop mode of the animation
  88471. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  88472. * @param onAnimationEnd Callback to run once the animation is complete
  88473. * @returns Nullable animation
  88474. */
  88475. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  88476. /**
  88477. * Transition property of an host to the target Value
  88478. * @param property The property to transition
  88479. * @param targetValue The target Value of the property
  88480. * @param host The object where the property to animate belongs
  88481. * @param scene Scene used to run the animation
  88482. * @param frameRate Framerate (in frame/s) to use
  88483. * @param transition The transition type we want to use
  88484. * @param duration The duration of the animation, in milliseconds
  88485. * @param onAnimationEnd Callback trigger at the end of the animation
  88486. * @returns Nullable animation
  88487. */
  88488. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  88489. /**
  88490. * Return the array of runtime animations currently using this animation
  88491. */
  88492. readonly runtimeAnimations: RuntimeAnimation[];
  88493. /**
  88494. * Specifies if any of the runtime animations are currently running
  88495. */
  88496. readonly hasRunningRuntimeAnimations: boolean;
  88497. /**
  88498. * Initializes the animation
  88499. * @param name Name of the animation
  88500. * @param targetProperty Property to animate
  88501. * @param framePerSecond The frames per second of the animation
  88502. * @param dataType The data type of the animation
  88503. * @param loopMode The loop mode of the animation
  88504. * @param enableBlending Specifies if blending should be enabled
  88505. */
  88506. constructor(
  88507. /**Name of the animation */
  88508. name: string,
  88509. /**Property to animate */
  88510. targetProperty: string,
  88511. /**The frames per second of the animation */
  88512. framePerSecond: number,
  88513. /**The data type of the animation */
  88514. dataType: number,
  88515. /**The loop mode of the animation */
  88516. loopMode?: number | undefined,
  88517. /**Specifies if blending should be enabled */
  88518. enableBlending?: boolean | undefined);
  88519. /**
  88520. * Converts the animation to a string
  88521. * @param fullDetails support for multiple levels of logging within scene loading
  88522. * @returns String form of the animation
  88523. */
  88524. toString(fullDetails?: boolean): string;
  88525. /**
  88526. * Add an event to this animation
  88527. * @param event Event to add
  88528. */
  88529. addEvent(event: AnimationEvent): void;
  88530. /**
  88531. * Remove all events found at the given frame
  88532. * @param frame The frame to remove events from
  88533. */
  88534. removeEvents(frame: number): void;
  88535. /**
  88536. * Retrieves all the events from the animation
  88537. * @returns Events from the animation
  88538. */
  88539. getEvents(): AnimationEvent[];
  88540. /**
  88541. * Creates an animation range
  88542. * @param name Name of the animation range
  88543. * @param from Starting frame of the animation range
  88544. * @param to Ending frame of the animation
  88545. */
  88546. createRange(name: string, from: number, to: number): void;
  88547. /**
  88548. * Deletes an animation range by name
  88549. * @param name Name of the animation range to delete
  88550. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  88551. */
  88552. deleteRange(name: string, deleteFrames?: boolean): void;
  88553. /**
  88554. * Gets the animation range by name, or null if not defined
  88555. * @param name Name of the animation range
  88556. * @returns Nullable animation range
  88557. */
  88558. getRange(name: string): Nullable<AnimationRange>;
  88559. /**
  88560. * Gets the key frames from the animation
  88561. * @returns The key frames of the animation
  88562. */
  88563. getKeys(): Array<IAnimationKey>;
  88564. /**
  88565. * Gets the highest frame rate of the animation
  88566. * @returns Highest frame rate of the animation
  88567. */
  88568. getHighestFrame(): number;
  88569. /**
  88570. * Gets the easing function of the animation
  88571. * @returns Easing function of the animation
  88572. */
  88573. getEasingFunction(): IEasingFunction;
  88574. /**
  88575. * Sets the easing function of the animation
  88576. * @param easingFunction A custom mathematical formula for animation
  88577. */
  88578. setEasingFunction(easingFunction: EasingFunction): void;
  88579. /**
  88580. * Interpolates a scalar linearly
  88581. * @param startValue Start value of the animation curve
  88582. * @param endValue End value of the animation curve
  88583. * @param gradient Scalar amount to interpolate
  88584. * @returns Interpolated scalar value
  88585. */
  88586. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  88587. /**
  88588. * Interpolates a scalar cubically
  88589. * @param startValue Start value of the animation curve
  88590. * @param outTangent End tangent of the animation
  88591. * @param endValue End value of the animation curve
  88592. * @param inTangent Start tangent of the animation curve
  88593. * @param gradient Scalar amount to interpolate
  88594. * @returns Interpolated scalar value
  88595. */
  88596. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  88597. /**
  88598. * Interpolates a quaternion using a spherical linear interpolation
  88599. * @param startValue Start value of the animation curve
  88600. * @param endValue End value of the animation curve
  88601. * @param gradient Scalar amount to interpolate
  88602. * @returns Interpolated quaternion value
  88603. */
  88604. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  88605. /**
  88606. * Interpolates a quaternion cubically
  88607. * @param startValue Start value of the animation curve
  88608. * @param outTangent End tangent of the animation curve
  88609. * @param endValue End value of the animation curve
  88610. * @param inTangent Start tangent of the animation curve
  88611. * @param gradient Scalar amount to interpolate
  88612. * @returns Interpolated quaternion value
  88613. */
  88614. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  88615. /**
  88616. * Interpolates a Vector3 linearl
  88617. * @param startValue Start value of the animation curve
  88618. * @param endValue End value of the animation curve
  88619. * @param gradient Scalar amount to interpolate
  88620. * @returns Interpolated scalar value
  88621. */
  88622. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  88623. /**
  88624. * Interpolates a Vector3 cubically
  88625. * @param startValue Start value of the animation curve
  88626. * @param outTangent End tangent of the animation
  88627. * @param endValue End value of the animation curve
  88628. * @param inTangent Start tangent of the animation curve
  88629. * @param gradient Scalar amount to interpolate
  88630. * @returns InterpolatedVector3 value
  88631. */
  88632. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  88633. /**
  88634. * Interpolates a Vector2 linearly
  88635. * @param startValue Start value of the animation curve
  88636. * @param endValue End value of the animation curve
  88637. * @param gradient Scalar amount to interpolate
  88638. * @returns Interpolated Vector2 value
  88639. */
  88640. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  88641. /**
  88642. * Interpolates a Vector2 cubically
  88643. * @param startValue Start value of the animation curve
  88644. * @param outTangent End tangent of the animation
  88645. * @param endValue End value of the animation curve
  88646. * @param inTangent Start tangent of the animation curve
  88647. * @param gradient Scalar amount to interpolate
  88648. * @returns Interpolated Vector2 value
  88649. */
  88650. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  88651. /**
  88652. * Interpolates a size linearly
  88653. * @param startValue Start value of the animation curve
  88654. * @param endValue End value of the animation curve
  88655. * @param gradient Scalar amount to interpolate
  88656. * @returns Interpolated Size value
  88657. */
  88658. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  88659. /**
  88660. * Interpolates a Color3 linearly
  88661. * @param startValue Start value of the animation curve
  88662. * @param endValue End value of the animation curve
  88663. * @param gradient Scalar amount to interpolate
  88664. * @returns Interpolated Color3 value
  88665. */
  88666. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  88667. /**
  88668. * @hidden Internal use only
  88669. */
  88670. _getKeyValue(value: any): any;
  88671. /**
  88672. * @hidden Internal use only
  88673. */
  88674. _interpolate(currentFrame: number, state: _IAnimationState): any;
  88675. /**
  88676. * Defines the function to use to interpolate matrices
  88677. * @param startValue defines the start matrix
  88678. * @param endValue defines the end matrix
  88679. * @param gradient defines the gradient between both matrices
  88680. * @param result defines an optional target matrix where to store the interpolation
  88681. * @returns the interpolated matrix
  88682. */
  88683. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  88684. /**
  88685. * Makes a copy of the animation
  88686. * @returns Cloned animation
  88687. */
  88688. clone(): Animation;
  88689. /**
  88690. * Sets the key frames of the animation
  88691. * @param values The animation key frames to set
  88692. */
  88693. setKeys(values: Array<IAnimationKey>): void;
  88694. /**
  88695. * Serializes the animation to an object
  88696. * @returns Serialized object
  88697. */
  88698. serialize(): any;
  88699. /**
  88700. * Float animation type
  88701. */
  88702. private static _ANIMATIONTYPE_FLOAT;
  88703. /**
  88704. * Vector3 animation type
  88705. */
  88706. private static _ANIMATIONTYPE_VECTOR3;
  88707. /**
  88708. * Quaternion animation type
  88709. */
  88710. private static _ANIMATIONTYPE_QUATERNION;
  88711. /**
  88712. * Matrix animation type
  88713. */
  88714. private static _ANIMATIONTYPE_MATRIX;
  88715. /**
  88716. * Color3 animation type
  88717. */
  88718. private static _ANIMATIONTYPE_COLOR3;
  88719. /**
  88720. * Vector2 animation type
  88721. */
  88722. private static _ANIMATIONTYPE_VECTOR2;
  88723. /**
  88724. * Size animation type
  88725. */
  88726. private static _ANIMATIONTYPE_SIZE;
  88727. /**
  88728. * Relative Loop Mode
  88729. */
  88730. private static _ANIMATIONLOOPMODE_RELATIVE;
  88731. /**
  88732. * Cycle Loop Mode
  88733. */
  88734. private static _ANIMATIONLOOPMODE_CYCLE;
  88735. /**
  88736. * Constant Loop Mode
  88737. */
  88738. private static _ANIMATIONLOOPMODE_CONSTANT;
  88739. /**
  88740. * Get the float animation type
  88741. */
  88742. static readonly ANIMATIONTYPE_FLOAT: number;
  88743. /**
  88744. * Get the Vector3 animation type
  88745. */
  88746. static readonly ANIMATIONTYPE_VECTOR3: number;
  88747. /**
  88748. * Get the Vector2 animation type
  88749. */
  88750. static readonly ANIMATIONTYPE_VECTOR2: number;
  88751. /**
  88752. * Get the Size animation type
  88753. */
  88754. static readonly ANIMATIONTYPE_SIZE: number;
  88755. /**
  88756. * Get the Quaternion animation type
  88757. */
  88758. static readonly ANIMATIONTYPE_QUATERNION: number;
  88759. /**
  88760. * Get the Matrix animation type
  88761. */
  88762. static readonly ANIMATIONTYPE_MATRIX: number;
  88763. /**
  88764. * Get the Color3 animation type
  88765. */
  88766. static readonly ANIMATIONTYPE_COLOR3: number;
  88767. /**
  88768. * Get the Relative Loop Mode
  88769. */
  88770. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  88771. /**
  88772. * Get the Cycle Loop Mode
  88773. */
  88774. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  88775. /**
  88776. * Get the Constant Loop Mode
  88777. */
  88778. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  88779. /** @hidden */
  88780. static _UniversalLerp(left: any, right: any, amount: number): any;
  88781. /**
  88782. * Parses an animation object and creates an animation
  88783. * @param parsedAnimation Parsed animation object
  88784. * @returns Animation object
  88785. */
  88786. static Parse(parsedAnimation: any): Animation;
  88787. /**
  88788. * Appends the serialized animations from the source animations
  88789. * @param source Source containing the animations
  88790. * @param destination Target to store the animations
  88791. */
  88792. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  88793. }
  88794. }
  88795. declare module BABYLON {
  88796. /**
  88797. * Base class of all the textures in babylon.
  88798. * It groups all the common properties the materials, post process, lights... might need
  88799. * in order to make a correct use of the texture.
  88800. */
  88801. export class BaseTexture implements IAnimatable {
  88802. /**
  88803. * Default anisotropic filtering level for the application.
  88804. * It is set to 4 as a good tradeoff between perf and quality.
  88805. */
  88806. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  88807. /**
  88808. * Gets or sets the unique id of the texture
  88809. */
  88810. uniqueId: number;
  88811. /**
  88812. * Define the name of the texture.
  88813. */
  88814. name: string;
  88815. /**
  88816. * Gets or sets an object used to store user defined information.
  88817. */
  88818. metadata: any;
  88819. /**
  88820. * For internal use only. Please do not use.
  88821. */
  88822. reservedDataStore: any;
  88823. private _hasAlpha;
  88824. /**
  88825. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  88826. */
  88827. hasAlpha: boolean;
  88828. /**
  88829. * Defines if the alpha value should be determined via the rgb values.
  88830. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  88831. */
  88832. getAlphaFromRGB: boolean;
  88833. /**
  88834. * Intensity or strength of the texture.
  88835. * It is commonly used by materials to fine tune the intensity of the texture
  88836. */
  88837. level: number;
  88838. /**
  88839. * Define the UV chanel to use starting from 0 and defaulting to 0.
  88840. * This is part of the texture as textures usually maps to one uv set.
  88841. */
  88842. coordinatesIndex: number;
  88843. private _coordinatesMode;
  88844. /**
  88845. * How a texture is mapped.
  88846. *
  88847. * | Value | Type | Description |
  88848. * | ----- | ----------------------------------- | ----------- |
  88849. * | 0 | EXPLICIT_MODE | |
  88850. * | 1 | SPHERICAL_MODE | |
  88851. * | 2 | PLANAR_MODE | |
  88852. * | 3 | CUBIC_MODE | |
  88853. * | 4 | PROJECTION_MODE | |
  88854. * | 5 | SKYBOX_MODE | |
  88855. * | 6 | INVCUBIC_MODE | |
  88856. * | 7 | EQUIRECTANGULAR_MODE | |
  88857. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  88858. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  88859. */
  88860. coordinatesMode: number;
  88861. /**
  88862. * | Value | Type | Description |
  88863. * | ----- | ------------------ | ----------- |
  88864. * | 0 | CLAMP_ADDRESSMODE | |
  88865. * | 1 | WRAP_ADDRESSMODE | |
  88866. * | 2 | MIRROR_ADDRESSMODE | |
  88867. */
  88868. wrapU: number;
  88869. /**
  88870. * | Value | Type | Description |
  88871. * | ----- | ------------------ | ----------- |
  88872. * | 0 | CLAMP_ADDRESSMODE | |
  88873. * | 1 | WRAP_ADDRESSMODE | |
  88874. * | 2 | MIRROR_ADDRESSMODE | |
  88875. */
  88876. wrapV: number;
  88877. /**
  88878. * | Value | Type | Description |
  88879. * | ----- | ------------------ | ----------- |
  88880. * | 0 | CLAMP_ADDRESSMODE | |
  88881. * | 1 | WRAP_ADDRESSMODE | |
  88882. * | 2 | MIRROR_ADDRESSMODE | |
  88883. */
  88884. wrapR: number;
  88885. /**
  88886. * With compliant hardware and browser (supporting anisotropic filtering)
  88887. * this defines the level of anisotropic filtering in the texture.
  88888. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  88889. */
  88890. anisotropicFilteringLevel: number;
  88891. /**
  88892. * Define if the texture is a cube texture or if false a 2d texture.
  88893. */
  88894. isCube: boolean;
  88895. /**
  88896. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  88897. */
  88898. is3D: boolean;
  88899. /**
  88900. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  88901. * HDR texture are usually stored in linear space.
  88902. * This only impacts the PBR and Background materials
  88903. */
  88904. gammaSpace: boolean;
  88905. /**
  88906. * Gets whether or not the texture contains RGBD data.
  88907. */
  88908. readonly isRGBD: boolean;
  88909. /**
  88910. * Is Z inverted in the texture (useful in a cube texture).
  88911. */
  88912. invertZ: boolean;
  88913. /**
  88914. * Are mip maps generated for this texture or not.
  88915. */
  88916. readonly noMipmap: boolean;
  88917. /**
  88918. * @hidden
  88919. */
  88920. lodLevelInAlpha: boolean;
  88921. /**
  88922. * With prefiltered texture, defined the offset used during the prefiltering steps.
  88923. */
  88924. lodGenerationOffset: number;
  88925. /**
  88926. * With prefiltered texture, defined the scale used during the prefiltering steps.
  88927. */
  88928. lodGenerationScale: number;
  88929. /**
  88930. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  88931. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  88932. * average roughness values.
  88933. */
  88934. linearSpecularLOD: boolean;
  88935. /**
  88936. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  88937. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  88938. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  88939. */
  88940. irradianceTexture: Nullable<BaseTexture>;
  88941. /**
  88942. * Define if the texture is a render target.
  88943. */
  88944. isRenderTarget: boolean;
  88945. /**
  88946. * Define the unique id of the texture in the scene.
  88947. */
  88948. readonly uid: string;
  88949. /**
  88950. * Return a string representation of the texture.
  88951. * @returns the texture as a string
  88952. */
  88953. toString(): string;
  88954. /**
  88955. * Get the class name of the texture.
  88956. * @returns "BaseTexture"
  88957. */
  88958. getClassName(): string;
  88959. /**
  88960. * Define the list of animation attached to the texture.
  88961. */
  88962. animations: Animation[];
  88963. /**
  88964. * An event triggered when the texture is disposed.
  88965. */
  88966. onDisposeObservable: Observable<BaseTexture>;
  88967. private _onDisposeObserver;
  88968. /**
  88969. * Callback triggered when the texture has been disposed.
  88970. * Kept for back compatibility, you can use the onDisposeObservable instead.
  88971. */
  88972. onDispose: () => void;
  88973. /**
  88974. * Define the current state of the loading sequence when in delayed load mode.
  88975. */
  88976. delayLoadState: number;
  88977. private _scene;
  88978. /** @hidden */
  88979. _texture: Nullable<InternalTexture>;
  88980. private _uid;
  88981. /**
  88982. * Define if the texture is preventinga material to render or not.
  88983. * If not and the texture is not ready, the engine will use a default black texture instead.
  88984. */
  88985. readonly isBlocking: boolean;
  88986. /**
  88987. * Instantiates a new BaseTexture.
  88988. * Base class of all the textures in babylon.
  88989. * It groups all the common properties the materials, post process, lights... might need
  88990. * in order to make a correct use of the texture.
  88991. * @param scene Define the scene the texture blongs to
  88992. */
  88993. constructor(scene: Nullable<Scene>);
  88994. /**
  88995. * Get the scene the texture belongs to.
  88996. * @returns the scene or null if undefined
  88997. */
  88998. getScene(): Nullable<Scene>;
  88999. /**
  89000. * Get the texture transform matrix used to offset tile the texture for istance.
  89001. * @returns the transformation matrix
  89002. */
  89003. getTextureMatrix(): Matrix;
  89004. /**
  89005. * Get the texture reflection matrix used to rotate/transform the reflection.
  89006. * @returns the reflection matrix
  89007. */
  89008. getReflectionTextureMatrix(): Matrix;
  89009. /**
  89010. * Get the underlying lower level texture from Babylon.
  89011. * @returns the insternal texture
  89012. */
  89013. getInternalTexture(): Nullable<InternalTexture>;
  89014. /**
  89015. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  89016. * @returns true if ready or not blocking
  89017. */
  89018. isReadyOrNotBlocking(): boolean;
  89019. /**
  89020. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  89021. * @returns true if fully ready
  89022. */
  89023. isReady(): boolean;
  89024. private _cachedSize;
  89025. /**
  89026. * Get the size of the texture.
  89027. * @returns the texture size.
  89028. */
  89029. getSize(): ISize;
  89030. /**
  89031. * Get the base size of the texture.
  89032. * It can be different from the size if the texture has been resized for POT for instance
  89033. * @returns the base size
  89034. */
  89035. getBaseSize(): ISize;
  89036. /**
  89037. * Update the sampling mode of the texture.
  89038. * Default is Trilinear mode.
  89039. *
  89040. * | Value | Type | Description |
  89041. * | ----- | ------------------ | ----------- |
  89042. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  89043. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  89044. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  89045. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  89046. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  89047. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  89048. * | 7 | NEAREST_LINEAR | |
  89049. * | 8 | NEAREST_NEAREST | |
  89050. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  89051. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  89052. * | 11 | LINEAR_LINEAR | |
  89053. * | 12 | LINEAR_NEAREST | |
  89054. *
  89055. * > _mag_: magnification filter (close to the viewer)
  89056. * > _min_: minification filter (far from the viewer)
  89057. * > _mip_: filter used between mip map levels
  89058. *@param samplingMode Define the new sampling mode of the texture
  89059. */
  89060. updateSamplingMode(samplingMode: number): void;
  89061. /**
  89062. * Scales the texture if is `canRescale()`
  89063. * @param ratio the resize factor we want to use to rescale
  89064. */
  89065. scale(ratio: number): void;
  89066. /**
  89067. * Get if the texture can rescale.
  89068. */
  89069. readonly canRescale: boolean;
  89070. /** @hidden */
  89071. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  89072. /** @hidden */
  89073. _rebuild(): void;
  89074. /**
  89075. * Triggers the load sequence in delayed load mode.
  89076. */
  89077. delayLoad(): void;
  89078. /**
  89079. * Clones the texture.
  89080. * @returns the cloned texture
  89081. */
  89082. clone(): Nullable<BaseTexture>;
  89083. /**
  89084. * Get the texture underlying type (INT, FLOAT...)
  89085. */
  89086. readonly textureType: number;
  89087. /**
  89088. * Get the texture underlying format (RGB, RGBA...)
  89089. */
  89090. readonly textureFormat: number;
  89091. /**
  89092. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  89093. * This will returns an RGBA array buffer containing either in values (0-255) or
  89094. * float values (0-1) depending of the underlying buffer type.
  89095. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  89096. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  89097. * @param buffer defines a user defined buffer to fill with data (can be null)
  89098. * @returns The Array buffer containing the pixels data.
  89099. */
  89100. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  89101. /**
  89102. * Release and destroy the underlying lower level texture aka internalTexture.
  89103. */
  89104. releaseInternalTexture(): void;
  89105. /**
  89106. * Get the polynomial representation of the texture data.
  89107. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  89108. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  89109. */
  89110. sphericalPolynomial: Nullable<SphericalPolynomial>;
  89111. /** @hidden */
  89112. readonly _lodTextureHigh: Nullable<BaseTexture>;
  89113. /** @hidden */
  89114. readonly _lodTextureMid: Nullable<BaseTexture>;
  89115. /** @hidden */
  89116. readonly _lodTextureLow: Nullable<BaseTexture>;
  89117. /**
  89118. * Dispose the texture and release its associated resources.
  89119. */
  89120. dispose(): void;
  89121. /**
  89122. * Serialize the texture into a JSON representation that can be parsed later on.
  89123. * @returns the JSON representation of the texture
  89124. */
  89125. serialize(): any;
  89126. /**
  89127. * Helper function to be called back once a list of texture contains only ready textures.
  89128. * @param textures Define the list of textures to wait for
  89129. * @param callback Define the callback triggered once the entire list will be ready
  89130. */
  89131. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  89132. }
  89133. }
  89134. declare module BABYLON {
  89135. /**
  89136. * Uniform buffer objects.
  89137. *
  89138. * Handles blocks of uniform on the GPU.
  89139. *
  89140. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  89141. *
  89142. * For more information, please refer to :
  89143. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  89144. */
  89145. export class UniformBuffer {
  89146. private _engine;
  89147. private _buffer;
  89148. private _data;
  89149. private _bufferData;
  89150. private _dynamic?;
  89151. private _uniformLocations;
  89152. private _uniformSizes;
  89153. private _uniformLocationPointer;
  89154. private _needSync;
  89155. private _noUBO;
  89156. private _currentEffect;
  89157. private static _MAX_UNIFORM_SIZE;
  89158. private static _tempBuffer;
  89159. /**
  89160. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  89161. * This is dynamic to allow compat with webgl 1 and 2.
  89162. * You will need to pass the name of the uniform as well as the value.
  89163. */
  89164. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  89165. /**
  89166. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  89167. * This is dynamic to allow compat with webgl 1 and 2.
  89168. * You will need to pass the name of the uniform as well as the value.
  89169. */
  89170. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  89171. /**
  89172. * Lambda to Update a single float in a uniform buffer.
  89173. * This is dynamic to allow compat with webgl 1 and 2.
  89174. * You will need to pass the name of the uniform as well as the value.
  89175. */
  89176. updateFloat: (name: string, x: number) => void;
  89177. /**
  89178. * Lambda to Update a vec2 of float in a uniform buffer.
  89179. * This is dynamic to allow compat with webgl 1 and 2.
  89180. * You will need to pass the name of the uniform as well as the value.
  89181. */
  89182. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  89183. /**
  89184. * Lambda to Update a vec3 of float in a uniform buffer.
  89185. * This is dynamic to allow compat with webgl 1 and 2.
  89186. * You will need to pass the name of the uniform as well as the value.
  89187. */
  89188. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  89189. /**
  89190. * Lambda to Update a vec4 of float in a uniform buffer.
  89191. * This is dynamic to allow compat with webgl 1 and 2.
  89192. * You will need to pass the name of the uniform as well as the value.
  89193. */
  89194. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  89195. /**
  89196. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  89197. * This is dynamic to allow compat with webgl 1 and 2.
  89198. * You will need to pass the name of the uniform as well as the value.
  89199. */
  89200. updateMatrix: (name: string, mat: Matrix) => void;
  89201. /**
  89202. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  89203. * This is dynamic to allow compat with webgl 1 and 2.
  89204. * You will need to pass the name of the uniform as well as the value.
  89205. */
  89206. updateVector3: (name: string, vector: Vector3) => void;
  89207. /**
  89208. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  89209. * This is dynamic to allow compat with webgl 1 and 2.
  89210. * You will need to pass the name of the uniform as well as the value.
  89211. */
  89212. updateVector4: (name: string, vector: Vector4) => void;
  89213. /**
  89214. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  89215. * This is dynamic to allow compat with webgl 1 and 2.
  89216. * You will need to pass the name of the uniform as well as the value.
  89217. */
  89218. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  89219. /**
  89220. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  89221. * This is dynamic to allow compat with webgl 1 and 2.
  89222. * You will need to pass the name of the uniform as well as the value.
  89223. */
  89224. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  89225. /**
  89226. * Instantiates a new Uniform buffer objects.
  89227. *
  89228. * Handles blocks of uniform on the GPU.
  89229. *
  89230. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  89231. *
  89232. * For more information, please refer to :
  89233. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  89234. * @param engine Define the engine the buffer is associated with
  89235. * @param data Define the data contained in the buffer
  89236. * @param dynamic Define if the buffer is updatable
  89237. */
  89238. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  89239. /**
  89240. * Indicates if the buffer is using the WebGL2 UBO implementation,
  89241. * or just falling back on setUniformXXX calls.
  89242. */
  89243. readonly useUbo: boolean;
  89244. /**
  89245. * Indicates if the WebGL underlying uniform buffer is in sync
  89246. * with the javascript cache data.
  89247. */
  89248. readonly isSync: boolean;
  89249. /**
  89250. * Indicates if the WebGL underlying uniform buffer is dynamic.
  89251. * Also, a dynamic UniformBuffer will disable cache verification and always
  89252. * update the underlying WebGL uniform buffer to the GPU.
  89253. * @returns if Dynamic, otherwise false
  89254. */
  89255. isDynamic(): boolean;
  89256. /**
  89257. * The data cache on JS side.
  89258. * @returns the underlying data as a float array
  89259. */
  89260. getData(): Float32Array;
  89261. /**
  89262. * The underlying WebGL Uniform buffer.
  89263. * @returns the webgl buffer
  89264. */
  89265. getBuffer(): Nullable<DataBuffer>;
  89266. /**
  89267. * std140 layout specifies how to align data within an UBO structure.
  89268. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  89269. * for specs.
  89270. */
  89271. private _fillAlignment;
  89272. /**
  89273. * Adds an uniform in the buffer.
  89274. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  89275. * for the layout to be correct !
  89276. * @param name Name of the uniform, as used in the uniform block in the shader.
  89277. * @param size Data size, or data directly.
  89278. */
  89279. addUniform(name: string, size: number | number[]): void;
  89280. /**
  89281. * Adds a Matrix 4x4 to the uniform buffer.
  89282. * @param name Name of the uniform, as used in the uniform block in the shader.
  89283. * @param mat A 4x4 matrix.
  89284. */
  89285. addMatrix(name: string, mat: Matrix): void;
  89286. /**
  89287. * Adds a vec2 to the uniform buffer.
  89288. * @param name Name of the uniform, as used in the uniform block in the shader.
  89289. * @param x Define the x component value of the vec2
  89290. * @param y Define the y component value of the vec2
  89291. */
  89292. addFloat2(name: string, x: number, y: number): void;
  89293. /**
  89294. * Adds a vec3 to the uniform buffer.
  89295. * @param name Name of the uniform, as used in the uniform block in the shader.
  89296. * @param x Define the x component value of the vec3
  89297. * @param y Define the y component value of the vec3
  89298. * @param z Define the z component value of the vec3
  89299. */
  89300. addFloat3(name: string, x: number, y: number, z: number): void;
  89301. /**
  89302. * Adds a vec3 to the uniform buffer.
  89303. * @param name Name of the uniform, as used in the uniform block in the shader.
  89304. * @param color Define the vec3 from a Color
  89305. */
  89306. addColor3(name: string, color: Color3): void;
  89307. /**
  89308. * Adds a vec4 to the uniform buffer.
  89309. * @param name Name of the uniform, as used in the uniform block in the shader.
  89310. * @param color Define the rgb components from a Color
  89311. * @param alpha Define the a component of the vec4
  89312. */
  89313. addColor4(name: string, color: Color3, alpha: number): void;
  89314. /**
  89315. * Adds a vec3 to the uniform buffer.
  89316. * @param name Name of the uniform, as used in the uniform block in the shader.
  89317. * @param vector Define the vec3 components from a Vector
  89318. */
  89319. addVector3(name: string, vector: Vector3): void;
  89320. /**
  89321. * Adds a Matrix 3x3 to the uniform buffer.
  89322. * @param name Name of the uniform, as used in the uniform block in the shader.
  89323. */
  89324. addMatrix3x3(name: string): void;
  89325. /**
  89326. * Adds a Matrix 2x2 to the uniform buffer.
  89327. * @param name Name of the uniform, as used in the uniform block in the shader.
  89328. */
  89329. addMatrix2x2(name: string): void;
  89330. /**
  89331. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  89332. */
  89333. create(): void;
  89334. /** @hidden */
  89335. _rebuild(): void;
  89336. /**
  89337. * Updates the WebGL Uniform Buffer on the GPU.
  89338. * If the `dynamic` flag is set to true, no cache comparison is done.
  89339. * Otherwise, the buffer will be updated only if the cache differs.
  89340. */
  89341. update(): void;
  89342. /**
  89343. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  89344. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89345. * @param data Define the flattened data
  89346. * @param size Define the size of the data.
  89347. */
  89348. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  89349. private _updateMatrix3x3ForUniform;
  89350. private _updateMatrix3x3ForEffect;
  89351. private _updateMatrix2x2ForEffect;
  89352. private _updateMatrix2x2ForUniform;
  89353. private _updateFloatForEffect;
  89354. private _updateFloatForUniform;
  89355. private _updateFloat2ForEffect;
  89356. private _updateFloat2ForUniform;
  89357. private _updateFloat3ForEffect;
  89358. private _updateFloat3ForUniform;
  89359. private _updateFloat4ForEffect;
  89360. private _updateFloat4ForUniform;
  89361. private _updateMatrixForEffect;
  89362. private _updateMatrixForUniform;
  89363. private _updateVector3ForEffect;
  89364. private _updateVector3ForUniform;
  89365. private _updateVector4ForEffect;
  89366. private _updateVector4ForUniform;
  89367. private _updateColor3ForEffect;
  89368. private _updateColor3ForUniform;
  89369. private _updateColor4ForEffect;
  89370. private _updateColor4ForUniform;
  89371. /**
  89372. * Sets a sampler uniform on the effect.
  89373. * @param name Define the name of the sampler.
  89374. * @param texture Define the texture to set in the sampler
  89375. */
  89376. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  89377. /**
  89378. * Directly updates the value of the uniform in the cache AND on the GPU.
  89379. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  89380. * @param data Define the flattened data
  89381. */
  89382. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  89383. /**
  89384. * Binds this uniform buffer to an effect.
  89385. * @param effect Define the effect to bind the buffer to
  89386. * @param name Name of the uniform block in the shader.
  89387. */
  89388. bindToEffect(effect: Effect, name: string): void;
  89389. /**
  89390. * Disposes the uniform buffer.
  89391. */
  89392. dispose(): void;
  89393. }
  89394. }
  89395. declare module BABYLON {
  89396. /**
  89397. * Class used to work with sound analyzer using fast fourier transform (FFT)
  89398. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89399. */
  89400. export class Analyser {
  89401. /**
  89402. * Gets or sets the smoothing
  89403. * @ignorenaming
  89404. */
  89405. SMOOTHING: number;
  89406. /**
  89407. * Gets or sets the FFT table size
  89408. * @ignorenaming
  89409. */
  89410. FFT_SIZE: number;
  89411. /**
  89412. * Gets or sets the bar graph amplitude
  89413. * @ignorenaming
  89414. */
  89415. BARGRAPHAMPLITUDE: number;
  89416. /**
  89417. * Gets or sets the position of the debug canvas
  89418. * @ignorenaming
  89419. */
  89420. DEBUGCANVASPOS: {
  89421. x: number;
  89422. y: number;
  89423. };
  89424. /**
  89425. * Gets or sets the debug canvas size
  89426. * @ignorenaming
  89427. */
  89428. DEBUGCANVASSIZE: {
  89429. width: number;
  89430. height: number;
  89431. };
  89432. private _byteFreqs;
  89433. private _byteTime;
  89434. private _floatFreqs;
  89435. private _webAudioAnalyser;
  89436. private _debugCanvas;
  89437. private _debugCanvasContext;
  89438. private _scene;
  89439. private _registerFunc;
  89440. private _audioEngine;
  89441. /**
  89442. * Creates a new analyser
  89443. * @param scene defines hosting scene
  89444. */
  89445. constructor(scene: Scene);
  89446. /**
  89447. * Get the number of data values you will have to play with for the visualization
  89448. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  89449. * @returns a number
  89450. */
  89451. getFrequencyBinCount(): number;
  89452. /**
  89453. * Gets the current frequency data as a byte array
  89454. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  89455. * @returns a Uint8Array
  89456. */
  89457. getByteFrequencyData(): Uint8Array;
  89458. /**
  89459. * Gets the current waveform as a byte array
  89460. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  89461. * @returns a Uint8Array
  89462. */
  89463. getByteTimeDomainData(): Uint8Array;
  89464. /**
  89465. * Gets the current frequency data as a float array
  89466. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  89467. * @returns a Float32Array
  89468. */
  89469. getFloatFrequencyData(): Float32Array;
  89470. /**
  89471. * Renders the debug canvas
  89472. */
  89473. drawDebugCanvas(): void;
  89474. /**
  89475. * Stops rendering the debug canvas and removes it
  89476. */
  89477. stopDebugCanvas(): void;
  89478. /**
  89479. * Connects two audio nodes
  89480. * @param inputAudioNode defines first node to connect
  89481. * @param outputAudioNode defines second node to connect
  89482. */
  89483. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  89484. /**
  89485. * Releases all associated resources
  89486. */
  89487. dispose(): void;
  89488. }
  89489. }
  89490. declare module BABYLON {
  89491. /**
  89492. * This represents an audio engine and it is responsible
  89493. * to play, synchronize and analyse sounds throughout the application.
  89494. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89495. */
  89496. export interface IAudioEngine extends IDisposable {
  89497. /**
  89498. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  89499. */
  89500. readonly canUseWebAudio: boolean;
  89501. /**
  89502. * Gets the current AudioContext if available.
  89503. */
  89504. readonly audioContext: Nullable<AudioContext>;
  89505. /**
  89506. * The master gain node defines the global audio volume of your audio engine.
  89507. */
  89508. readonly masterGain: GainNode;
  89509. /**
  89510. * Gets whether or not mp3 are supported by your browser.
  89511. */
  89512. readonly isMP3supported: boolean;
  89513. /**
  89514. * Gets whether or not ogg are supported by your browser.
  89515. */
  89516. readonly isOGGsupported: boolean;
  89517. /**
  89518. * Defines if Babylon should emit a warning if WebAudio is not supported.
  89519. * @ignoreNaming
  89520. */
  89521. WarnedWebAudioUnsupported: boolean;
  89522. /**
  89523. * Defines if the audio engine relies on a custom unlocked button.
  89524. * In this case, the embedded button will not be displayed.
  89525. */
  89526. useCustomUnlockedButton: boolean;
  89527. /**
  89528. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  89529. */
  89530. readonly unlocked: boolean;
  89531. /**
  89532. * Event raised when audio has been unlocked on the browser.
  89533. */
  89534. onAudioUnlockedObservable: Observable<AudioEngine>;
  89535. /**
  89536. * Event raised when audio has been locked on the browser.
  89537. */
  89538. onAudioLockedObservable: Observable<AudioEngine>;
  89539. /**
  89540. * Flags the audio engine in Locked state.
  89541. * This happens due to new browser policies preventing audio to autoplay.
  89542. */
  89543. lock(): void;
  89544. /**
  89545. * Unlocks the audio engine once a user action has been done on the dom.
  89546. * This is helpful to resume play once browser policies have been satisfied.
  89547. */
  89548. unlock(): void;
  89549. }
  89550. /**
  89551. * This represents the default audio engine used in babylon.
  89552. * It is responsible to play, synchronize and analyse sounds throughout the application.
  89553. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89554. */
  89555. export class AudioEngine implements IAudioEngine {
  89556. private _audioContext;
  89557. private _audioContextInitialized;
  89558. private _muteButton;
  89559. private _hostElement;
  89560. /**
  89561. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  89562. */
  89563. canUseWebAudio: boolean;
  89564. /**
  89565. * The master gain node defines the global audio volume of your audio engine.
  89566. */
  89567. masterGain: GainNode;
  89568. /**
  89569. * Defines if Babylon should emit a warning if WebAudio is not supported.
  89570. * @ignoreNaming
  89571. */
  89572. WarnedWebAudioUnsupported: boolean;
  89573. /**
  89574. * Gets whether or not mp3 are supported by your browser.
  89575. */
  89576. isMP3supported: boolean;
  89577. /**
  89578. * Gets whether or not ogg are supported by your browser.
  89579. */
  89580. isOGGsupported: boolean;
  89581. /**
  89582. * Gets whether audio has been unlocked on the device.
  89583. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  89584. * a user interaction has happened.
  89585. */
  89586. unlocked: boolean;
  89587. /**
  89588. * Defines if the audio engine relies on a custom unlocked button.
  89589. * In this case, the embedded button will not be displayed.
  89590. */
  89591. useCustomUnlockedButton: boolean;
  89592. /**
  89593. * Event raised when audio has been unlocked on the browser.
  89594. */
  89595. onAudioUnlockedObservable: Observable<AudioEngine>;
  89596. /**
  89597. * Event raised when audio has been locked on the browser.
  89598. */
  89599. onAudioLockedObservable: Observable<AudioEngine>;
  89600. /**
  89601. * Gets the current AudioContext if available.
  89602. */
  89603. readonly audioContext: Nullable<AudioContext>;
  89604. private _connectedAnalyser;
  89605. /**
  89606. * Instantiates a new audio engine.
  89607. *
  89608. * There should be only one per page as some browsers restrict the number
  89609. * of audio contexts you can create.
  89610. * @param hostElement defines the host element where to display the mute icon if necessary
  89611. */
  89612. constructor(hostElement?: Nullable<HTMLElement>);
  89613. /**
  89614. * Flags the audio engine in Locked state.
  89615. * This happens due to new browser policies preventing audio to autoplay.
  89616. */
  89617. lock(): void;
  89618. /**
  89619. * Unlocks the audio engine once a user action has been done on the dom.
  89620. * This is helpful to resume play once browser policies have been satisfied.
  89621. */
  89622. unlock(): void;
  89623. private _resumeAudioContext;
  89624. private _initializeAudioContext;
  89625. private _tryToRun;
  89626. private _triggerRunningState;
  89627. private _triggerSuspendedState;
  89628. private _displayMuteButton;
  89629. private _moveButtonToTopLeft;
  89630. private _onResize;
  89631. private _hideMuteButton;
  89632. /**
  89633. * Destroy and release the resources associated with the audio ccontext.
  89634. */
  89635. dispose(): void;
  89636. /**
  89637. * Gets the global volume sets on the master gain.
  89638. * @returns the global volume if set or -1 otherwise
  89639. */
  89640. getGlobalVolume(): number;
  89641. /**
  89642. * Sets the global volume of your experience (sets on the master gain).
  89643. * @param newVolume Defines the new global volume of the application
  89644. */
  89645. setGlobalVolume(newVolume: number): void;
  89646. /**
  89647. * Connect the audio engine to an audio analyser allowing some amazing
  89648. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  89649. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  89650. * @param analyser The analyser to connect to the engine
  89651. */
  89652. connectToAnalyser(analyser: Analyser): void;
  89653. }
  89654. }
  89655. declare module BABYLON {
  89656. /**
  89657. * Interface used to present a loading screen while loading a scene
  89658. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  89659. */
  89660. export interface ILoadingScreen {
  89661. /**
  89662. * Function called to display the loading screen
  89663. */
  89664. displayLoadingUI: () => void;
  89665. /**
  89666. * Function called to hide the loading screen
  89667. */
  89668. hideLoadingUI: () => void;
  89669. /**
  89670. * Gets or sets the color to use for the background
  89671. */
  89672. loadingUIBackgroundColor: string;
  89673. /**
  89674. * Gets or sets the text to display while loading
  89675. */
  89676. loadingUIText: string;
  89677. }
  89678. /**
  89679. * Class used for the default loading screen
  89680. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  89681. */
  89682. export class DefaultLoadingScreen implements ILoadingScreen {
  89683. private _renderingCanvas;
  89684. private _loadingText;
  89685. private _loadingDivBackgroundColor;
  89686. private _loadingDiv;
  89687. private _loadingTextDiv;
  89688. /** Gets or sets the logo url to use for the default loading screen */
  89689. static DefaultLogoUrl: string;
  89690. /** Gets or sets the spinner url to use for the default loading screen */
  89691. static DefaultSpinnerUrl: string;
  89692. /**
  89693. * Creates a new default loading screen
  89694. * @param _renderingCanvas defines the canvas used to render the scene
  89695. * @param _loadingText defines the default text to display
  89696. * @param _loadingDivBackgroundColor defines the default background color
  89697. */
  89698. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  89699. /**
  89700. * Function called to display the loading screen
  89701. */
  89702. displayLoadingUI(): void;
  89703. /**
  89704. * Function called to hide the loading screen
  89705. */
  89706. hideLoadingUI(): void;
  89707. /**
  89708. * Gets or sets the text to display while loading
  89709. */
  89710. loadingUIText: string;
  89711. /**
  89712. * Gets or sets the color to use for the background
  89713. */
  89714. loadingUIBackgroundColor: string;
  89715. private _resizeLoadingUI;
  89716. }
  89717. }
  89718. declare module BABYLON {
  89719. /** @hidden */
  89720. export class WebGLPipelineContext implements IPipelineContext {
  89721. engine: Engine;
  89722. program: Nullable<WebGLProgram>;
  89723. context?: WebGLRenderingContext;
  89724. vertexShader?: WebGLShader;
  89725. fragmentShader?: WebGLShader;
  89726. isParallelCompiled: boolean;
  89727. onCompiled?: () => void;
  89728. transformFeedback?: WebGLTransformFeedback | null;
  89729. readonly isAsync: boolean;
  89730. readonly isReady: boolean;
  89731. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  89732. }
  89733. }
  89734. declare module BABYLON {
  89735. /** @hidden */
  89736. export class WebGLDataBuffer extends DataBuffer {
  89737. private _buffer;
  89738. constructor(resource: WebGLBuffer);
  89739. readonly underlyingResource: any;
  89740. }
  89741. }
  89742. declare module BABYLON {
  89743. /** @hidden */
  89744. export class WebGL2ShaderProcessor implements IShaderProcessor {
  89745. attributeProcessor(attribute: string): string;
  89746. varyingProcessor(varying: string, isFragment: boolean): string;
  89747. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  89748. }
  89749. }
  89750. declare module BABYLON {
  89751. /**
  89752. * Settings for finer control over video usage
  89753. */
  89754. export interface VideoTextureSettings {
  89755. /**
  89756. * Applies `autoplay` to video, if specified
  89757. */
  89758. autoPlay?: boolean;
  89759. /**
  89760. * Applies `loop` to video, if specified
  89761. */
  89762. loop?: boolean;
  89763. /**
  89764. * Automatically updates internal texture from video at every frame in the render loop
  89765. */
  89766. autoUpdateTexture: boolean;
  89767. /**
  89768. * Image src displayed during the video loading or until the user interacts with the video.
  89769. */
  89770. poster?: string;
  89771. }
  89772. /**
  89773. * If you want to display a video in your scene, this is the special texture for that.
  89774. * This special texture works similar to other textures, with the exception of a few parameters.
  89775. * @see https://doc.babylonjs.com/how_to/video_texture
  89776. */
  89777. export class VideoTexture extends Texture {
  89778. /**
  89779. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  89780. */
  89781. readonly autoUpdateTexture: boolean;
  89782. /**
  89783. * The video instance used by the texture internally
  89784. */
  89785. readonly video: HTMLVideoElement;
  89786. private _onUserActionRequestedObservable;
  89787. /**
  89788. * Event triggerd when a dom action is required by the user to play the video.
  89789. * This happens due to recent changes in browser policies preventing video to auto start.
  89790. */
  89791. readonly onUserActionRequestedObservable: Observable<Texture>;
  89792. private _generateMipMaps;
  89793. private _engine;
  89794. private _stillImageCaptured;
  89795. private _displayingPosterTexture;
  89796. private _settings;
  89797. private _createInternalTextureOnEvent;
  89798. /**
  89799. * Creates a video texture.
  89800. * If you want to display a video in your scene, this is the special texture for that.
  89801. * This special texture works similar to other textures, with the exception of a few parameters.
  89802. * @see https://doc.babylonjs.com/how_to/video_texture
  89803. * @param name optional name, will detect from video source, if not defined
  89804. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  89805. * @param scene is obviously the current scene.
  89806. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  89807. * @param invertY is false by default but can be used to invert video on Y axis
  89808. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  89809. * @param settings allows finer control over video usage
  89810. */
  89811. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  89812. private _getName;
  89813. private _getVideo;
  89814. private _createInternalTexture;
  89815. private reset;
  89816. /**
  89817. * @hidden Internal method to initiate `update`.
  89818. */
  89819. _rebuild(): void;
  89820. /**
  89821. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  89822. */
  89823. update(): void;
  89824. /**
  89825. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  89826. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  89827. */
  89828. updateTexture(isVisible: boolean): void;
  89829. protected _updateInternalTexture: () => void;
  89830. /**
  89831. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  89832. * @param url New url.
  89833. */
  89834. updateURL(url: string): void;
  89835. /**
  89836. * Dispose the texture and release its associated resources.
  89837. */
  89838. dispose(): void;
  89839. /**
  89840. * Creates a video texture straight from a stream.
  89841. * @param scene Define the scene the texture should be created in
  89842. * @param stream Define the stream the texture should be created from
  89843. * @returns The created video texture as a promise
  89844. */
  89845. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  89846. /**
  89847. * Creates a video texture straight from your WebCam video feed.
  89848. * @param scene Define the scene the texture should be created in
  89849. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  89850. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  89851. * @returns The created video texture as a promise
  89852. */
  89853. static CreateFromWebCamAsync(scene: Scene, constraints: {
  89854. minWidth: number;
  89855. maxWidth: number;
  89856. minHeight: number;
  89857. maxHeight: number;
  89858. deviceId: string;
  89859. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  89860. /**
  89861. * Creates a video texture straight from your WebCam video feed.
  89862. * @param scene Define the scene the texture should be created in
  89863. * @param onReady Define a callback to triggered once the texture will be ready
  89864. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  89865. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  89866. */
  89867. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  89868. minWidth: number;
  89869. maxWidth: number;
  89870. minHeight: number;
  89871. maxHeight: number;
  89872. deviceId: string;
  89873. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  89874. }
  89875. }
  89876. declare module BABYLON {
  89877. /**
  89878. * Interface for attribute information associated with buffer instanciation
  89879. */
  89880. export class InstancingAttributeInfo {
  89881. /**
  89882. * Index/offset of the attribute in the vertex shader
  89883. */
  89884. index: number;
  89885. /**
  89886. * size of the attribute, 1, 2, 3 or 4
  89887. */
  89888. attributeSize: number;
  89889. /**
  89890. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  89891. * default is FLOAT
  89892. */
  89893. attribyteType: number;
  89894. /**
  89895. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  89896. */
  89897. normalized: boolean;
  89898. /**
  89899. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  89900. */
  89901. offset: number;
  89902. /**
  89903. * Name of the GLSL attribute, for debugging purpose only
  89904. */
  89905. attributeName: string;
  89906. }
  89907. /**
  89908. * Define options used to create a depth texture
  89909. */
  89910. export class DepthTextureCreationOptions {
  89911. /** Specifies whether or not a stencil should be allocated in the texture */
  89912. generateStencil?: boolean;
  89913. /** Specifies whether or not bilinear filtering is enable on the texture */
  89914. bilinearFiltering?: boolean;
  89915. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  89916. comparisonFunction?: number;
  89917. /** Specifies if the created texture is a cube texture */
  89918. isCube?: boolean;
  89919. }
  89920. /**
  89921. * Class used to describe the capabilities of the engine relatively to the current browser
  89922. */
  89923. export class EngineCapabilities {
  89924. /** Maximum textures units per fragment shader */
  89925. maxTexturesImageUnits: number;
  89926. /** Maximum texture units per vertex shader */
  89927. maxVertexTextureImageUnits: number;
  89928. /** Maximum textures units in the entire pipeline */
  89929. maxCombinedTexturesImageUnits: number;
  89930. /** Maximum texture size */
  89931. maxTextureSize: number;
  89932. /** Maximum cube texture size */
  89933. maxCubemapTextureSize: number;
  89934. /** Maximum render texture size */
  89935. maxRenderTextureSize: number;
  89936. /** Maximum number of vertex attributes */
  89937. maxVertexAttribs: number;
  89938. /** Maximum number of varyings */
  89939. maxVaryingVectors: number;
  89940. /** Maximum number of uniforms per vertex shader */
  89941. maxVertexUniformVectors: number;
  89942. /** Maximum number of uniforms per fragment shader */
  89943. maxFragmentUniformVectors: number;
  89944. /** Defines if standard derivates (dx/dy) are supported */
  89945. standardDerivatives: boolean;
  89946. /** Defines if s3tc texture compression is supported */
  89947. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  89948. /** Defines if pvrtc texture compression is supported */
  89949. pvrtc: any;
  89950. /** Defines if etc1 texture compression is supported */
  89951. etc1: any;
  89952. /** Defines if etc2 texture compression is supported */
  89953. etc2: any;
  89954. /** Defines if astc texture compression is supported */
  89955. astc: any;
  89956. /** Defines if float textures are supported */
  89957. textureFloat: boolean;
  89958. /** Defines if vertex array objects are supported */
  89959. vertexArrayObject: boolean;
  89960. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  89961. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  89962. /** Gets the maximum level of anisotropy supported */
  89963. maxAnisotropy: number;
  89964. /** Defines if instancing is supported */
  89965. instancedArrays: boolean;
  89966. /** Defines if 32 bits indices are supported */
  89967. uintIndices: boolean;
  89968. /** Defines if high precision shaders are supported */
  89969. highPrecisionShaderSupported: boolean;
  89970. /** Defines if depth reading in the fragment shader is supported */
  89971. fragmentDepthSupported: boolean;
  89972. /** Defines if float texture linear filtering is supported*/
  89973. textureFloatLinearFiltering: boolean;
  89974. /** Defines if rendering to float textures is supported */
  89975. textureFloatRender: boolean;
  89976. /** Defines if half float textures are supported*/
  89977. textureHalfFloat: boolean;
  89978. /** Defines if half float texture linear filtering is supported*/
  89979. textureHalfFloatLinearFiltering: boolean;
  89980. /** Defines if rendering to half float textures is supported */
  89981. textureHalfFloatRender: boolean;
  89982. /** Defines if textureLOD shader command is supported */
  89983. textureLOD: boolean;
  89984. /** Defines if draw buffers extension is supported */
  89985. drawBuffersExtension: boolean;
  89986. /** Defines if depth textures are supported */
  89987. depthTextureExtension: boolean;
  89988. /** Defines if float color buffer are supported */
  89989. colorBufferFloat: boolean;
  89990. /** Gets disjoint timer query extension (null if not supported) */
  89991. timerQuery: EXT_disjoint_timer_query;
  89992. /** Defines if timestamp can be used with timer query */
  89993. canUseTimestampForTimerQuery: boolean;
  89994. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  89995. multiview: any;
  89996. /** Function used to let the system compiles shaders in background */
  89997. parallelShaderCompile: {
  89998. COMPLETION_STATUS_KHR: number;
  89999. };
  90000. }
  90001. /** Interface defining initialization parameters for Engine class */
  90002. export interface EngineOptions extends WebGLContextAttributes {
  90003. /**
  90004. * Defines if the engine should no exceed a specified device ratio
  90005. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  90006. */
  90007. limitDeviceRatio?: number;
  90008. /**
  90009. * Defines if webvr should be enabled automatically
  90010. * @see http://doc.babylonjs.com/how_to/webvr_camera
  90011. */
  90012. autoEnableWebVR?: boolean;
  90013. /**
  90014. * Defines if webgl2 should be turned off even if supported
  90015. * @see http://doc.babylonjs.com/features/webgl2
  90016. */
  90017. disableWebGL2Support?: boolean;
  90018. /**
  90019. * Defines if webaudio should be initialized as well
  90020. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90021. */
  90022. audioEngine?: boolean;
  90023. /**
  90024. * Defines if animations should run using a deterministic lock step
  90025. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90026. */
  90027. deterministicLockstep?: boolean;
  90028. /** Defines the maximum steps to use with deterministic lock step mode */
  90029. lockstepMaxSteps?: number;
  90030. /**
  90031. * Defines that engine should ignore context lost events
  90032. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  90033. */
  90034. doNotHandleContextLost?: boolean;
  90035. /**
  90036. * Defines that engine should ignore modifying touch action attribute and style
  90037. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  90038. */
  90039. doNotHandleTouchAction?: boolean;
  90040. /**
  90041. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  90042. */
  90043. useHighPrecisionFloats?: boolean;
  90044. }
  90045. /**
  90046. * Defines the interface used by display changed events
  90047. */
  90048. export interface IDisplayChangedEventArgs {
  90049. /** Gets the vrDisplay object (if any) */
  90050. vrDisplay: Nullable<any>;
  90051. /** Gets a boolean indicating if webVR is supported */
  90052. vrSupported: boolean;
  90053. }
  90054. /**
  90055. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  90056. */
  90057. export class Engine {
  90058. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  90059. static ExceptionList: ({
  90060. key: string;
  90061. capture: string;
  90062. captureConstraint: number;
  90063. targets: string[];
  90064. } | {
  90065. key: string;
  90066. capture: null;
  90067. captureConstraint: null;
  90068. targets: string[];
  90069. })[];
  90070. /** Gets the list of created engines */
  90071. static readonly Instances: Engine[];
  90072. /**
  90073. * Gets the latest created engine
  90074. */
  90075. static readonly LastCreatedEngine: Nullable<Engine>;
  90076. /**
  90077. * Gets the latest created scene
  90078. */
  90079. static readonly LastCreatedScene: Nullable<Scene>;
  90080. /**
  90081. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  90082. * @param flag defines which part of the materials must be marked as dirty
  90083. * @param predicate defines a predicate used to filter which materials should be affected
  90084. */
  90085. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  90086. /** @hidden */
  90087. static _TextureLoaders: IInternalTextureLoader[];
  90088. /** Defines that alpha blending is disabled */
  90089. static readonly ALPHA_DISABLE: number;
  90090. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  90091. static readonly ALPHA_ADD: number;
  90092. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  90093. static readonly ALPHA_COMBINE: number;
  90094. /** Defines that alpha blending to DEST - SRC * DEST */
  90095. static readonly ALPHA_SUBTRACT: number;
  90096. /** Defines that alpha blending to SRC * DEST */
  90097. static readonly ALPHA_MULTIPLY: number;
  90098. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  90099. static readonly ALPHA_MAXIMIZED: number;
  90100. /** Defines that alpha blending to SRC + DEST */
  90101. static readonly ALPHA_ONEONE: number;
  90102. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  90103. static readonly ALPHA_PREMULTIPLIED: number;
  90104. /**
  90105. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  90106. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  90107. */
  90108. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  90109. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  90110. static readonly ALPHA_INTERPOLATE: number;
  90111. /**
  90112. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  90113. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  90114. */
  90115. static readonly ALPHA_SCREENMODE: number;
  90116. /** Defines that the ressource is not delayed*/
  90117. static readonly DELAYLOADSTATE_NONE: number;
  90118. /** Defines that the ressource was successfully delay loaded */
  90119. static readonly DELAYLOADSTATE_LOADED: number;
  90120. /** Defines that the ressource is currently delay loading */
  90121. static readonly DELAYLOADSTATE_LOADING: number;
  90122. /** Defines that the ressource is delayed and has not started loading */
  90123. static readonly DELAYLOADSTATE_NOTLOADED: number;
  90124. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  90125. static readonly NEVER: number;
  90126. /** 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 */
  90127. static readonly ALWAYS: number;
  90128. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  90129. static readonly LESS: number;
  90130. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  90131. static readonly EQUAL: number;
  90132. /** 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 */
  90133. static readonly LEQUAL: number;
  90134. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  90135. static readonly GREATER: number;
  90136. /** 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 */
  90137. static readonly GEQUAL: number;
  90138. /** 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 */
  90139. static readonly NOTEQUAL: number;
  90140. /** Passed to stencilOperation to specify that stencil value must be kept */
  90141. static readonly KEEP: number;
  90142. /** Passed to stencilOperation to specify that stencil value must be replaced */
  90143. static readonly REPLACE: number;
  90144. /** Passed to stencilOperation to specify that stencil value must be incremented */
  90145. static readonly INCR: number;
  90146. /** Passed to stencilOperation to specify that stencil value must be decremented */
  90147. static readonly DECR: number;
  90148. /** Passed to stencilOperation to specify that stencil value must be inverted */
  90149. static readonly INVERT: number;
  90150. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  90151. static readonly INCR_WRAP: number;
  90152. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  90153. static readonly DECR_WRAP: number;
  90154. /** Texture is not repeating outside of 0..1 UVs */
  90155. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  90156. /** Texture is repeating outside of 0..1 UVs */
  90157. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  90158. /** Texture is repeating and mirrored */
  90159. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  90160. /** ALPHA */
  90161. static readonly TEXTUREFORMAT_ALPHA: number;
  90162. /** LUMINANCE */
  90163. static readonly TEXTUREFORMAT_LUMINANCE: number;
  90164. /** LUMINANCE_ALPHA */
  90165. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  90166. /** RGB */
  90167. static readonly TEXTUREFORMAT_RGB: number;
  90168. /** RGBA */
  90169. static readonly TEXTUREFORMAT_RGBA: number;
  90170. /** RED */
  90171. static readonly TEXTUREFORMAT_RED: number;
  90172. /** RED (2nd reference) */
  90173. static readonly TEXTUREFORMAT_R: number;
  90174. /** RG */
  90175. static readonly TEXTUREFORMAT_RG: number;
  90176. /** RED_INTEGER */
  90177. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  90178. /** RED_INTEGER (2nd reference) */
  90179. static readonly TEXTUREFORMAT_R_INTEGER: number;
  90180. /** RG_INTEGER */
  90181. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  90182. /** RGB_INTEGER */
  90183. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  90184. /** RGBA_INTEGER */
  90185. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  90186. /** UNSIGNED_BYTE */
  90187. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  90188. /** UNSIGNED_BYTE (2nd reference) */
  90189. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  90190. /** FLOAT */
  90191. static readonly TEXTURETYPE_FLOAT: number;
  90192. /** HALF_FLOAT */
  90193. static readonly TEXTURETYPE_HALF_FLOAT: number;
  90194. /** BYTE */
  90195. static readonly TEXTURETYPE_BYTE: number;
  90196. /** SHORT */
  90197. static readonly TEXTURETYPE_SHORT: number;
  90198. /** UNSIGNED_SHORT */
  90199. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  90200. /** INT */
  90201. static readonly TEXTURETYPE_INT: number;
  90202. /** UNSIGNED_INT */
  90203. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  90204. /** UNSIGNED_SHORT_4_4_4_4 */
  90205. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  90206. /** UNSIGNED_SHORT_5_5_5_1 */
  90207. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  90208. /** UNSIGNED_SHORT_5_6_5 */
  90209. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  90210. /** UNSIGNED_INT_2_10_10_10_REV */
  90211. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  90212. /** UNSIGNED_INT_24_8 */
  90213. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  90214. /** UNSIGNED_INT_10F_11F_11F_REV */
  90215. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  90216. /** UNSIGNED_INT_5_9_9_9_REV */
  90217. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  90218. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  90219. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  90220. /** nearest is mag = nearest and min = nearest and mip = linear */
  90221. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  90222. /** Bilinear is mag = linear and min = linear and mip = nearest */
  90223. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  90224. /** Trilinear is mag = linear and min = linear and mip = linear */
  90225. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  90226. /** nearest is mag = nearest and min = nearest and mip = linear */
  90227. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  90228. /** Bilinear is mag = linear and min = linear and mip = nearest */
  90229. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  90230. /** Trilinear is mag = linear and min = linear and mip = linear */
  90231. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  90232. /** mag = nearest and min = nearest and mip = nearest */
  90233. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  90234. /** mag = nearest and min = linear and mip = nearest */
  90235. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  90236. /** mag = nearest and min = linear and mip = linear */
  90237. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  90238. /** mag = nearest and min = linear and mip = none */
  90239. static readonly TEXTURE_NEAREST_LINEAR: number;
  90240. /** mag = nearest and min = nearest and mip = none */
  90241. static readonly TEXTURE_NEAREST_NEAREST: number;
  90242. /** mag = linear and min = nearest and mip = nearest */
  90243. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  90244. /** mag = linear and min = nearest and mip = linear */
  90245. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  90246. /** mag = linear and min = linear and mip = none */
  90247. static readonly TEXTURE_LINEAR_LINEAR: number;
  90248. /** mag = linear and min = nearest and mip = none */
  90249. static readonly TEXTURE_LINEAR_NEAREST: number;
  90250. /** Explicit coordinates mode */
  90251. static readonly TEXTURE_EXPLICIT_MODE: number;
  90252. /** Spherical coordinates mode */
  90253. static readonly TEXTURE_SPHERICAL_MODE: number;
  90254. /** Planar coordinates mode */
  90255. static readonly TEXTURE_PLANAR_MODE: number;
  90256. /** Cubic coordinates mode */
  90257. static readonly TEXTURE_CUBIC_MODE: number;
  90258. /** Projection coordinates mode */
  90259. static readonly TEXTURE_PROJECTION_MODE: number;
  90260. /** Skybox coordinates mode */
  90261. static readonly TEXTURE_SKYBOX_MODE: number;
  90262. /** Inverse Cubic coordinates mode */
  90263. static readonly TEXTURE_INVCUBIC_MODE: number;
  90264. /** Equirectangular coordinates mode */
  90265. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  90266. /** Equirectangular Fixed coordinates mode */
  90267. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  90268. /** Equirectangular Fixed Mirrored coordinates mode */
  90269. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  90270. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  90271. static readonly SCALEMODE_FLOOR: number;
  90272. /** Defines that texture rescaling will look for the nearest power of 2 size */
  90273. static readonly SCALEMODE_NEAREST: number;
  90274. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  90275. static readonly SCALEMODE_CEILING: number;
  90276. /**
  90277. * Returns the current npm package of the sdk
  90278. */
  90279. static readonly NpmPackage: string;
  90280. /**
  90281. * Returns the current version of the framework
  90282. */
  90283. static readonly Version: string;
  90284. /**
  90285. * Returns a string describing the current engine
  90286. */
  90287. readonly description: string;
  90288. /**
  90289. * Gets or sets the epsilon value used by collision engine
  90290. */
  90291. static CollisionsEpsilon: number;
  90292. /**
  90293. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  90294. */
  90295. static ShadersRepository: string;
  90296. /**
  90297. * Method called to create the default loading screen.
  90298. * This can be overriden in your own app.
  90299. * @param canvas The rendering canvas element
  90300. * @returns The loading screen
  90301. */
  90302. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  90303. /**
  90304. * Method called to create the default rescale post process on each engine.
  90305. */
  90306. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  90307. /** @hidden */
  90308. _shaderProcessor: IShaderProcessor;
  90309. /**
  90310. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  90311. */
  90312. forcePOTTextures: boolean;
  90313. /**
  90314. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  90315. */
  90316. isFullscreen: boolean;
  90317. /**
  90318. * Gets a boolean indicating if the pointer is currently locked
  90319. */
  90320. isPointerLock: boolean;
  90321. /**
  90322. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  90323. */
  90324. cullBackFaces: boolean;
  90325. /**
  90326. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  90327. */
  90328. renderEvenInBackground: boolean;
  90329. /**
  90330. * Gets or sets a boolean indicating that cache can be kept between frames
  90331. */
  90332. preventCacheWipeBetweenFrames: boolean;
  90333. /**
  90334. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  90335. **/
  90336. enableOfflineSupport: boolean;
  90337. /**
  90338. * 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)
  90339. **/
  90340. disableManifestCheck: boolean;
  90341. /**
  90342. * Gets the list of created scenes
  90343. */
  90344. scenes: Scene[];
  90345. /**
  90346. * Event raised when a new scene is created
  90347. */
  90348. onNewSceneAddedObservable: Observable<Scene>;
  90349. /**
  90350. * Gets the list of created postprocesses
  90351. */
  90352. postProcesses: PostProcess[];
  90353. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  90354. validateShaderPrograms: boolean;
  90355. /**
  90356. * Observable event triggered each time the rendering canvas is resized
  90357. */
  90358. onResizeObservable: Observable<Engine>;
  90359. /**
  90360. * Observable event triggered each time the canvas loses focus
  90361. */
  90362. onCanvasBlurObservable: Observable<Engine>;
  90363. /**
  90364. * Observable event triggered each time the canvas gains focus
  90365. */
  90366. onCanvasFocusObservable: Observable<Engine>;
  90367. /**
  90368. * Observable event triggered each time the canvas receives pointerout event
  90369. */
  90370. onCanvasPointerOutObservable: Observable<PointerEvent>;
  90371. /**
  90372. * Observable event triggered before each texture is initialized
  90373. */
  90374. onBeforeTextureInitObservable: Observable<Texture>;
  90375. /**
  90376. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  90377. */
  90378. disableUniformBuffers: boolean;
  90379. /** @hidden */
  90380. _uniformBuffers: UniformBuffer[];
  90381. /**
  90382. * Gets a boolean indicating that the engine supports uniform buffers
  90383. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90384. */
  90385. readonly supportsUniformBuffers: boolean;
  90386. /**
  90387. * Observable raised when the engine begins a new frame
  90388. */
  90389. onBeginFrameObservable: Observable<Engine>;
  90390. /**
  90391. * If set, will be used to request the next animation frame for the render loop
  90392. */
  90393. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  90394. /**
  90395. * Observable raised when the engine ends the current frame
  90396. */
  90397. onEndFrameObservable: Observable<Engine>;
  90398. /**
  90399. * Observable raised when the engine is about to compile a shader
  90400. */
  90401. onBeforeShaderCompilationObservable: Observable<Engine>;
  90402. /**
  90403. * Observable raised when the engine has jsut compiled a shader
  90404. */
  90405. onAfterShaderCompilationObservable: Observable<Engine>;
  90406. /** @hidden */
  90407. _gl: WebGLRenderingContext;
  90408. private _renderingCanvas;
  90409. private _windowIsBackground;
  90410. private _webGLVersion;
  90411. protected _highPrecisionShadersAllowed: boolean;
  90412. /** @hidden */
  90413. readonly _shouldUseHighPrecisionShader: boolean;
  90414. /**
  90415. * Gets a boolean indicating that only power of 2 textures are supported
  90416. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  90417. */
  90418. readonly needPOTTextures: boolean;
  90419. /** @hidden */
  90420. _badOS: boolean;
  90421. /** @hidden */
  90422. _badDesktopOS: boolean;
  90423. /**
  90424. * Gets the audio engine
  90425. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  90426. * @ignorenaming
  90427. */
  90428. static audioEngine: IAudioEngine;
  90429. /**
  90430. * Default AudioEngine factory responsible of creating the Audio Engine.
  90431. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  90432. */
  90433. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  90434. /**
  90435. * Default offline support factory responsible of creating a tool used to store data locally.
  90436. * By default, this will create a Database object if the workload has been embedded.
  90437. */
  90438. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  90439. private _onFocus;
  90440. private _onBlur;
  90441. private _onCanvasPointerOut;
  90442. private _onCanvasBlur;
  90443. private _onCanvasFocus;
  90444. private _onFullscreenChange;
  90445. private _onPointerLockChange;
  90446. private _hardwareScalingLevel;
  90447. /** @hidden */
  90448. _caps: EngineCapabilities;
  90449. private _pointerLockRequested;
  90450. private _isStencilEnable;
  90451. private _colorWrite;
  90452. private _loadingScreen;
  90453. /** @hidden */
  90454. _drawCalls: PerfCounter;
  90455. private _glVersion;
  90456. private _glRenderer;
  90457. private _glVendor;
  90458. private _videoTextureSupported;
  90459. private _renderingQueueLaunched;
  90460. private _activeRenderLoops;
  90461. private _deterministicLockstep;
  90462. private _lockstepMaxSteps;
  90463. /**
  90464. * Observable signaled when a context lost event is raised
  90465. */
  90466. onContextLostObservable: Observable<Engine>;
  90467. /**
  90468. * Observable signaled when a context restored event is raised
  90469. */
  90470. onContextRestoredObservable: Observable<Engine>;
  90471. private _onContextLost;
  90472. private _onContextRestored;
  90473. private _contextWasLost;
  90474. /** @hidden */
  90475. _doNotHandleContextLost: boolean;
  90476. /**
  90477. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  90478. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  90479. */
  90480. doNotHandleContextLost: boolean;
  90481. private _performanceMonitor;
  90482. private _fps;
  90483. private _deltaTime;
  90484. /**
  90485. * Turn this value on if you want to pause FPS computation when in background
  90486. */
  90487. disablePerformanceMonitorInBackground: boolean;
  90488. /**
  90489. * Gets the performance monitor attached to this engine
  90490. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  90491. */
  90492. readonly performanceMonitor: PerformanceMonitor;
  90493. /**
  90494. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  90495. */
  90496. disableVertexArrayObjects: boolean;
  90497. /** @hidden */
  90498. protected _depthCullingState: _DepthCullingState;
  90499. /** @hidden */
  90500. protected _stencilState: _StencilState;
  90501. /** @hidden */
  90502. protected _alphaState: _AlphaState;
  90503. /** @hidden */
  90504. protected _alphaMode: number;
  90505. /** @hidden */
  90506. _internalTexturesCache: InternalTexture[];
  90507. /** @hidden */
  90508. protected _activeChannel: number;
  90509. private _currentTextureChannel;
  90510. /** @hidden */
  90511. protected _boundTexturesCache: {
  90512. [key: string]: Nullable<InternalTexture>;
  90513. };
  90514. /** @hidden */
  90515. protected _currentEffect: Nullable<Effect>;
  90516. /** @hidden */
  90517. protected _currentProgram: Nullable<WebGLProgram>;
  90518. private _compiledEffects;
  90519. private _vertexAttribArraysEnabled;
  90520. /** @hidden */
  90521. protected _cachedViewport: Nullable<Viewport>;
  90522. private _cachedVertexArrayObject;
  90523. /** @hidden */
  90524. protected _cachedVertexBuffers: any;
  90525. /** @hidden */
  90526. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  90527. /** @hidden */
  90528. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  90529. /** @hidden */
  90530. _currentRenderTarget: Nullable<InternalTexture>;
  90531. private _uintIndicesCurrentlySet;
  90532. private _currentBoundBuffer;
  90533. /** @hidden */
  90534. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  90535. private _currentBufferPointers;
  90536. private _currentInstanceLocations;
  90537. private _currentInstanceBuffers;
  90538. private _textureUnits;
  90539. /** @hidden */
  90540. _workingCanvas: Nullable<HTMLCanvasElement>;
  90541. /** @hidden */
  90542. _workingContext: Nullable<CanvasRenderingContext2D>;
  90543. private _rescalePostProcess;
  90544. private _dummyFramebuffer;
  90545. private _externalData;
  90546. /** @hidden */
  90547. _bindedRenderFunction: any;
  90548. private _vaoRecordInProgress;
  90549. private _mustWipeVertexAttributes;
  90550. private _emptyTexture;
  90551. private _emptyCubeTexture;
  90552. private _emptyTexture3D;
  90553. /** @hidden */
  90554. _frameHandler: number;
  90555. private _nextFreeTextureSlots;
  90556. private _maxSimultaneousTextures;
  90557. private _activeRequests;
  90558. private _texturesSupported;
  90559. /** @hidden */
  90560. _textureFormatInUse: Nullable<string>;
  90561. /**
  90562. * Gets the list of texture formats supported
  90563. */
  90564. readonly texturesSupported: Array<string>;
  90565. /**
  90566. * Gets the list of texture formats in use
  90567. */
  90568. readonly textureFormatInUse: Nullable<string>;
  90569. /**
  90570. * Gets the current viewport
  90571. */
  90572. readonly currentViewport: Nullable<Viewport>;
  90573. /**
  90574. * Gets the default empty texture
  90575. */
  90576. readonly emptyTexture: InternalTexture;
  90577. /**
  90578. * Gets the default empty 3D texture
  90579. */
  90580. readonly emptyTexture3D: InternalTexture;
  90581. /**
  90582. * Gets the default empty cube texture
  90583. */
  90584. readonly emptyCubeTexture: InternalTexture;
  90585. /**
  90586. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  90587. */
  90588. readonly premultipliedAlpha: boolean;
  90589. /**
  90590. * Creates a new engine
  90591. * @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
  90592. * @param antialias defines enable antialiasing (default: false)
  90593. * @param options defines further options to be sent to the getContext() function
  90594. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  90595. */
  90596. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  90597. /**
  90598. * Initializes a webVR display and starts listening to display change events
  90599. * The onVRDisplayChangedObservable will be notified upon these changes
  90600. * @returns The onVRDisplayChangedObservable
  90601. */
  90602. initWebVR(): Observable<IDisplayChangedEventArgs>;
  90603. /** @hidden */
  90604. _prepareVRComponent(): void;
  90605. /** @hidden */
  90606. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  90607. /** @hidden */
  90608. _submitVRFrame(): void;
  90609. /**
  90610. * Call this function to leave webVR mode
  90611. * Will do nothing if webVR is not supported or if there is no webVR device
  90612. * @see http://doc.babylonjs.com/how_to/webvr_camera
  90613. */
  90614. disableVR(): void;
  90615. /**
  90616. * Gets a boolean indicating that the system is in VR mode and is presenting
  90617. * @returns true if VR mode is engaged
  90618. */
  90619. isVRPresenting(): boolean;
  90620. /** @hidden */
  90621. _requestVRFrame(): void;
  90622. private _disableTouchAction;
  90623. private _rebuildInternalTextures;
  90624. private _rebuildEffects;
  90625. /**
  90626. * Gets a boolean indicating if all created effects are ready
  90627. * @returns true if all effects are ready
  90628. */
  90629. areAllEffectsReady(): boolean;
  90630. private _rebuildBuffers;
  90631. private _initGLContext;
  90632. /**
  90633. * Gets version of the current webGL context
  90634. */
  90635. readonly webGLVersion: number;
  90636. /**
  90637. * Gets a string idenfifying the name of the class
  90638. * @returns "Engine" string
  90639. */
  90640. getClassName(): string;
  90641. /**
  90642. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  90643. */
  90644. readonly isStencilEnable: boolean;
  90645. /** @hidden */
  90646. _prepareWorkingCanvas(): void;
  90647. /**
  90648. * Reset the texture cache to empty state
  90649. */
  90650. resetTextureCache(): void;
  90651. /**
  90652. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  90653. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90654. * @returns true if engine is in deterministic lock step mode
  90655. */
  90656. isDeterministicLockStep(): boolean;
  90657. /**
  90658. * Gets the max steps when engine is running in deterministic lock step
  90659. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  90660. * @returns the max steps
  90661. */
  90662. getLockstepMaxSteps(): number;
  90663. /**
  90664. * Gets an object containing information about the current webGL context
  90665. * @returns an object containing the vender, the renderer and the version of the current webGL context
  90666. */
  90667. getGlInfo(): {
  90668. vendor: string;
  90669. renderer: string;
  90670. version: string;
  90671. };
  90672. /**
  90673. * Gets current aspect ratio
  90674. * @param camera defines the camera to use to get the aspect ratio
  90675. * @param useScreen defines if screen size must be used (or the current render target if any)
  90676. * @returns a number defining the aspect ratio
  90677. */
  90678. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  90679. /**
  90680. * Gets current screen aspect ratio
  90681. * @returns a number defining the aspect ratio
  90682. */
  90683. getScreenAspectRatio(): number;
  90684. /**
  90685. * Gets the current render width
  90686. * @param useScreen defines if screen size must be used (or the current render target if any)
  90687. * @returns a number defining the current render width
  90688. */
  90689. getRenderWidth(useScreen?: boolean): number;
  90690. /**
  90691. * Gets the current render height
  90692. * @param useScreen defines if screen size must be used (or the current render target if any)
  90693. * @returns a number defining the current render height
  90694. */
  90695. getRenderHeight(useScreen?: boolean): number;
  90696. /**
  90697. * Gets the HTML canvas attached with the current webGL context
  90698. * @returns a HTML canvas
  90699. */
  90700. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  90701. /**
  90702. * Gets the client rect of the HTML canvas attached with the current webGL context
  90703. * @returns a client rectanglee
  90704. */
  90705. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  90706. /**
  90707. * Defines the hardware scaling level.
  90708. * By default the hardware scaling level is computed from the window device ratio.
  90709. * 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.
  90710. * @param level defines the level to use
  90711. */
  90712. setHardwareScalingLevel(level: number): void;
  90713. /**
  90714. * Gets the current hardware scaling level.
  90715. * By default the hardware scaling level is computed from the window device ratio.
  90716. * 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.
  90717. * @returns a number indicating the current hardware scaling level
  90718. */
  90719. getHardwareScalingLevel(): number;
  90720. /**
  90721. * Gets the list of loaded textures
  90722. * @returns an array containing all loaded textures
  90723. */
  90724. getLoadedTexturesCache(): InternalTexture[];
  90725. /**
  90726. * Gets the object containing all engine capabilities
  90727. * @returns the EngineCapabilities object
  90728. */
  90729. getCaps(): EngineCapabilities;
  90730. /**
  90731. * Gets the current depth function
  90732. * @returns a number defining the depth function
  90733. */
  90734. getDepthFunction(): Nullable<number>;
  90735. /**
  90736. * Sets the current depth function
  90737. * @param depthFunc defines the function to use
  90738. */
  90739. setDepthFunction(depthFunc: number): void;
  90740. /**
  90741. * Sets the current depth function to GREATER
  90742. */
  90743. setDepthFunctionToGreater(): void;
  90744. /**
  90745. * Sets the current depth function to GEQUAL
  90746. */
  90747. setDepthFunctionToGreaterOrEqual(): void;
  90748. /**
  90749. * Sets the current depth function to LESS
  90750. */
  90751. setDepthFunctionToLess(): void;
  90752. private _cachedStencilBuffer;
  90753. private _cachedStencilFunction;
  90754. private _cachedStencilMask;
  90755. private _cachedStencilOperationPass;
  90756. private _cachedStencilOperationFail;
  90757. private _cachedStencilOperationDepthFail;
  90758. private _cachedStencilReference;
  90759. /**
  90760. * Caches the the state of the stencil buffer
  90761. */
  90762. cacheStencilState(): void;
  90763. /**
  90764. * Restores the state of the stencil buffer
  90765. */
  90766. restoreStencilState(): void;
  90767. /**
  90768. * Sets the current depth function to LEQUAL
  90769. */
  90770. setDepthFunctionToLessOrEqual(): void;
  90771. /**
  90772. * Gets a boolean indicating if stencil buffer is enabled
  90773. * @returns the current stencil buffer state
  90774. */
  90775. getStencilBuffer(): boolean;
  90776. /**
  90777. * Enable or disable the stencil buffer
  90778. * @param enable defines if the stencil buffer must be enabled or disabled
  90779. */
  90780. setStencilBuffer(enable: boolean): void;
  90781. /**
  90782. * Gets the current stencil mask
  90783. * @returns a number defining the new stencil mask to use
  90784. */
  90785. getStencilMask(): number;
  90786. /**
  90787. * Sets the current stencil mask
  90788. * @param mask defines the new stencil mask to use
  90789. */
  90790. setStencilMask(mask: number): void;
  90791. /**
  90792. * Gets the current stencil function
  90793. * @returns a number defining the stencil function to use
  90794. */
  90795. getStencilFunction(): number;
  90796. /**
  90797. * Gets the current stencil reference value
  90798. * @returns a number defining the stencil reference value to use
  90799. */
  90800. getStencilFunctionReference(): number;
  90801. /**
  90802. * Gets the current stencil mask
  90803. * @returns a number defining the stencil mask to use
  90804. */
  90805. getStencilFunctionMask(): number;
  90806. /**
  90807. * Sets the current stencil function
  90808. * @param stencilFunc defines the new stencil function to use
  90809. */
  90810. setStencilFunction(stencilFunc: number): void;
  90811. /**
  90812. * Sets the current stencil reference
  90813. * @param reference defines the new stencil reference to use
  90814. */
  90815. setStencilFunctionReference(reference: number): void;
  90816. /**
  90817. * Sets the current stencil mask
  90818. * @param mask defines the new stencil mask to use
  90819. */
  90820. setStencilFunctionMask(mask: number): void;
  90821. /**
  90822. * Gets the current stencil operation when stencil fails
  90823. * @returns a number defining stencil operation to use when stencil fails
  90824. */
  90825. getStencilOperationFail(): number;
  90826. /**
  90827. * Gets the current stencil operation when depth fails
  90828. * @returns a number defining stencil operation to use when depth fails
  90829. */
  90830. getStencilOperationDepthFail(): number;
  90831. /**
  90832. * Gets the current stencil operation when stencil passes
  90833. * @returns a number defining stencil operation to use when stencil passes
  90834. */
  90835. getStencilOperationPass(): number;
  90836. /**
  90837. * Sets the stencil operation to use when stencil fails
  90838. * @param operation defines the stencil operation to use when stencil fails
  90839. */
  90840. setStencilOperationFail(operation: number): void;
  90841. /**
  90842. * Sets the stencil operation to use when depth fails
  90843. * @param operation defines the stencil operation to use when depth fails
  90844. */
  90845. setStencilOperationDepthFail(operation: number): void;
  90846. /**
  90847. * Sets the stencil operation to use when stencil passes
  90848. * @param operation defines the stencil operation to use when stencil passes
  90849. */
  90850. setStencilOperationPass(operation: number): void;
  90851. /**
  90852. * Sets a boolean indicating if the dithering state is enabled or disabled
  90853. * @param value defines the dithering state
  90854. */
  90855. setDitheringState(value: boolean): void;
  90856. /**
  90857. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  90858. * @param value defines the rasterizer state
  90859. */
  90860. setRasterizerState(value: boolean): void;
  90861. /**
  90862. * stop executing a render loop function and remove it from the execution array
  90863. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  90864. */
  90865. stopRenderLoop(renderFunction?: () => void): void;
  90866. /** @hidden */
  90867. _renderLoop(): void;
  90868. /**
  90869. * Register and execute a render loop. The engine can have more than one render function
  90870. * @param renderFunction defines the function to continuously execute
  90871. */
  90872. runRenderLoop(renderFunction: () => void): void;
  90873. /**
  90874. * Toggle full screen mode
  90875. * @param requestPointerLock defines if a pointer lock should be requested from the user
  90876. */
  90877. switchFullscreen(requestPointerLock: boolean): void;
  90878. /**
  90879. * Enters full screen mode
  90880. * @param requestPointerLock defines if a pointer lock should be requested from the user
  90881. */
  90882. enterFullscreen(requestPointerLock: boolean): void;
  90883. /**
  90884. * Exits full screen mode
  90885. */
  90886. exitFullscreen(): void;
  90887. /**
  90888. * Enters Pointerlock mode
  90889. */
  90890. enterPointerlock(): void;
  90891. /**
  90892. * Exits Pointerlock mode
  90893. */
  90894. exitPointerlock(): void;
  90895. /**
  90896. * Clear the current render buffer or the current render target (if any is set up)
  90897. * @param color defines the color to use
  90898. * @param backBuffer defines if the back buffer must be cleared
  90899. * @param depth defines if the depth buffer must be cleared
  90900. * @param stencil defines if the stencil buffer must be cleared
  90901. */
  90902. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  90903. /**
  90904. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  90905. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  90906. * @param y defines the y-coordinate of the corner of the clear rectangle
  90907. * @param width defines the width of the clear rectangle
  90908. * @param height defines the height of the clear rectangle
  90909. * @param clearColor defines the clear color
  90910. */
  90911. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  90912. /**
  90913. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  90914. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  90915. * @param y defines the y-coordinate of the corner of the clear rectangle
  90916. * @param width defines the width of the clear rectangle
  90917. * @param height defines the height of the clear rectangle
  90918. */
  90919. enableScissor(x: number, y: number, width: number, height: number): void;
  90920. /**
  90921. * Disable previously set scissor test rectangle
  90922. */
  90923. disableScissor(): void;
  90924. private _viewportCached;
  90925. /** @hidden */
  90926. _viewport(x: number, y: number, width: number, height: number): void;
  90927. /**
  90928. * Set the WebGL's viewport
  90929. * @param viewport defines the viewport element to be used
  90930. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  90931. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  90932. */
  90933. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  90934. /**
  90935. * Directly set the WebGL Viewport
  90936. * @param x defines the x coordinate of the viewport (in screen space)
  90937. * @param y defines the y coordinate of the viewport (in screen space)
  90938. * @param width defines the width of the viewport (in screen space)
  90939. * @param height defines the height of the viewport (in screen space)
  90940. * @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
  90941. */
  90942. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  90943. /**
  90944. * Begin a new frame
  90945. */
  90946. beginFrame(): void;
  90947. /**
  90948. * Enf the current frame
  90949. */
  90950. endFrame(): void;
  90951. /**
  90952. * Resize the view according to the canvas' size
  90953. */
  90954. resize(): void;
  90955. /**
  90956. * Force a specific size of the canvas
  90957. * @param width defines the new canvas' width
  90958. * @param height defines the new canvas' height
  90959. */
  90960. setSize(width: number, height: number): void;
  90961. /**
  90962. * Binds the frame buffer to the specified texture.
  90963. * @param texture The texture to render to or null for the default canvas
  90964. * @param faceIndex The face of the texture to render to in case of cube texture
  90965. * @param requiredWidth The width of the target to render to
  90966. * @param requiredHeight The height of the target to render to
  90967. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  90968. * @param depthStencilTexture The depth stencil texture to use to render
  90969. * @param lodLevel defines le lod level to bind to the frame buffer
  90970. */
  90971. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  90972. /** @hidden */
  90973. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  90974. /**
  90975. * Unbind the current render target texture from the webGL context
  90976. * @param texture defines the render target texture to unbind
  90977. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  90978. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  90979. */
  90980. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  90981. /**
  90982. * Force the mipmap generation for the given render target texture
  90983. * @param texture defines the render target texture to use
  90984. */
  90985. generateMipMapsForCubemap(texture: InternalTexture): void;
  90986. /**
  90987. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  90988. */
  90989. flushFramebuffer(): void;
  90990. /**
  90991. * Unbind the current render target and bind the default framebuffer
  90992. */
  90993. restoreDefaultFramebuffer(): void;
  90994. /**
  90995. * Create an uniform buffer
  90996. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90997. * @param elements defines the content of the uniform buffer
  90998. * @returns the webGL uniform buffer
  90999. */
  91000. createUniformBuffer(elements: FloatArray): DataBuffer;
  91001. /**
  91002. * Create a dynamic uniform buffer
  91003. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  91004. * @param elements defines the content of the uniform buffer
  91005. * @returns the webGL uniform buffer
  91006. */
  91007. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  91008. /**
  91009. * Update an existing uniform buffer
  91010. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  91011. * @param uniformBuffer defines the target uniform buffer
  91012. * @param elements defines the content to update
  91013. * @param offset defines the offset in the uniform buffer where update should start
  91014. * @param count defines the size of the data to update
  91015. */
  91016. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  91017. private _resetVertexBufferBinding;
  91018. /**
  91019. * Creates a vertex buffer
  91020. * @param data the data for the vertex buffer
  91021. * @returns the new WebGL static buffer
  91022. */
  91023. createVertexBuffer(data: DataArray): DataBuffer;
  91024. /**
  91025. * Creates a dynamic vertex buffer
  91026. * @param data the data for the dynamic vertex buffer
  91027. * @returns the new WebGL dynamic buffer
  91028. */
  91029. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  91030. /**
  91031. * Update a dynamic index buffer
  91032. * @param indexBuffer defines the target index buffer
  91033. * @param indices defines the data to update
  91034. * @param offset defines the offset in the target index buffer where update should start
  91035. */
  91036. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  91037. /**
  91038. * Updates a dynamic vertex buffer.
  91039. * @param vertexBuffer the vertex buffer to update
  91040. * @param data the data used to update the vertex buffer
  91041. * @param byteOffset the byte offset of the data
  91042. * @param byteLength the byte length of the data
  91043. */
  91044. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  91045. private _resetIndexBufferBinding;
  91046. /**
  91047. * Creates a new index buffer
  91048. * @param indices defines the content of the index buffer
  91049. * @param updatable defines if the index buffer must be updatable
  91050. * @returns a new webGL buffer
  91051. */
  91052. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  91053. /**
  91054. * Bind a webGL buffer to the webGL context
  91055. * @param buffer defines the buffer to bind
  91056. */
  91057. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  91058. /**
  91059. * Bind an uniform buffer to the current webGL context
  91060. * @param buffer defines the buffer to bind
  91061. */
  91062. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  91063. /**
  91064. * Bind a buffer to the current webGL context at a given location
  91065. * @param buffer defines the buffer to bind
  91066. * @param location defines the index where to bind the buffer
  91067. */
  91068. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  91069. /**
  91070. * Bind a specific block at a given index in a specific shader program
  91071. * @param pipelineContext defines the pipeline context to use
  91072. * @param blockName defines the block name
  91073. * @param index defines the index where to bind the block
  91074. */
  91075. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  91076. private bindIndexBuffer;
  91077. private bindBuffer;
  91078. /**
  91079. * update the bound buffer with the given data
  91080. * @param data defines the data to update
  91081. */
  91082. updateArrayBuffer(data: Float32Array): void;
  91083. private _vertexAttribPointer;
  91084. private _bindIndexBufferWithCache;
  91085. private _bindVertexBuffersAttributes;
  91086. /**
  91087. * Records a vertex array object
  91088. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  91089. * @param vertexBuffers defines the list of vertex buffers to store
  91090. * @param indexBuffer defines the index buffer to store
  91091. * @param effect defines the effect to store
  91092. * @returns the new vertex array object
  91093. */
  91094. recordVertexArrayObject(vertexBuffers: {
  91095. [key: string]: VertexBuffer;
  91096. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  91097. /**
  91098. * Bind a specific vertex array object
  91099. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  91100. * @param vertexArrayObject defines the vertex array object to bind
  91101. * @param indexBuffer defines the index buffer to bind
  91102. */
  91103. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  91104. /**
  91105. * Bind webGl buffers directly to the webGL context
  91106. * @param vertexBuffer defines the vertex buffer to bind
  91107. * @param indexBuffer defines the index buffer to bind
  91108. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  91109. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  91110. * @param effect defines the effect associated with the vertex buffer
  91111. */
  91112. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  91113. private _unbindVertexArrayObject;
  91114. /**
  91115. * Bind a list of vertex buffers to the webGL context
  91116. * @param vertexBuffers defines the list of vertex buffers to bind
  91117. * @param indexBuffer defines the index buffer to bind
  91118. * @param effect defines the effect associated with the vertex buffers
  91119. */
  91120. bindBuffers(vertexBuffers: {
  91121. [key: string]: Nullable<VertexBuffer>;
  91122. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  91123. /**
  91124. * Unbind all instance attributes
  91125. */
  91126. unbindInstanceAttributes(): void;
  91127. /**
  91128. * Release and free the memory of a vertex array object
  91129. * @param vao defines the vertex array object to delete
  91130. */
  91131. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  91132. /** @hidden */
  91133. _releaseBuffer(buffer: DataBuffer): boolean;
  91134. /**
  91135. * Creates a webGL buffer to use with instanciation
  91136. * @param capacity defines the size of the buffer
  91137. * @returns the webGL buffer
  91138. */
  91139. createInstancesBuffer(capacity: number): DataBuffer;
  91140. /**
  91141. * Delete a webGL buffer used with instanciation
  91142. * @param buffer defines the webGL buffer to delete
  91143. */
  91144. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  91145. /**
  91146. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  91147. * @param instancesBuffer defines the webGL buffer to update and bind
  91148. * @param data defines the data to store in the buffer
  91149. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  91150. */
  91151. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  91152. /**
  91153. * Apply all cached states (depth, culling, stencil and alpha)
  91154. */
  91155. applyStates(): void;
  91156. /**
  91157. * Send a draw order
  91158. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  91159. * @param indexStart defines the starting index
  91160. * @param indexCount defines the number of index to draw
  91161. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91162. */
  91163. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  91164. /**
  91165. * Draw a list of points
  91166. * @param verticesStart defines the index of first vertex to draw
  91167. * @param verticesCount defines the count of vertices to draw
  91168. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91169. */
  91170. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91171. /**
  91172. * Draw a list of unindexed primitives
  91173. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  91174. * @param verticesStart defines the index of first vertex to draw
  91175. * @param verticesCount defines the count of vertices to draw
  91176. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91177. */
  91178. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91179. /**
  91180. * Draw a list of indexed primitives
  91181. * @param fillMode defines the primitive to use
  91182. * @param indexStart defines the starting index
  91183. * @param indexCount defines the number of index to draw
  91184. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91185. */
  91186. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  91187. /**
  91188. * Draw a list of unindexed primitives
  91189. * @param fillMode defines the primitive to use
  91190. * @param verticesStart defines the index of first vertex to draw
  91191. * @param verticesCount defines the count of vertices to draw
  91192. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  91193. */
  91194. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  91195. private _drawMode;
  91196. /** @hidden */
  91197. _releaseEffect(effect: Effect): void;
  91198. /** @hidden */
  91199. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  91200. /**
  91201. * Create a new effect (used to store vertex/fragment shaders)
  91202. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  91203. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  91204. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  91205. * @param samplers defines an array of string used to represent textures
  91206. * @param defines defines the string containing the defines to use to compile the shaders
  91207. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  91208. * @param onCompiled defines a function to call when the effect creation is successful
  91209. * @param onError defines a function to call when the effect creation has failed
  91210. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  91211. * @returns the new Effect
  91212. */
  91213. 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;
  91214. private _compileShader;
  91215. private _compileRawShader;
  91216. /**
  91217. * Directly creates a webGL program
  91218. * @param pipelineContext defines the pipeline context to attach to
  91219. * @param vertexCode defines the vertex shader code to use
  91220. * @param fragmentCode defines the fragment shader code to use
  91221. * @param context defines the webGL context to use (if not set, the current one will be used)
  91222. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  91223. * @returns the new webGL program
  91224. */
  91225. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  91226. /**
  91227. * Creates a webGL program
  91228. * @param pipelineContext defines the pipeline context to attach to
  91229. * @param vertexCode defines the vertex shader code to use
  91230. * @param fragmentCode defines the fragment shader code to use
  91231. * @param defines defines the string containing the defines to use to compile the shaders
  91232. * @param context defines the webGL context to use (if not set, the current one will be used)
  91233. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  91234. * @returns the new webGL program
  91235. */
  91236. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  91237. /**
  91238. * Creates a new pipeline context
  91239. * @returns the new pipeline
  91240. */
  91241. createPipelineContext(): WebGLPipelineContext;
  91242. private _createShaderProgram;
  91243. private _finalizePipelineContext;
  91244. /** @hidden */
  91245. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  91246. /** @hidden */
  91247. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  91248. /** @hidden */
  91249. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  91250. /**
  91251. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  91252. * @param pipelineContext defines the pipeline context to use
  91253. * @param uniformsNames defines the list of uniform names
  91254. * @returns an array of webGL uniform locations
  91255. */
  91256. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  91257. /**
  91258. * Gets the lsit of active attributes for a given webGL program
  91259. * @param pipelineContext defines the pipeline context to use
  91260. * @param attributesNames defines the list of attribute names to get
  91261. * @returns an array of indices indicating the offset of each attribute
  91262. */
  91263. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  91264. /**
  91265. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  91266. * @param effect defines the effect to activate
  91267. */
  91268. enableEffect(effect: Nullable<Effect>): void;
  91269. /**
  91270. * Set the value of an uniform to an array of int32
  91271. * @param uniform defines the webGL uniform location where to store the value
  91272. * @param array defines the array of int32 to store
  91273. */
  91274. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91275. /**
  91276. * Set the value of an uniform to an array of int32 (stored as vec2)
  91277. * @param uniform defines the webGL uniform location where to store the value
  91278. * @param array defines the array of int32 to store
  91279. */
  91280. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91281. /**
  91282. * Set the value of an uniform to an array of int32 (stored as vec3)
  91283. * @param uniform defines the webGL uniform location where to store the value
  91284. * @param array defines the array of int32 to store
  91285. */
  91286. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91287. /**
  91288. * Set the value of an uniform to an array of int32 (stored as vec4)
  91289. * @param uniform defines the webGL uniform location where to store the value
  91290. * @param array defines the array of int32 to store
  91291. */
  91292. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  91293. /**
  91294. * Set the value of an uniform to an array of float32
  91295. * @param uniform defines the webGL uniform location where to store the value
  91296. * @param array defines the array of float32 to store
  91297. */
  91298. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91299. /**
  91300. * Set the value of an uniform to an array of float32 (stored as vec2)
  91301. * @param uniform defines the webGL uniform location where to store the value
  91302. * @param array defines the array of float32 to store
  91303. */
  91304. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91305. /**
  91306. * Set the value of an uniform to an array of float32 (stored as vec3)
  91307. * @param uniform defines the webGL uniform location where to store the value
  91308. * @param array defines the array of float32 to store
  91309. */
  91310. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91311. /**
  91312. * Set the value of an uniform to an array of float32 (stored as vec4)
  91313. * @param uniform defines the webGL uniform location where to store the value
  91314. * @param array defines the array of float32 to store
  91315. */
  91316. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  91317. /**
  91318. * Set the value of an uniform to an array of number
  91319. * @param uniform defines the webGL uniform location where to store the value
  91320. * @param array defines the array of number to store
  91321. */
  91322. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91323. /**
  91324. * Set the value of an uniform to an array of number (stored as vec2)
  91325. * @param uniform defines the webGL uniform location where to store the value
  91326. * @param array defines the array of number to store
  91327. */
  91328. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91329. /**
  91330. * Set the value of an uniform to an array of number (stored as vec3)
  91331. * @param uniform defines the webGL uniform location where to store the value
  91332. * @param array defines the array of number to store
  91333. */
  91334. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91335. /**
  91336. * Set the value of an uniform to an array of number (stored as vec4)
  91337. * @param uniform defines the webGL uniform location where to store the value
  91338. * @param array defines the array of number to store
  91339. */
  91340. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  91341. /**
  91342. * Set the value of an uniform to an array of float32 (stored as matrices)
  91343. * @param uniform defines the webGL uniform location where to store the value
  91344. * @param matrices defines the array of float32 to store
  91345. */
  91346. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  91347. /**
  91348. * Set the value of an uniform to a matrix
  91349. * @param uniform defines the webGL uniform location where to store the value
  91350. * @param matrix defines the matrix to store
  91351. */
  91352. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  91353. /**
  91354. * Set the value of an uniform to a matrix (3x3)
  91355. * @param uniform defines the webGL uniform location where to store the value
  91356. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  91357. */
  91358. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  91359. /**
  91360. * Set the value of an uniform to a matrix (2x2)
  91361. * @param uniform defines the webGL uniform location where to store the value
  91362. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  91363. */
  91364. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  91365. /**
  91366. * Set the value of an uniform to a number (int)
  91367. * @param uniform defines the webGL uniform location where to store the value
  91368. * @param value defines the int number to store
  91369. */
  91370. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  91371. /**
  91372. * Set the value of an uniform to a number (float)
  91373. * @param uniform defines the webGL uniform location where to store the value
  91374. * @param value defines the float number to store
  91375. */
  91376. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  91377. /**
  91378. * Set the value of an uniform to a vec2
  91379. * @param uniform defines the webGL uniform location where to store the value
  91380. * @param x defines the 1st component of the value
  91381. * @param y defines the 2nd component of the value
  91382. */
  91383. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  91384. /**
  91385. * Set the value of an uniform to a vec3
  91386. * @param uniform defines the webGL uniform location where to store the value
  91387. * @param x defines the 1st component of the value
  91388. * @param y defines the 2nd component of the value
  91389. * @param z defines the 3rd component of the value
  91390. */
  91391. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  91392. /**
  91393. * Set the value of an uniform to a boolean
  91394. * @param uniform defines the webGL uniform location where to store the value
  91395. * @param bool defines the boolean to store
  91396. */
  91397. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  91398. /**
  91399. * Set the value of an uniform to a vec4
  91400. * @param uniform defines the webGL uniform location where to store the value
  91401. * @param x defines the 1st component of the value
  91402. * @param y defines the 2nd component of the value
  91403. * @param z defines the 3rd component of the value
  91404. * @param w defines the 4th component of the value
  91405. */
  91406. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  91407. /**
  91408. * Set the value of an uniform to a Color3
  91409. * @param uniform defines the webGL uniform location where to store the value
  91410. * @param color3 defines the color to store
  91411. */
  91412. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  91413. /**
  91414. * Set the value of an uniform to a Color3 and an alpha value
  91415. * @param uniform defines the webGL uniform location where to store the value
  91416. * @param color3 defines the color to store
  91417. * @param alpha defines the alpha component to store
  91418. */
  91419. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  91420. /**
  91421. * Sets a Color4 on a uniform variable
  91422. * @param uniform defines the uniform location
  91423. * @param color4 defines the value to be set
  91424. */
  91425. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  91426. /**
  91427. * Set various states to the webGL context
  91428. * @param culling defines backface culling state
  91429. * @param zOffset defines the value to apply to zOffset (0 by default)
  91430. * @param force defines if states must be applied even if cache is up to date
  91431. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  91432. */
  91433. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  91434. /**
  91435. * Set the z offset to apply to current rendering
  91436. * @param value defines the offset to apply
  91437. */
  91438. setZOffset(value: number): void;
  91439. /**
  91440. * Gets the current value of the zOffset
  91441. * @returns the current zOffset state
  91442. */
  91443. getZOffset(): number;
  91444. /**
  91445. * Enable or disable depth buffering
  91446. * @param enable defines the state to set
  91447. */
  91448. setDepthBuffer(enable: boolean): void;
  91449. /**
  91450. * Gets a boolean indicating if depth writing is enabled
  91451. * @returns the current depth writing state
  91452. */
  91453. getDepthWrite(): boolean;
  91454. /**
  91455. * Enable or disable depth writing
  91456. * @param enable defines the state to set
  91457. */
  91458. setDepthWrite(enable: boolean): void;
  91459. /**
  91460. * Enable or disable color writing
  91461. * @param enable defines the state to set
  91462. */
  91463. setColorWrite(enable: boolean): void;
  91464. /**
  91465. * Gets a boolean indicating if color writing is enabled
  91466. * @returns the current color writing state
  91467. */
  91468. getColorWrite(): boolean;
  91469. /**
  91470. * Sets alpha constants used by some alpha blending modes
  91471. * @param r defines the red component
  91472. * @param g defines the green component
  91473. * @param b defines the blue component
  91474. * @param a defines the alpha component
  91475. */
  91476. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  91477. /**
  91478. * Sets the current alpha mode
  91479. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  91480. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  91481. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  91482. */
  91483. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  91484. /**
  91485. * Gets the current alpha mode
  91486. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  91487. * @returns the current alpha mode
  91488. */
  91489. getAlphaMode(): number;
  91490. /**
  91491. * Clears the list of texture accessible through engine.
  91492. * This can help preventing texture load conflict due to name collision.
  91493. */
  91494. clearInternalTexturesCache(): void;
  91495. /**
  91496. * Force the entire cache to be cleared
  91497. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  91498. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  91499. */
  91500. wipeCaches(bruteForce?: boolean): void;
  91501. /**
  91502. * Set the compressed texture format to use, based on the formats you have, and the formats
  91503. * supported by the hardware / browser.
  91504. *
  91505. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  91506. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  91507. * to API arguments needed to compressed textures. This puts the burden on the container
  91508. * generator to house the arcane code for determining these for current & future formats.
  91509. *
  91510. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  91511. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  91512. *
  91513. * Note: The result of this call is not taken into account when a texture is base64.
  91514. *
  91515. * @param formatsAvailable defines the list of those format families you have created
  91516. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  91517. *
  91518. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  91519. * @returns The extension selected.
  91520. */
  91521. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  91522. /** @hidden */
  91523. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  91524. min: number;
  91525. mag: number;
  91526. };
  91527. /** @hidden */
  91528. _createTexture(): WebGLTexture;
  91529. /**
  91530. * Usually called from Texture.ts.
  91531. * Passed information to create a WebGLTexture
  91532. * @param urlArg defines a value which contains one of the following:
  91533. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  91534. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  91535. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  91536. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  91537. * @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)
  91538. * @param scene needed for loading to the correct scene
  91539. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  91540. * @param onLoad optional callback to be called upon successful completion
  91541. * @param onError optional callback to be called upon failure
  91542. * @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
  91543. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  91544. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  91545. * @param forcedExtension defines the extension to use to pick the right loader
  91546. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  91547. * @returns a InternalTexture for assignment back into BABYLON.Texture
  91548. */
  91549. 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;
  91550. /**
  91551. * @hidden
  91552. * Rescales a texture
  91553. * @param source input texutre
  91554. * @param destination destination texture
  91555. * @param scene scene to use to render the resize
  91556. * @param internalFormat format to use when resizing
  91557. * @param onComplete callback to be called when resize has completed
  91558. */
  91559. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  91560. private _unpackFlipYCached;
  91561. /**
  91562. * In case you are sharing the context with other applications, it might
  91563. * be interested to not cache the unpack flip y state to ensure a consistent
  91564. * value would be set.
  91565. */
  91566. enableUnpackFlipYCached: boolean;
  91567. /** @hidden */
  91568. _unpackFlipY(value: boolean): void;
  91569. /** @hidden */
  91570. _getUnpackAlignement(): number;
  91571. /**
  91572. * Creates a dynamic texture
  91573. * @param width defines the width of the texture
  91574. * @param height defines the height of the texture
  91575. * @param generateMipMaps defines if the engine should generate the mip levels
  91576. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  91577. * @returns the dynamic texture inside an InternalTexture
  91578. */
  91579. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  91580. /**
  91581. * Update the sampling mode of a given texture
  91582. * @param samplingMode defines the required sampling mode
  91583. * @param texture defines the texture to update
  91584. */
  91585. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  91586. /**
  91587. * Update the content of a dynamic texture
  91588. * @param texture defines the texture to update
  91589. * @param canvas defines the canvas containing the source
  91590. * @param invertY defines if data must be stored with Y axis inverted
  91591. * @param premulAlpha defines if alpha is stored as premultiplied
  91592. * @param format defines the format of the data
  91593. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  91594. */
  91595. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  91596. /**
  91597. * Update a video texture
  91598. * @param texture defines the texture to update
  91599. * @param video defines the video element to use
  91600. * @param invertY defines if data must be stored with Y axis inverted
  91601. */
  91602. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  91603. /**
  91604. * Updates a depth texture Comparison Mode and Function.
  91605. * If the comparison Function is equal to 0, the mode will be set to none.
  91606. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  91607. * @param texture The texture to set the comparison function for
  91608. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  91609. */
  91610. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  91611. /** @hidden */
  91612. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  91613. width: number;
  91614. height: number;
  91615. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  91616. /**
  91617. * Creates a depth stencil texture.
  91618. * This is only available in WebGL 2 or with the depth texture extension available.
  91619. * @param size The size of face edge in the texture.
  91620. * @param options The options defining the texture.
  91621. * @returns The texture
  91622. */
  91623. createDepthStencilTexture(size: number | {
  91624. width: number;
  91625. height: number;
  91626. }, options: DepthTextureCreationOptions): InternalTexture;
  91627. /**
  91628. * Creates a depth stencil texture.
  91629. * This is only available in WebGL 2 or with the depth texture extension available.
  91630. * @param size The size of face edge in the texture.
  91631. * @param options The options defining the texture.
  91632. * @returns The texture
  91633. */
  91634. private _createDepthStencilTexture;
  91635. /**
  91636. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  91637. * @param renderTarget The render target to set the frame buffer for
  91638. */
  91639. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  91640. /**
  91641. * Creates a new render target texture
  91642. * @param size defines the size of the texture
  91643. * @param options defines the options used to create the texture
  91644. * @returns a new render target texture stored in an InternalTexture
  91645. */
  91646. createRenderTargetTexture(size: number | {
  91647. width: number;
  91648. height: number;
  91649. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  91650. /** @hidden */
  91651. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  91652. /**
  91653. * Updates the sample count of a render target texture
  91654. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  91655. * @param texture defines the texture to update
  91656. * @param samples defines the sample count to set
  91657. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  91658. */
  91659. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  91660. /** @hidden */
  91661. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  91662. /** @hidden */
  91663. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  91664. /** @hidden */
  91665. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  91666. /** @hidden */
  91667. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  91668. /**
  91669. * @hidden
  91670. */
  91671. _setCubeMapTextureParams(loadMipmap: boolean): void;
  91672. private _prepareWebGLTextureContinuation;
  91673. private _prepareWebGLTexture;
  91674. /** @hidden */
  91675. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  91676. /** @hidden */
  91677. _releaseFramebufferObjects(texture: InternalTexture): void;
  91678. /** @hidden */
  91679. _releaseTexture(texture: InternalTexture): void;
  91680. private setProgram;
  91681. private _boundUniforms;
  91682. /**
  91683. * Binds an effect to the webGL context
  91684. * @param effect defines the effect to bind
  91685. */
  91686. bindSamplers(effect: Effect): void;
  91687. private _activateCurrentTexture;
  91688. /** @hidden */
  91689. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  91690. /** @hidden */
  91691. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  91692. /**
  91693. * Sets a texture to the webGL context from a postprocess
  91694. * @param channel defines the channel to use
  91695. * @param postProcess defines the source postprocess
  91696. */
  91697. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  91698. /**
  91699. * Binds the output of the passed in post process to the texture channel specified
  91700. * @param channel The channel the texture should be bound to
  91701. * @param postProcess The post process which's output should be bound
  91702. */
  91703. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  91704. /**
  91705. * Unbind all textures from the webGL context
  91706. */
  91707. unbindAllTextures(): void;
  91708. /**
  91709. * Sets a texture to the according uniform.
  91710. * @param channel The texture channel
  91711. * @param uniform The uniform to set
  91712. * @param texture The texture to apply
  91713. */
  91714. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  91715. /**
  91716. * Sets a depth stencil texture from a render target to the according uniform.
  91717. * @param channel The texture channel
  91718. * @param uniform The uniform to set
  91719. * @param texture The render target texture containing the depth stencil texture to apply
  91720. */
  91721. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  91722. private _bindSamplerUniformToChannel;
  91723. private _getTextureWrapMode;
  91724. private _setTexture;
  91725. /**
  91726. * Sets an array of texture to the webGL context
  91727. * @param channel defines the channel where the texture array must be set
  91728. * @param uniform defines the associated uniform location
  91729. * @param textures defines the array of textures to bind
  91730. */
  91731. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  91732. /** @hidden */
  91733. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  91734. private _setTextureParameterFloat;
  91735. private _setTextureParameterInteger;
  91736. /**
  91737. * Reads pixels from the current frame buffer. Please note that this function can be slow
  91738. * @param x defines the x coordinate of the rectangle where pixels must be read
  91739. * @param y defines the y coordinate of the rectangle where pixels must be read
  91740. * @param width defines the width of the rectangle where pixels must be read
  91741. * @param height defines the height of the rectangle where pixels must be read
  91742. * @returns a Uint8Array containing RGBA colors
  91743. */
  91744. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  91745. /**
  91746. * Add an externaly attached data from its key.
  91747. * This method call will fail and return false, if such key already exists.
  91748. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  91749. * @param key the unique key that identifies the data
  91750. * @param data the data object to associate to the key for this Engine instance
  91751. * @return true if no such key were already present and the data was added successfully, false otherwise
  91752. */
  91753. addExternalData<T>(key: string, data: T): boolean;
  91754. /**
  91755. * Get an externaly attached data from its key
  91756. * @param key the unique key that identifies the data
  91757. * @return the associated data, if present (can be null), or undefined if not present
  91758. */
  91759. getExternalData<T>(key: string): T;
  91760. /**
  91761. * Get an externaly attached data from its key, create it using a factory if it's not already present
  91762. * @param key the unique key that identifies the data
  91763. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  91764. * @return the associated data, can be null if the factory returned null.
  91765. */
  91766. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  91767. /**
  91768. * Remove an externaly attached data from the Engine instance
  91769. * @param key the unique key that identifies the data
  91770. * @return true if the data was successfully removed, false if it doesn't exist
  91771. */
  91772. removeExternalData(key: string): boolean;
  91773. /**
  91774. * Unbind all vertex attributes from the webGL context
  91775. */
  91776. unbindAllAttributes(): void;
  91777. /**
  91778. * 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
  91779. */
  91780. releaseEffects(): void;
  91781. /**
  91782. * Dispose and release all associated resources
  91783. */
  91784. dispose(): void;
  91785. /**
  91786. * Display the loading screen
  91787. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91788. */
  91789. displayLoadingUI(): void;
  91790. /**
  91791. * Hide the loading screen
  91792. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91793. */
  91794. hideLoadingUI(): void;
  91795. /**
  91796. * Gets the current loading screen object
  91797. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91798. */
  91799. /**
  91800. * Sets the current loading screen object
  91801. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91802. */
  91803. loadingScreen: ILoadingScreen;
  91804. /**
  91805. * Sets the current loading screen text
  91806. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91807. */
  91808. loadingUIText: string;
  91809. /**
  91810. * Sets the current loading screen background color
  91811. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91812. */
  91813. loadingUIBackgroundColor: string;
  91814. /**
  91815. * Attach a new callback raised when context lost event is fired
  91816. * @param callback defines the callback to call
  91817. */
  91818. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  91819. /**
  91820. * Attach a new callback raised when context restored event is fired
  91821. * @param callback defines the callback to call
  91822. */
  91823. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  91824. /**
  91825. * Gets the source code of the vertex shader associated with a specific webGL program
  91826. * @param program defines the program to use
  91827. * @returns a string containing the source code of the vertex shader associated with the program
  91828. */
  91829. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  91830. /**
  91831. * Gets the source code of the fragment shader associated with a specific webGL program
  91832. * @param program defines the program to use
  91833. * @returns a string containing the source code of the fragment shader associated with the program
  91834. */
  91835. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  91836. /**
  91837. * Get the current error code of the webGL context
  91838. * @returns the error code
  91839. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  91840. */
  91841. getError(): number;
  91842. /**
  91843. * Gets the current framerate
  91844. * @returns a number representing the framerate
  91845. */
  91846. getFps(): number;
  91847. /**
  91848. * Gets the time spent between current and previous frame
  91849. * @returns a number representing the delta time in ms
  91850. */
  91851. getDeltaTime(): number;
  91852. private _measureFps;
  91853. /** @hidden */
  91854. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  91855. private _canRenderToFloatFramebuffer;
  91856. private _canRenderToHalfFloatFramebuffer;
  91857. private _canRenderToFramebuffer;
  91858. /** @hidden */
  91859. _getWebGLTextureType(type: number): number;
  91860. /** @hidden */
  91861. _getInternalFormat(format: number): number;
  91862. /** @hidden */
  91863. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  91864. /** @hidden */
  91865. _getRGBAMultiSampleBufferFormat(type: number): number;
  91866. /** @hidden */
  91867. _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;
  91868. /** @hidden */
  91869. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  91870. /**
  91871. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  91872. * @returns true if the engine can be created
  91873. * @ignorenaming
  91874. */
  91875. static isSupported(): boolean;
  91876. }
  91877. }
  91878. declare module BABYLON {
  91879. /**
  91880. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  91881. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  91882. */
  91883. export class EffectFallbacks {
  91884. private _defines;
  91885. private _currentRank;
  91886. private _maxRank;
  91887. private _mesh;
  91888. /**
  91889. * Removes the fallback from the bound mesh.
  91890. */
  91891. unBindMesh(): void;
  91892. /**
  91893. * Adds a fallback on the specified property.
  91894. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  91895. * @param define The name of the define in the shader
  91896. */
  91897. addFallback(rank: number, define: string): void;
  91898. /**
  91899. * Sets the mesh to use CPU skinning when needing to fallback.
  91900. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  91901. * @param mesh The mesh to use the fallbacks.
  91902. */
  91903. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  91904. /**
  91905. * Checks to see if more fallbacks are still availible.
  91906. */
  91907. readonly isMoreFallbacks: boolean;
  91908. /**
  91909. * Removes the defines that should be removed when falling back.
  91910. * @param currentDefines defines the current define statements for the shader.
  91911. * @param effect defines the current effect we try to compile
  91912. * @returns The resulting defines with defines of the current rank removed.
  91913. */
  91914. reduce(currentDefines: string, effect: Effect): string;
  91915. }
  91916. /**
  91917. * Options to be used when creating an effect.
  91918. */
  91919. export class EffectCreationOptions {
  91920. /**
  91921. * Atrributes that will be used in the shader.
  91922. */
  91923. attributes: string[];
  91924. /**
  91925. * Uniform varible names that will be set in the shader.
  91926. */
  91927. uniformsNames: string[];
  91928. /**
  91929. * Uniform buffer varible names that will be set in the shader.
  91930. */
  91931. uniformBuffersNames: string[];
  91932. /**
  91933. * Sampler texture variable names that will be set in the shader.
  91934. */
  91935. samplers: string[];
  91936. /**
  91937. * Define statements that will be set in the shader.
  91938. */
  91939. defines: any;
  91940. /**
  91941. * Possible fallbacks for this effect to improve performance when needed.
  91942. */
  91943. fallbacks: Nullable<EffectFallbacks>;
  91944. /**
  91945. * Callback that will be called when the shader is compiled.
  91946. */
  91947. onCompiled: Nullable<(effect: Effect) => void>;
  91948. /**
  91949. * Callback that will be called if an error occurs during shader compilation.
  91950. */
  91951. onError: Nullable<(effect: Effect, errors: string) => void>;
  91952. /**
  91953. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  91954. */
  91955. indexParameters: any;
  91956. /**
  91957. * Max number of lights that can be used in the shader.
  91958. */
  91959. maxSimultaneousLights: number;
  91960. /**
  91961. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  91962. */
  91963. transformFeedbackVaryings: Nullable<string[]>;
  91964. }
  91965. /**
  91966. * Effect containing vertex and fragment shader that can be executed on an object.
  91967. */
  91968. export class Effect implements IDisposable {
  91969. /**
  91970. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  91971. */
  91972. static ShadersRepository: string;
  91973. /**
  91974. * Name of the effect.
  91975. */
  91976. name: any;
  91977. /**
  91978. * String container all the define statements that should be set on the shader.
  91979. */
  91980. defines: string;
  91981. /**
  91982. * Callback that will be called when the shader is compiled.
  91983. */
  91984. onCompiled: Nullable<(effect: Effect) => void>;
  91985. /**
  91986. * Callback that will be called if an error occurs during shader compilation.
  91987. */
  91988. onError: Nullable<(effect: Effect, errors: string) => void>;
  91989. /**
  91990. * Callback that will be called when effect is bound.
  91991. */
  91992. onBind: Nullable<(effect: Effect) => void>;
  91993. /**
  91994. * Unique ID of the effect.
  91995. */
  91996. uniqueId: number;
  91997. /**
  91998. * Observable that will be called when the shader is compiled.
  91999. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  92000. */
  92001. onCompileObservable: Observable<Effect>;
  92002. /**
  92003. * Observable that will be called if an error occurs during shader compilation.
  92004. */
  92005. onErrorObservable: Observable<Effect>;
  92006. /** @hidden */
  92007. _onBindObservable: Nullable<Observable<Effect>>;
  92008. /**
  92009. * Observable that will be called when effect is bound.
  92010. */
  92011. readonly onBindObservable: Observable<Effect>;
  92012. /** @hidden */
  92013. _bonesComputationForcedToCPU: boolean;
  92014. private static _uniqueIdSeed;
  92015. private _engine;
  92016. private _uniformBuffersNames;
  92017. private _uniformsNames;
  92018. private _samplerList;
  92019. private _samplers;
  92020. private _isReady;
  92021. private _compilationError;
  92022. private _attributesNames;
  92023. private _attributes;
  92024. private _uniforms;
  92025. /**
  92026. * Key for the effect.
  92027. * @hidden
  92028. */
  92029. _key: string;
  92030. private _indexParameters;
  92031. private _fallbacks;
  92032. private _vertexSourceCode;
  92033. private _fragmentSourceCode;
  92034. private _vertexSourceCodeOverride;
  92035. private _fragmentSourceCodeOverride;
  92036. private _transformFeedbackVaryings;
  92037. /**
  92038. * Compiled shader to webGL program.
  92039. * @hidden
  92040. */
  92041. _pipelineContext: Nullable<IPipelineContext>;
  92042. private _valueCache;
  92043. private static _baseCache;
  92044. /**
  92045. * Instantiates an effect.
  92046. * An effect can be used to create/manage/execute vertex and fragment shaders.
  92047. * @param baseName Name of the effect.
  92048. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  92049. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  92050. * @param samplers List of sampler variables that will be passed to the shader.
  92051. * @param engine Engine to be used to render the effect
  92052. * @param defines Define statements to be added to the shader.
  92053. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  92054. * @param onCompiled Callback that will be called when the shader is compiled.
  92055. * @param onError Callback that will be called if an error occurs during shader compilation.
  92056. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  92057. */
  92058. 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);
  92059. private _useFinalCode;
  92060. /**
  92061. * Unique key for this effect
  92062. */
  92063. readonly key: string;
  92064. /**
  92065. * If the effect has been compiled and prepared.
  92066. * @returns if the effect is compiled and prepared.
  92067. */
  92068. isReady(): boolean;
  92069. /**
  92070. * The engine the effect was initialized with.
  92071. * @returns the engine.
  92072. */
  92073. getEngine(): Engine;
  92074. /**
  92075. * The pipeline context for this effect
  92076. * @returns the associated pipeline context
  92077. */
  92078. getPipelineContext(): Nullable<IPipelineContext>;
  92079. /**
  92080. * The set of names of attribute variables for the shader.
  92081. * @returns An array of attribute names.
  92082. */
  92083. getAttributesNames(): string[];
  92084. /**
  92085. * Returns the attribute at the given index.
  92086. * @param index The index of the attribute.
  92087. * @returns The location of the attribute.
  92088. */
  92089. getAttributeLocation(index: number): number;
  92090. /**
  92091. * Returns the attribute based on the name of the variable.
  92092. * @param name of the attribute to look up.
  92093. * @returns the attribute location.
  92094. */
  92095. getAttributeLocationByName(name: string): number;
  92096. /**
  92097. * The number of attributes.
  92098. * @returns the numnber of attributes.
  92099. */
  92100. getAttributesCount(): number;
  92101. /**
  92102. * Gets the index of a uniform variable.
  92103. * @param uniformName of the uniform to look up.
  92104. * @returns the index.
  92105. */
  92106. getUniformIndex(uniformName: string): number;
  92107. /**
  92108. * Returns the attribute based on the name of the variable.
  92109. * @param uniformName of the uniform to look up.
  92110. * @returns the location of the uniform.
  92111. */
  92112. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  92113. /**
  92114. * Returns an array of sampler variable names
  92115. * @returns The array of sampler variable neames.
  92116. */
  92117. getSamplers(): string[];
  92118. /**
  92119. * The error from the last compilation.
  92120. * @returns the error string.
  92121. */
  92122. getCompilationError(): string;
  92123. /**
  92124. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  92125. * @param func The callback to be used.
  92126. */
  92127. executeWhenCompiled(func: (effect: Effect) => void): void;
  92128. private _checkIsReady;
  92129. /** @hidden */
  92130. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  92131. /** @hidden */
  92132. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  92133. /** @hidden */
  92134. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  92135. /**
  92136. * Recompiles the webGL program
  92137. * @param vertexSourceCode The source code for the vertex shader.
  92138. * @param fragmentSourceCode The source code for the fragment shader.
  92139. * @param onCompiled Callback called when completed.
  92140. * @param onError Callback called on error.
  92141. * @hidden
  92142. */
  92143. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  92144. /**
  92145. * Prepares the effect
  92146. * @hidden
  92147. */
  92148. _prepareEffect(): void;
  92149. /**
  92150. * Checks if the effect is supported. (Must be called after compilation)
  92151. */
  92152. readonly isSupported: boolean;
  92153. /**
  92154. * Binds a texture to the engine to be used as output of the shader.
  92155. * @param channel Name of the output variable.
  92156. * @param texture Texture to bind.
  92157. * @hidden
  92158. */
  92159. _bindTexture(channel: string, texture: InternalTexture): void;
  92160. /**
  92161. * Sets a texture on the engine to be used in the shader.
  92162. * @param channel Name of the sampler variable.
  92163. * @param texture Texture to set.
  92164. */
  92165. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  92166. /**
  92167. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  92168. * @param channel Name of the sampler variable.
  92169. * @param texture Texture to set.
  92170. */
  92171. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  92172. /**
  92173. * Sets an array of textures on the engine to be used in the shader.
  92174. * @param channel Name of the variable.
  92175. * @param textures Textures to set.
  92176. */
  92177. setTextureArray(channel: string, textures: BaseTexture[]): void;
  92178. /**
  92179. * 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)
  92180. * @param channel Name of the sampler variable.
  92181. * @param postProcess Post process to get the input texture from.
  92182. */
  92183. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  92184. /**
  92185. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  92186. * 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)
  92187. * @param channel Name of the sampler variable.
  92188. * @param postProcess Post process to get the output texture from.
  92189. */
  92190. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  92191. /** @hidden */
  92192. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  92193. /** @hidden */
  92194. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  92195. /** @hidden */
  92196. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  92197. /** @hidden */
  92198. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  92199. /**
  92200. * Binds a buffer to a uniform.
  92201. * @param buffer Buffer to bind.
  92202. * @param name Name of the uniform variable to bind to.
  92203. */
  92204. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  92205. /**
  92206. * Binds block to a uniform.
  92207. * @param blockName Name of the block to bind.
  92208. * @param index Index to bind.
  92209. */
  92210. bindUniformBlock(blockName: string, index: number): void;
  92211. /**
  92212. * Sets an interger value on a uniform variable.
  92213. * @param uniformName Name of the variable.
  92214. * @param value Value to be set.
  92215. * @returns this effect.
  92216. */
  92217. setInt(uniformName: string, value: number): Effect;
  92218. /**
  92219. * Sets an int array on a uniform variable.
  92220. * @param uniformName Name of the variable.
  92221. * @param array array to be set.
  92222. * @returns this effect.
  92223. */
  92224. setIntArray(uniformName: string, array: Int32Array): Effect;
  92225. /**
  92226. * 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)
  92227. * @param uniformName Name of the variable.
  92228. * @param array array to be set.
  92229. * @returns this effect.
  92230. */
  92231. setIntArray2(uniformName: string, array: Int32Array): Effect;
  92232. /**
  92233. * 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)
  92234. * @param uniformName Name of the variable.
  92235. * @param array array to be set.
  92236. * @returns this effect.
  92237. */
  92238. setIntArray3(uniformName: string, array: Int32Array): Effect;
  92239. /**
  92240. * 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)
  92241. * @param uniformName Name of the variable.
  92242. * @param array array to be set.
  92243. * @returns this effect.
  92244. */
  92245. setIntArray4(uniformName: string, array: Int32Array): Effect;
  92246. /**
  92247. * Sets an float array on a uniform variable.
  92248. * @param uniformName Name of the variable.
  92249. * @param array array to be set.
  92250. * @returns this effect.
  92251. */
  92252. setFloatArray(uniformName: string, array: Float32Array): Effect;
  92253. /**
  92254. * 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)
  92255. * @param uniformName Name of the variable.
  92256. * @param array array to be set.
  92257. * @returns this effect.
  92258. */
  92259. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  92260. /**
  92261. * 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)
  92262. * @param uniformName Name of the variable.
  92263. * @param array array to be set.
  92264. * @returns this effect.
  92265. */
  92266. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  92267. /**
  92268. * 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)
  92269. * @param uniformName Name of the variable.
  92270. * @param array array to be set.
  92271. * @returns this effect.
  92272. */
  92273. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  92274. /**
  92275. * Sets an array on a uniform variable.
  92276. * @param uniformName Name of the variable.
  92277. * @param array array to be set.
  92278. * @returns this effect.
  92279. */
  92280. setArray(uniformName: string, array: number[]): Effect;
  92281. /**
  92282. * 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)
  92283. * @param uniformName Name of the variable.
  92284. * @param array array to be set.
  92285. * @returns this effect.
  92286. */
  92287. setArray2(uniformName: string, array: number[]): Effect;
  92288. /**
  92289. * 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)
  92290. * @param uniformName Name of the variable.
  92291. * @param array array to be set.
  92292. * @returns this effect.
  92293. */
  92294. setArray3(uniformName: string, array: number[]): Effect;
  92295. /**
  92296. * 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)
  92297. * @param uniformName Name of the variable.
  92298. * @param array array to be set.
  92299. * @returns this effect.
  92300. */
  92301. setArray4(uniformName: string, array: number[]): Effect;
  92302. /**
  92303. * Sets matrices on a uniform variable.
  92304. * @param uniformName Name of the variable.
  92305. * @param matrices matrices to be set.
  92306. * @returns this effect.
  92307. */
  92308. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  92309. /**
  92310. * Sets matrix on a uniform variable.
  92311. * @param uniformName Name of the variable.
  92312. * @param matrix matrix to be set.
  92313. * @returns this effect.
  92314. */
  92315. setMatrix(uniformName: string, matrix: Matrix): Effect;
  92316. /**
  92317. * 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)
  92318. * @param uniformName Name of the variable.
  92319. * @param matrix matrix to be set.
  92320. * @returns this effect.
  92321. */
  92322. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  92323. /**
  92324. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  92325. * @param uniformName Name of the variable.
  92326. * @param matrix matrix to be set.
  92327. * @returns this effect.
  92328. */
  92329. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  92330. /**
  92331. * Sets a float on a uniform variable.
  92332. * @param uniformName Name of the variable.
  92333. * @param value value to be set.
  92334. * @returns this effect.
  92335. */
  92336. setFloat(uniformName: string, value: number): Effect;
  92337. /**
  92338. * Sets a boolean on a uniform variable.
  92339. * @param uniformName Name of the variable.
  92340. * @param bool value to be set.
  92341. * @returns this effect.
  92342. */
  92343. setBool(uniformName: string, bool: boolean): Effect;
  92344. /**
  92345. * Sets a Vector2 on a uniform variable.
  92346. * @param uniformName Name of the variable.
  92347. * @param vector2 vector2 to be set.
  92348. * @returns this effect.
  92349. */
  92350. setVector2(uniformName: string, vector2: Vector2): Effect;
  92351. /**
  92352. * Sets a float2 on a uniform variable.
  92353. * @param uniformName Name of the variable.
  92354. * @param x First float in float2.
  92355. * @param y Second float in float2.
  92356. * @returns this effect.
  92357. */
  92358. setFloat2(uniformName: string, x: number, y: number): Effect;
  92359. /**
  92360. * Sets a Vector3 on a uniform variable.
  92361. * @param uniformName Name of the variable.
  92362. * @param vector3 Value to be set.
  92363. * @returns this effect.
  92364. */
  92365. setVector3(uniformName: string, vector3: Vector3): Effect;
  92366. /**
  92367. * Sets a float3 on a uniform variable.
  92368. * @param uniformName Name of the variable.
  92369. * @param x First float in float3.
  92370. * @param y Second float in float3.
  92371. * @param z Third float in float3.
  92372. * @returns this effect.
  92373. */
  92374. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  92375. /**
  92376. * Sets a Vector4 on a uniform variable.
  92377. * @param uniformName Name of the variable.
  92378. * @param vector4 Value to be set.
  92379. * @returns this effect.
  92380. */
  92381. setVector4(uniformName: string, vector4: Vector4): Effect;
  92382. /**
  92383. * Sets a float4 on a uniform variable.
  92384. * @param uniformName Name of the variable.
  92385. * @param x First float in float4.
  92386. * @param y Second float in float4.
  92387. * @param z Third float in float4.
  92388. * @param w Fourth float in float4.
  92389. * @returns this effect.
  92390. */
  92391. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  92392. /**
  92393. * Sets a Color3 on a uniform variable.
  92394. * @param uniformName Name of the variable.
  92395. * @param color3 Value to be set.
  92396. * @returns this effect.
  92397. */
  92398. setColor3(uniformName: string, color3: Color3): Effect;
  92399. /**
  92400. * Sets a Color4 on a uniform variable.
  92401. * @param uniformName Name of the variable.
  92402. * @param color3 Value to be set.
  92403. * @param alpha Alpha value to be set.
  92404. * @returns this effect.
  92405. */
  92406. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  92407. /**
  92408. * Sets a Color4 on a uniform variable
  92409. * @param uniformName defines the name of the variable
  92410. * @param color4 defines the value to be set
  92411. * @returns this effect.
  92412. */
  92413. setDirectColor4(uniformName: string, color4: Color4): Effect;
  92414. /** Release all associated resources */
  92415. dispose(): void;
  92416. /**
  92417. * This function will add a new shader to the shader store
  92418. * @param name the name of the shader
  92419. * @param pixelShader optional pixel shader content
  92420. * @param vertexShader optional vertex shader content
  92421. */
  92422. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  92423. /**
  92424. * Store of each shader (The can be looked up using effect.key)
  92425. */
  92426. static ShadersStore: {
  92427. [key: string]: string;
  92428. };
  92429. /**
  92430. * Store of each included file for a shader (The can be looked up using effect.key)
  92431. */
  92432. static IncludesShadersStore: {
  92433. [key: string]: string;
  92434. };
  92435. /**
  92436. * Resets the cache of effects.
  92437. */
  92438. static ResetCache(): void;
  92439. }
  92440. }
  92441. declare module BABYLON {
  92442. /**
  92443. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  92444. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  92445. * 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;
  92446. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  92447. */
  92448. export class ColorCurves {
  92449. private _dirty;
  92450. private _tempColor;
  92451. private _globalCurve;
  92452. private _highlightsCurve;
  92453. private _midtonesCurve;
  92454. private _shadowsCurve;
  92455. private _positiveCurve;
  92456. private _negativeCurve;
  92457. private _globalHue;
  92458. private _globalDensity;
  92459. private _globalSaturation;
  92460. private _globalExposure;
  92461. /**
  92462. * Gets the global Hue value.
  92463. * 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).
  92464. */
  92465. /**
  92466. * Sets the global Hue value.
  92467. * 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).
  92468. */
  92469. globalHue: number;
  92470. /**
  92471. * Gets the global Density value.
  92472. * 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.
  92473. * Values less than zero provide a filter of opposite hue.
  92474. */
  92475. /**
  92476. * Sets the global Density value.
  92477. * 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.
  92478. * Values less than zero provide a filter of opposite hue.
  92479. */
  92480. globalDensity: number;
  92481. /**
  92482. * Gets the global Saturation value.
  92483. * 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.
  92484. */
  92485. /**
  92486. * Sets the global Saturation value.
  92487. * 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.
  92488. */
  92489. globalSaturation: number;
  92490. /**
  92491. * Gets the global Exposure value.
  92492. * 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.
  92493. */
  92494. /**
  92495. * Sets the global Exposure value.
  92496. * 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.
  92497. */
  92498. globalExposure: number;
  92499. private _highlightsHue;
  92500. private _highlightsDensity;
  92501. private _highlightsSaturation;
  92502. private _highlightsExposure;
  92503. /**
  92504. * Gets the highlights Hue value.
  92505. * 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).
  92506. */
  92507. /**
  92508. * Sets the highlights Hue value.
  92509. * 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).
  92510. */
  92511. highlightsHue: number;
  92512. /**
  92513. * Gets the highlights Density value.
  92514. * 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.
  92515. * Values less than zero provide a filter of opposite hue.
  92516. */
  92517. /**
  92518. * Sets the highlights Density value.
  92519. * 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.
  92520. * Values less than zero provide a filter of opposite hue.
  92521. */
  92522. highlightsDensity: number;
  92523. /**
  92524. * Gets the highlights Saturation value.
  92525. * 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.
  92526. */
  92527. /**
  92528. * Sets the highlights Saturation value.
  92529. * 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.
  92530. */
  92531. highlightsSaturation: number;
  92532. /**
  92533. * Gets the highlights Exposure value.
  92534. * 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.
  92535. */
  92536. /**
  92537. * Sets the highlights Exposure value.
  92538. * 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.
  92539. */
  92540. highlightsExposure: number;
  92541. private _midtonesHue;
  92542. private _midtonesDensity;
  92543. private _midtonesSaturation;
  92544. private _midtonesExposure;
  92545. /**
  92546. * Gets the midtones Hue value.
  92547. * 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).
  92548. */
  92549. /**
  92550. * Sets the midtones Hue value.
  92551. * 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).
  92552. */
  92553. midtonesHue: number;
  92554. /**
  92555. * Gets the midtones Density value.
  92556. * 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.
  92557. * Values less than zero provide a filter of opposite hue.
  92558. */
  92559. /**
  92560. * Sets the midtones Density value.
  92561. * 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.
  92562. * Values less than zero provide a filter of opposite hue.
  92563. */
  92564. midtonesDensity: number;
  92565. /**
  92566. * Gets the midtones Saturation value.
  92567. * 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.
  92568. */
  92569. /**
  92570. * Sets the midtones Saturation value.
  92571. * 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.
  92572. */
  92573. midtonesSaturation: number;
  92574. /**
  92575. * Gets the midtones Exposure value.
  92576. * 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.
  92577. */
  92578. /**
  92579. * Sets the midtones Exposure value.
  92580. * 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.
  92581. */
  92582. midtonesExposure: number;
  92583. private _shadowsHue;
  92584. private _shadowsDensity;
  92585. private _shadowsSaturation;
  92586. private _shadowsExposure;
  92587. /**
  92588. * Gets the shadows Hue value.
  92589. * 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).
  92590. */
  92591. /**
  92592. * Sets the shadows Hue value.
  92593. * 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).
  92594. */
  92595. shadowsHue: number;
  92596. /**
  92597. * Gets the shadows Density value.
  92598. * 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.
  92599. * Values less than zero provide a filter of opposite hue.
  92600. */
  92601. /**
  92602. * Sets the shadows Density value.
  92603. * 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.
  92604. * Values less than zero provide a filter of opposite hue.
  92605. */
  92606. shadowsDensity: number;
  92607. /**
  92608. * Gets the shadows Saturation value.
  92609. * 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.
  92610. */
  92611. /**
  92612. * Sets the shadows Saturation value.
  92613. * 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.
  92614. */
  92615. shadowsSaturation: number;
  92616. /**
  92617. * Gets the shadows Exposure value.
  92618. * 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.
  92619. */
  92620. /**
  92621. * Sets the shadows Exposure value.
  92622. * 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.
  92623. */
  92624. shadowsExposure: number;
  92625. /**
  92626. * Returns the class name
  92627. * @returns The class name
  92628. */
  92629. getClassName(): string;
  92630. /**
  92631. * Binds the color curves to the shader.
  92632. * @param colorCurves The color curve to bind
  92633. * @param effect The effect to bind to
  92634. * @param positiveUniform The positive uniform shader parameter
  92635. * @param neutralUniform The neutral uniform shader parameter
  92636. * @param negativeUniform The negative uniform shader parameter
  92637. */
  92638. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  92639. /**
  92640. * Prepare the list of uniforms associated with the ColorCurves effects.
  92641. * @param uniformsList The list of uniforms used in the effect
  92642. */
  92643. static PrepareUniforms(uniformsList: string[]): void;
  92644. /**
  92645. * Returns color grading data based on a hue, density, saturation and exposure value.
  92646. * @param filterHue The hue of the color filter.
  92647. * @param filterDensity The density of the color filter.
  92648. * @param saturation The saturation.
  92649. * @param exposure The exposure.
  92650. * @param result The result data container.
  92651. */
  92652. private getColorGradingDataToRef;
  92653. /**
  92654. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  92655. * @param value The input slider value in range [-100,100].
  92656. * @returns Adjusted value.
  92657. */
  92658. private static applyColorGradingSliderNonlinear;
  92659. /**
  92660. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  92661. * @param hue The hue (H) input.
  92662. * @param saturation The saturation (S) input.
  92663. * @param brightness The brightness (B) input.
  92664. * @result An RGBA color represented as Vector4.
  92665. */
  92666. private static fromHSBToRef;
  92667. /**
  92668. * Returns a value clamped between min and max
  92669. * @param value The value to clamp
  92670. * @param min The minimum of value
  92671. * @param max The maximum of value
  92672. * @returns The clamped value.
  92673. */
  92674. private static clamp;
  92675. /**
  92676. * Clones the current color curve instance.
  92677. * @return The cloned curves
  92678. */
  92679. clone(): ColorCurves;
  92680. /**
  92681. * Serializes the current color curve instance to a json representation.
  92682. * @return a JSON representation
  92683. */
  92684. serialize(): any;
  92685. /**
  92686. * Parses the color curve from a json representation.
  92687. * @param source the JSON source to parse
  92688. * @return The parsed curves
  92689. */
  92690. static Parse(source: any): ColorCurves;
  92691. }
  92692. }
  92693. declare module BABYLON {
  92694. /**
  92695. * Interface to follow in your material defines to integrate easily the
  92696. * Image proccessing functions.
  92697. * @hidden
  92698. */
  92699. export interface IImageProcessingConfigurationDefines {
  92700. IMAGEPROCESSING: boolean;
  92701. VIGNETTE: boolean;
  92702. VIGNETTEBLENDMODEMULTIPLY: boolean;
  92703. VIGNETTEBLENDMODEOPAQUE: boolean;
  92704. TONEMAPPING: boolean;
  92705. TONEMAPPING_ACES: boolean;
  92706. CONTRAST: boolean;
  92707. EXPOSURE: boolean;
  92708. COLORCURVES: boolean;
  92709. COLORGRADING: boolean;
  92710. COLORGRADING3D: boolean;
  92711. SAMPLER3DGREENDEPTH: boolean;
  92712. SAMPLER3DBGRMAP: boolean;
  92713. IMAGEPROCESSINGPOSTPROCESS: boolean;
  92714. }
  92715. /**
  92716. * @hidden
  92717. */
  92718. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  92719. IMAGEPROCESSING: boolean;
  92720. VIGNETTE: boolean;
  92721. VIGNETTEBLENDMODEMULTIPLY: boolean;
  92722. VIGNETTEBLENDMODEOPAQUE: boolean;
  92723. TONEMAPPING: boolean;
  92724. TONEMAPPING_ACES: boolean;
  92725. CONTRAST: boolean;
  92726. COLORCURVES: boolean;
  92727. COLORGRADING: boolean;
  92728. COLORGRADING3D: boolean;
  92729. SAMPLER3DGREENDEPTH: boolean;
  92730. SAMPLER3DBGRMAP: boolean;
  92731. IMAGEPROCESSINGPOSTPROCESS: boolean;
  92732. EXPOSURE: boolean;
  92733. constructor();
  92734. }
  92735. /**
  92736. * This groups together the common properties used for image processing either in direct forward pass
  92737. * or through post processing effect depending on the use of the image processing pipeline in your scene
  92738. * or not.
  92739. */
  92740. export class ImageProcessingConfiguration {
  92741. /**
  92742. * Default tone mapping applied in BabylonJS.
  92743. */
  92744. static readonly TONEMAPPING_STANDARD: number;
  92745. /**
  92746. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  92747. * to other engines rendering to increase portability.
  92748. */
  92749. static readonly TONEMAPPING_ACES: number;
  92750. /**
  92751. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  92752. */
  92753. colorCurves: Nullable<ColorCurves>;
  92754. private _colorCurvesEnabled;
  92755. /**
  92756. * Gets wether the color curves effect is enabled.
  92757. */
  92758. /**
  92759. * Sets wether the color curves effect is enabled.
  92760. */
  92761. colorCurvesEnabled: boolean;
  92762. private _colorGradingTexture;
  92763. /**
  92764. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  92765. */
  92766. /**
  92767. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  92768. */
  92769. colorGradingTexture: Nullable<BaseTexture>;
  92770. private _colorGradingEnabled;
  92771. /**
  92772. * Gets wether the color grading effect is enabled.
  92773. */
  92774. /**
  92775. * Sets wether the color grading effect is enabled.
  92776. */
  92777. colorGradingEnabled: boolean;
  92778. private _colorGradingWithGreenDepth;
  92779. /**
  92780. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  92781. */
  92782. /**
  92783. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  92784. */
  92785. colorGradingWithGreenDepth: boolean;
  92786. private _colorGradingBGR;
  92787. /**
  92788. * Gets wether the color grading texture contains BGR values.
  92789. */
  92790. /**
  92791. * Sets wether the color grading texture contains BGR values.
  92792. */
  92793. colorGradingBGR: boolean;
  92794. /** @hidden */
  92795. _exposure: number;
  92796. /**
  92797. * Gets the Exposure used in the effect.
  92798. */
  92799. /**
  92800. * Sets the Exposure used in the effect.
  92801. */
  92802. exposure: number;
  92803. private _toneMappingEnabled;
  92804. /**
  92805. * Gets wether the tone mapping effect is enabled.
  92806. */
  92807. /**
  92808. * Sets wether the tone mapping effect is enabled.
  92809. */
  92810. toneMappingEnabled: boolean;
  92811. private _toneMappingType;
  92812. /**
  92813. * Gets the type of tone mapping effect.
  92814. */
  92815. /**
  92816. * Sets the type of tone mapping effect used in BabylonJS.
  92817. */
  92818. toneMappingType: number;
  92819. protected _contrast: number;
  92820. /**
  92821. * Gets the contrast used in the effect.
  92822. */
  92823. /**
  92824. * Sets the contrast used in the effect.
  92825. */
  92826. contrast: number;
  92827. /**
  92828. * Vignette stretch size.
  92829. */
  92830. vignetteStretch: number;
  92831. /**
  92832. * Vignette centre X Offset.
  92833. */
  92834. vignetteCentreX: number;
  92835. /**
  92836. * Vignette centre Y Offset.
  92837. */
  92838. vignetteCentreY: number;
  92839. /**
  92840. * Vignette weight or intensity of the vignette effect.
  92841. */
  92842. vignetteWeight: number;
  92843. /**
  92844. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  92845. * if vignetteEnabled is set to true.
  92846. */
  92847. vignetteColor: Color4;
  92848. /**
  92849. * Camera field of view used by the Vignette effect.
  92850. */
  92851. vignetteCameraFov: number;
  92852. private _vignetteBlendMode;
  92853. /**
  92854. * Gets the vignette blend mode allowing different kind of effect.
  92855. */
  92856. /**
  92857. * Sets the vignette blend mode allowing different kind of effect.
  92858. */
  92859. vignetteBlendMode: number;
  92860. private _vignetteEnabled;
  92861. /**
  92862. * Gets wether the vignette effect is enabled.
  92863. */
  92864. /**
  92865. * Sets wether the vignette effect is enabled.
  92866. */
  92867. vignetteEnabled: boolean;
  92868. private _applyByPostProcess;
  92869. /**
  92870. * Gets wether the image processing is applied through a post process or not.
  92871. */
  92872. /**
  92873. * Sets wether the image processing is applied through a post process or not.
  92874. */
  92875. applyByPostProcess: boolean;
  92876. private _isEnabled;
  92877. /**
  92878. * Gets wether the image processing is enabled or not.
  92879. */
  92880. /**
  92881. * Sets wether the image processing is enabled or not.
  92882. */
  92883. isEnabled: boolean;
  92884. /**
  92885. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  92886. */
  92887. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  92888. /**
  92889. * Method called each time the image processing information changes requires to recompile the effect.
  92890. */
  92891. protected _updateParameters(): void;
  92892. /**
  92893. * Gets the current class name.
  92894. * @return "ImageProcessingConfiguration"
  92895. */
  92896. getClassName(): string;
  92897. /**
  92898. * Prepare the list of uniforms associated with the Image Processing effects.
  92899. * @param uniforms The list of uniforms used in the effect
  92900. * @param defines the list of defines currently in use
  92901. */
  92902. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  92903. /**
  92904. * Prepare the list of samplers associated with the Image Processing effects.
  92905. * @param samplersList The list of uniforms used in the effect
  92906. * @param defines the list of defines currently in use
  92907. */
  92908. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  92909. /**
  92910. * Prepare the list of defines associated to the shader.
  92911. * @param defines the list of defines to complete
  92912. * @param forPostProcess Define if we are currently in post process mode or not
  92913. */
  92914. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  92915. /**
  92916. * Returns true if all the image processing information are ready.
  92917. * @returns True if ready, otherwise, false
  92918. */
  92919. isReady(): boolean;
  92920. /**
  92921. * Binds the image processing to the shader.
  92922. * @param effect The effect to bind to
  92923. * @param aspectRatio Define the current aspect ratio of the effect
  92924. */
  92925. bind(effect: Effect, aspectRatio?: number): void;
  92926. /**
  92927. * Clones the current image processing instance.
  92928. * @return The cloned image processing
  92929. */
  92930. clone(): ImageProcessingConfiguration;
  92931. /**
  92932. * Serializes the current image processing instance to a json representation.
  92933. * @return a JSON representation
  92934. */
  92935. serialize(): any;
  92936. /**
  92937. * Parses the image processing from a json representation.
  92938. * @param source the JSON source to parse
  92939. * @return The parsed image processing
  92940. */
  92941. static Parse(source: any): ImageProcessingConfiguration;
  92942. private static _VIGNETTEMODE_MULTIPLY;
  92943. private static _VIGNETTEMODE_OPAQUE;
  92944. /**
  92945. * Used to apply the vignette as a mix with the pixel color.
  92946. */
  92947. static readonly VIGNETTEMODE_MULTIPLY: number;
  92948. /**
  92949. * Used to apply the vignette as a replacement of the pixel color.
  92950. */
  92951. static readonly VIGNETTEMODE_OPAQUE: number;
  92952. }
  92953. }
  92954. declare module BABYLON {
  92955. /**
  92956. * This represents all the required information to add a fresnel effect on a material:
  92957. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  92958. */
  92959. export class FresnelParameters {
  92960. private _isEnabled;
  92961. /**
  92962. * Define if the fresnel effect is enable or not.
  92963. */
  92964. isEnabled: boolean;
  92965. /**
  92966. * Define the color used on edges (grazing angle)
  92967. */
  92968. leftColor: Color3;
  92969. /**
  92970. * Define the color used on center
  92971. */
  92972. rightColor: Color3;
  92973. /**
  92974. * Define bias applied to computed fresnel term
  92975. */
  92976. bias: number;
  92977. /**
  92978. * Defined the power exponent applied to fresnel term
  92979. */
  92980. power: number;
  92981. /**
  92982. * Clones the current fresnel and its valuues
  92983. * @returns a clone fresnel configuration
  92984. */
  92985. clone(): FresnelParameters;
  92986. /**
  92987. * Serializes the current fresnel parameters to a JSON representation.
  92988. * @return the JSON serialization
  92989. */
  92990. serialize(): any;
  92991. /**
  92992. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  92993. * @param parsedFresnelParameters Define the JSON representation
  92994. * @returns the parsed parameters
  92995. */
  92996. static Parse(parsedFresnelParameters: any): FresnelParameters;
  92997. }
  92998. }
  92999. declare module BABYLON {
  93000. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  93001. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93002. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93003. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93004. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93005. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93006. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93007. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93008. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93009. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93010. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93011. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93012. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93013. /**
  93014. * Decorator used to define property that can be serialized as reference to a camera
  93015. * @param sourceName defines the name of the property to decorate
  93016. */
  93017. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  93018. /**
  93019. * Class used to help serialization objects
  93020. */
  93021. export class SerializationHelper {
  93022. /** @hidden */
  93023. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  93024. /** @hidden */
  93025. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  93026. /** @hidden */
  93027. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  93028. /** @hidden */
  93029. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  93030. /**
  93031. * Appends the serialized animations from the source animations
  93032. * @param source Source containing the animations
  93033. * @param destination Target to store the animations
  93034. */
  93035. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  93036. /**
  93037. * Static function used to serialized a specific entity
  93038. * @param entity defines the entity to serialize
  93039. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  93040. * @returns a JSON compatible object representing the serialization of the entity
  93041. */
  93042. static Serialize<T>(entity: T, serializationObject?: any): any;
  93043. /**
  93044. * Creates a new entity from a serialization data object
  93045. * @param creationFunction defines a function used to instanciated the new entity
  93046. * @param source defines the source serialization data
  93047. * @param scene defines the hosting scene
  93048. * @param rootUrl defines the root url for resources
  93049. * @returns a new entity
  93050. */
  93051. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  93052. /**
  93053. * Clones an object
  93054. * @param creationFunction defines the function used to instanciate the new object
  93055. * @param source defines the source object
  93056. * @returns the cloned object
  93057. */
  93058. static Clone<T>(creationFunction: () => T, source: T): T;
  93059. /**
  93060. * Instanciates a new object based on a source one (some data will be shared between both object)
  93061. * @param creationFunction defines the function used to instanciate the new object
  93062. * @param source defines the source object
  93063. * @returns the new object
  93064. */
  93065. static Instanciate<T>(creationFunction: () => T, source: T): T;
  93066. }
  93067. }
  93068. declare module BABYLON {
  93069. /**
  93070. * This is the base class of all the camera used in the application.
  93071. * @see http://doc.babylonjs.com/features/cameras
  93072. */
  93073. export class Camera extends Node {
  93074. /** @hidden */
  93075. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  93076. /**
  93077. * This is the default projection mode used by the cameras.
  93078. * It helps recreating a feeling of perspective and better appreciate depth.
  93079. * This is the best way to simulate real life cameras.
  93080. */
  93081. static readonly PERSPECTIVE_CAMERA: number;
  93082. /**
  93083. * This helps creating camera with an orthographic mode.
  93084. * 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.
  93085. */
  93086. static readonly ORTHOGRAPHIC_CAMERA: number;
  93087. /**
  93088. * This is the default FOV mode for perspective cameras.
  93089. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  93090. */
  93091. static readonly FOVMODE_VERTICAL_FIXED: number;
  93092. /**
  93093. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  93094. */
  93095. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  93096. /**
  93097. * This specifies ther is no need for a camera rig.
  93098. * Basically only one eye is rendered corresponding to the camera.
  93099. */
  93100. static readonly RIG_MODE_NONE: number;
  93101. /**
  93102. * Simulates a camera Rig with one blue eye and one red eye.
  93103. * This can be use with 3d blue and red glasses.
  93104. */
  93105. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  93106. /**
  93107. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  93108. */
  93109. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  93110. /**
  93111. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  93112. */
  93113. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  93114. /**
  93115. * Defines that both eyes of the camera will be rendered over under each other.
  93116. */
  93117. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  93118. /**
  93119. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  93120. */
  93121. static readonly RIG_MODE_VR: number;
  93122. /**
  93123. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  93124. */
  93125. static readonly RIG_MODE_WEBVR: number;
  93126. /**
  93127. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  93128. */
  93129. static readonly RIG_MODE_CUSTOM: number;
  93130. /**
  93131. * Defines if by default attaching controls should prevent the default javascript event to continue.
  93132. */
  93133. static ForceAttachControlToAlwaysPreventDefault: boolean;
  93134. /**
  93135. * Define the input manager associated with the camera.
  93136. */
  93137. inputs: CameraInputsManager<Camera>;
  93138. /** @hidden */
  93139. _position: Vector3;
  93140. /**
  93141. * Define the current local position of the camera in the scene
  93142. */
  93143. position: Vector3;
  93144. /**
  93145. * The vector the camera should consider as up.
  93146. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  93147. */
  93148. upVector: Vector3;
  93149. /**
  93150. * Define the current limit on the left side for an orthographic camera
  93151. * In scene unit
  93152. */
  93153. orthoLeft: Nullable<number>;
  93154. /**
  93155. * Define the current limit on the right side for an orthographic camera
  93156. * In scene unit
  93157. */
  93158. orthoRight: Nullable<number>;
  93159. /**
  93160. * Define the current limit on the bottom side for an orthographic camera
  93161. * In scene unit
  93162. */
  93163. orthoBottom: Nullable<number>;
  93164. /**
  93165. * Define the current limit on the top side for an orthographic camera
  93166. * In scene unit
  93167. */
  93168. orthoTop: Nullable<number>;
  93169. /**
  93170. * Field Of View is set in Radians. (default is 0.8)
  93171. */
  93172. fov: number;
  93173. /**
  93174. * Define the minimum distance the camera can see from.
  93175. * This is important to note that the depth buffer are not infinite and the closer it starts
  93176. * the more your scene might encounter depth fighting issue.
  93177. */
  93178. minZ: number;
  93179. /**
  93180. * Define the maximum distance the camera can see to.
  93181. * This is important to note that the depth buffer are not infinite and the further it end
  93182. * the more your scene might encounter depth fighting issue.
  93183. */
  93184. maxZ: number;
  93185. /**
  93186. * Define the default inertia of the camera.
  93187. * This helps giving a smooth feeling to the camera movement.
  93188. */
  93189. inertia: number;
  93190. /**
  93191. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  93192. */
  93193. mode: number;
  93194. /**
  93195. * Define wether the camera is intermediate.
  93196. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  93197. */
  93198. isIntermediate: boolean;
  93199. /**
  93200. * Define the viewport of the camera.
  93201. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  93202. */
  93203. viewport: Viewport;
  93204. /**
  93205. * Restricts the camera to viewing objects with the same layerMask.
  93206. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  93207. */
  93208. layerMask: number;
  93209. /**
  93210. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  93211. */
  93212. fovMode: number;
  93213. /**
  93214. * Rig mode of the camera.
  93215. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  93216. * This is normally controlled byt the camera themselves as internal use.
  93217. */
  93218. cameraRigMode: number;
  93219. /**
  93220. * Defines the distance between both "eyes" in case of a RIG
  93221. */
  93222. interaxialDistance: number;
  93223. /**
  93224. * Defines if stereoscopic rendering is done side by side or over under.
  93225. */
  93226. isStereoscopicSideBySide: boolean;
  93227. /**
  93228. * 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
  93229. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  93230. * else in the scene.
  93231. */
  93232. customRenderTargets: RenderTargetTexture[];
  93233. /**
  93234. * When set, the camera will render to this render target instead of the default canvas
  93235. */
  93236. outputRenderTarget: Nullable<RenderTargetTexture>;
  93237. /**
  93238. * Observable triggered when the camera view matrix has changed.
  93239. */
  93240. onViewMatrixChangedObservable: Observable<Camera>;
  93241. /**
  93242. * Observable triggered when the camera Projection matrix has changed.
  93243. */
  93244. onProjectionMatrixChangedObservable: Observable<Camera>;
  93245. /**
  93246. * Observable triggered when the inputs have been processed.
  93247. */
  93248. onAfterCheckInputsObservable: Observable<Camera>;
  93249. /**
  93250. * Observable triggered when reset has been called and applied to the camera.
  93251. */
  93252. onRestoreStateObservable: Observable<Camera>;
  93253. /** @hidden */
  93254. _cameraRigParams: any;
  93255. /** @hidden */
  93256. _rigCameras: Camera[];
  93257. /** @hidden */
  93258. _rigPostProcess: Nullable<PostProcess>;
  93259. protected _webvrViewMatrix: Matrix;
  93260. /** @hidden */
  93261. _skipRendering: boolean;
  93262. /** @hidden */
  93263. _projectionMatrix: Matrix;
  93264. /** @hidden */
  93265. _postProcesses: Nullable<PostProcess>[];
  93266. /** @hidden */
  93267. _activeMeshes: SmartArray<AbstractMesh>;
  93268. protected _globalPosition: Vector3;
  93269. /** @hidden */
  93270. _computedViewMatrix: Matrix;
  93271. private _doNotComputeProjectionMatrix;
  93272. private _transformMatrix;
  93273. private _frustumPlanes;
  93274. private _refreshFrustumPlanes;
  93275. private _storedFov;
  93276. private _stateStored;
  93277. /**
  93278. * Instantiates a new camera object.
  93279. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  93280. * @see http://doc.babylonjs.com/features/cameras
  93281. * @param name Defines the name of the camera in the scene
  93282. * @param position Defines the position of the camera
  93283. * @param scene Defines the scene the camera belongs too
  93284. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  93285. */
  93286. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  93287. /**
  93288. * Store current camera state (fov, position, etc..)
  93289. * @returns the camera
  93290. */
  93291. storeState(): Camera;
  93292. /**
  93293. * Restores the camera state values if it has been stored. You must call storeState() first
  93294. */
  93295. protected _restoreStateValues(): boolean;
  93296. /**
  93297. * Restored camera state. You must call storeState() first.
  93298. * @returns true if restored and false otherwise
  93299. */
  93300. restoreState(): boolean;
  93301. /**
  93302. * Gets the class name of the camera.
  93303. * @returns the class name
  93304. */
  93305. getClassName(): string;
  93306. /** @hidden */
  93307. readonly _isCamera: boolean;
  93308. /**
  93309. * Gets a string representation of the camera useful for debug purpose.
  93310. * @param fullDetails Defines that a more verboe level of logging is required
  93311. * @returns the string representation
  93312. */
  93313. toString(fullDetails?: boolean): string;
  93314. /**
  93315. * Gets the current world space position of the camera.
  93316. */
  93317. readonly globalPosition: Vector3;
  93318. /**
  93319. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  93320. * @returns the active meshe list
  93321. */
  93322. getActiveMeshes(): SmartArray<AbstractMesh>;
  93323. /**
  93324. * Check wether a mesh is part of the current active mesh list of the camera
  93325. * @param mesh Defines the mesh to check
  93326. * @returns true if active, false otherwise
  93327. */
  93328. isActiveMesh(mesh: Mesh): boolean;
  93329. /**
  93330. * Is this camera ready to be used/rendered
  93331. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  93332. * @return true if the camera is ready
  93333. */
  93334. isReady(completeCheck?: boolean): boolean;
  93335. /** @hidden */
  93336. _initCache(): void;
  93337. /** @hidden */
  93338. _updateCache(ignoreParentClass?: boolean): void;
  93339. /** @hidden */
  93340. _isSynchronized(): boolean;
  93341. /** @hidden */
  93342. _isSynchronizedViewMatrix(): boolean;
  93343. /** @hidden */
  93344. _isSynchronizedProjectionMatrix(): boolean;
  93345. /**
  93346. * Attach the input controls to a specific dom element to get the input from.
  93347. * @param element Defines the element the controls should be listened from
  93348. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  93349. */
  93350. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93351. /**
  93352. * Detach the current controls from the specified dom element.
  93353. * @param element Defines the element to stop listening the inputs from
  93354. */
  93355. detachControl(element: HTMLElement): void;
  93356. /**
  93357. * Update the camera state according to the different inputs gathered during the frame.
  93358. */
  93359. update(): void;
  93360. /** @hidden */
  93361. _checkInputs(): void;
  93362. /** @hidden */
  93363. readonly rigCameras: Camera[];
  93364. /**
  93365. * Gets the post process used by the rig cameras
  93366. */
  93367. readonly rigPostProcess: Nullable<PostProcess>;
  93368. /**
  93369. * Internal, gets the first post proces.
  93370. * @returns the first post process to be run on this camera.
  93371. */
  93372. _getFirstPostProcess(): Nullable<PostProcess>;
  93373. private _cascadePostProcessesToRigCams;
  93374. /**
  93375. * Attach a post process to the camera.
  93376. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93377. * @param postProcess The post process to attach to the camera
  93378. * @param insertAt The position of the post process in case several of them are in use in the scene
  93379. * @returns the position the post process has been inserted at
  93380. */
  93381. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  93382. /**
  93383. * Detach a post process to the camera.
  93384. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  93385. * @param postProcess The post process to detach from the camera
  93386. */
  93387. detachPostProcess(postProcess: PostProcess): void;
  93388. /**
  93389. * Gets the current world matrix of the camera
  93390. */
  93391. getWorldMatrix(): Matrix;
  93392. /** @hidden */
  93393. _getViewMatrix(): Matrix;
  93394. /**
  93395. * Gets the current view matrix of the camera.
  93396. * @param force forces the camera to recompute the matrix without looking at the cached state
  93397. * @returns the view matrix
  93398. */
  93399. getViewMatrix(force?: boolean): Matrix;
  93400. /**
  93401. * Freeze the projection matrix.
  93402. * It will prevent the cache check of the camera projection compute and can speed up perf
  93403. * if no parameter of the camera are meant to change
  93404. * @param projection Defines manually a projection if necessary
  93405. */
  93406. freezeProjectionMatrix(projection?: Matrix): void;
  93407. /**
  93408. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  93409. */
  93410. unfreezeProjectionMatrix(): void;
  93411. /**
  93412. * Gets the current projection matrix of the camera.
  93413. * @param force forces the camera to recompute the matrix without looking at the cached state
  93414. * @returns the projection matrix
  93415. */
  93416. getProjectionMatrix(force?: boolean): Matrix;
  93417. /**
  93418. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  93419. * @returns a Matrix
  93420. */
  93421. getTransformationMatrix(): Matrix;
  93422. private _updateFrustumPlanes;
  93423. /**
  93424. * Checks if a cullable object (mesh...) is in the camera frustum
  93425. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  93426. * @param target The object to check
  93427. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  93428. * @returns true if the object is in frustum otherwise false
  93429. */
  93430. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  93431. /**
  93432. * Checks if a cullable object (mesh...) is in the camera frustum
  93433. * Unlike isInFrustum this cheks the full bounding box
  93434. * @param target The object to check
  93435. * @returns true if the object is in frustum otherwise false
  93436. */
  93437. isCompletelyInFrustum(target: ICullable): boolean;
  93438. /**
  93439. * Gets a ray in the forward direction from the camera.
  93440. * @param length Defines the length of the ray to create
  93441. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  93442. * @param origin Defines the start point of the ray which defaults to the camera position
  93443. * @returns the forward ray
  93444. */
  93445. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  93446. /**
  93447. * Releases resources associated with this node.
  93448. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93449. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93450. */
  93451. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93452. /** @hidden */
  93453. _isLeftCamera: boolean;
  93454. /**
  93455. * Gets the left camera of a rig setup in case of Rigged Camera
  93456. */
  93457. readonly isLeftCamera: boolean;
  93458. /** @hidden */
  93459. _isRightCamera: boolean;
  93460. /**
  93461. * Gets the right camera of a rig setup in case of Rigged Camera
  93462. */
  93463. readonly isRightCamera: boolean;
  93464. /**
  93465. * Gets the left camera of a rig setup in case of Rigged Camera
  93466. */
  93467. readonly leftCamera: Nullable<FreeCamera>;
  93468. /**
  93469. * Gets the right camera of a rig setup in case of Rigged Camera
  93470. */
  93471. readonly rightCamera: Nullable<FreeCamera>;
  93472. /**
  93473. * Gets the left camera target of a rig setup in case of Rigged Camera
  93474. * @returns the target position
  93475. */
  93476. getLeftTarget(): Nullable<Vector3>;
  93477. /**
  93478. * Gets the right camera target of a rig setup in case of Rigged Camera
  93479. * @returns the target position
  93480. */
  93481. getRightTarget(): Nullable<Vector3>;
  93482. /**
  93483. * @hidden
  93484. */
  93485. setCameraRigMode(mode: number, rigParams: any): void;
  93486. /** @hidden */
  93487. static _setStereoscopicRigMode(camera: Camera): void;
  93488. /** @hidden */
  93489. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  93490. /** @hidden */
  93491. static _setVRRigMode(camera: Camera, rigParams: any): void;
  93492. /** @hidden */
  93493. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  93494. /** @hidden */
  93495. _getVRProjectionMatrix(): Matrix;
  93496. protected _updateCameraRotationMatrix(): void;
  93497. protected _updateWebVRCameraRotationMatrix(): void;
  93498. /**
  93499. * This function MUST be overwritten by the different WebVR cameras available.
  93500. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93501. * @hidden
  93502. */
  93503. _getWebVRProjectionMatrix(): Matrix;
  93504. /**
  93505. * This function MUST be overwritten by the different WebVR cameras available.
  93506. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  93507. * @hidden
  93508. */
  93509. _getWebVRViewMatrix(): Matrix;
  93510. /** @hidden */
  93511. setCameraRigParameter(name: string, value: any): void;
  93512. /**
  93513. * needs to be overridden by children so sub has required properties to be copied
  93514. * @hidden
  93515. */
  93516. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  93517. /**
  93518. * May need to be overridden by children
  93519. * @hidden
  93520. */
  93521. _updateRigCameras(): void;
  93522. /** @hidden */
  93523. _setupInputs(): void;
  93524. /**
  93525. * Serialiaze the camera setup to a json represention
  93526. * @returns the JSON representation
  93527. */
  93528. serialize(): any;
  93529. /**
  93530. * Clones the current camera.
  93531. * @param name The cloned camera name
  93532. * @returns the cloned camera
  93533. */
  93534. clone(name: string): Camera;
  93535. /**
  93536. * Gets the direction of the camera relative to a given local axis.
  93537. * @param localAxis Defines the reference axis to provide a relative direction.
  93538. * @return the direction
  93539. */
  93540. getDirection(localAxis: Vector3): Vector3;
  93541. /**
  93542. * Gets the direction of the camera relative to a given local axis into a passed vector.
  93543. * @param localAxis Defines the reference axis to provide a relative direction.
  93544. * @param result Defines the vector to store the result in
  93545. */
  93546. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  93547. /**
  93548. * Gets a camera constructor for a given camera type
  93549. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  93550. * @param name The name of the camera the result will be able to instantiate
  93551. * @param scene The scene the result will construct the camera in
  93552. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  93553. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  93554. * @returns a factory method to construc the camera
  93555. */
  93556. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  93557. /**
  93558. * Compute the world matrix of the camera.
  93559. * @returns the camera workd matrix
  93560. */
  93561. computeWorldMatrix(): Matrix;
  93562. /**
  93563. * Parse a JSON and creates the camera from the parsed information
  93564. * @param parsedCamera The JSON to parse
  93565. * @param scene The scene to instantiate the camera in
  93566. * @returns the newly constructed camera
  93567. */
  93568. static Parse(parsedCamera: any, scene: Scene): Camera;
  93569. }
  93570. }
  93571. declare module BABYLON {
  93572. /**
  93573. * Interface for any object that can request an animation frame
  93574. */
  93575. export interface ICustomAnimationFrameRequester {
  93576. /**
  93577. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  93578. */
  93579. renderFunction?: Function;
  93580. /**
  93581. * Called to request the next frame to render to
  93582. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  93583. */
  93584. requestAnimationFrame: Function;
  93585. /**
  93586. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  93587. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  93588. */
  93589. requestID?: number;
  93590. }
  93591. /**
  93592. * Interface containing an array of animations
  93593. */
  93594. export interface IAnimatable {
  93595. /**
  93596. * Array of animations
  93597. */
  93598. animations: Nullable<Array<Animation>>;
  93599. }
  93600. /** Interface used by value gradients (color, factor, ...) */
  93601. export interface IValueGradient {
  93602. /**
  93603. * Gets or sets the gradient value (between 0 and 1)
  93604. */
  93605. gradient: number;
  93606. }
  93607. /** Class used to store color4 gradient */
  93608. export class ColorGradient implements IValueGradient {
  93609. /**
  93610. * Gets or sets the gradient value (between 0 and 1)
  93611. */
  93612. gradient: number;
  93613. /**
  93614. * Gets or sets first associated color
  93615. */
  93616. color1: Color4;
  93617. /**
  93618. * Gets or sets second associated color
  93619. */
  93620. color2?: Color4;
  93621. /**
  93622. * Will get a color picked randomly between color1 and color2.
  93623. * If color2 is undefined then color1 will be used
  93624. * @param result defines the target Color4 to store the result in
  93625. */
  93626. getColorToRef(result: Color4): void;
  93627. }
  93628. /** Class used to store color 3 gradient */
  93629. export class Color3Gradient implements IValueGradient {
  93630. /**
  93631. * Gets or sets the gradient value (between 0 and 1)
  93632. */
  93633. gradient: number;
  93634. /**
  93635. * Gets or sets the associated color
  93636. */
  93637. color: Color3;
  93638. }
  93639. /** Class used to store factor gradient */
  93640. export class FactorGradient implements IValueGradient {
  93641. /**
  93642. * Gets or sets the gradient value (between 0 and 1)
  93643. */
  93644. gradient: number;
  93645. /**
  93646. * Gets or sets first associated factor
  93647. */
  93648. factor1: number;
  93649. /**
  93650. * Gets or sets second associated factor
  93651. */
  93652. factor2?: number;
  93653. /**
  93654. * Will get a number picked randomly between factor1 and factor2.
  93655. * If factor2 is undefined then factor1 will be used
  93656. * @returns the picked number
  93657. */
  93658. getFactor(): number;
  93659. }
  93660. /**
  93661. * @ignore
  93662. * Application error to support additional information when loading a file
  93663. */
  93664. export class LoadFileError extends Error {
  93665. /** defines the optional web request */
  93666. request?: WebRequest | undefined;
  93667. private static _setPrototypeOf;
  93668. /**
  93669. * Creates a new LoadFileError
  93670. * @param message defines the message of the error
  93671. * @param request defines the optional web request
  93672. */
  93673. constructor(message: string,
  93674. /** defines the optional web request */
  93675. request?: WebRequest | undefined);
  93676. }
  93677. /**
  93678. * Class used to define a retry strategy when error happens while loading assets
  93679. */
  93680. export class RetryStrategy {
  93681. /**
  93682. * Function used to defines an exponential back off strategy
  93683. * @param maxRetries defines the maximum number of retries (3 by default)
  93684. * @param baseInterval defines the interval between retries
  93685. * @returns the strategy function to use
  93686. */
  93687. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  93688. }
  93689. /**
  93690. * File request interface
  93691. */
  93692. export interface IFileRequest {
  93693. /**
  93694. * Raised when the request is complete (success or error).
  93695. */
  93696. onCompleteObservable: Observable<IFileRequest>;
  93697. /**
  93698. * Aborts the request for a file.
  93699. */
  93700. abort: () => void;
  93701. }
  93702. /**
  93703. * Class containing a set of static utilities functions
  93704. */
  93705. export class Tools {
  93706. /**
  93707. * Gets or sets the base URL to use to load assets
  93708. */
  93709. static BaseUrl: string;
  93710. /**
  93711. * Enable/Disable Custom HTTP Request Headers globally.
  93712. * default = false
  93713. * @see CustomRequestHeaders
  93714. */
  93715. static UseCustomRequestHeaders: boolean;
  93716. /**
  93717. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  93718. * i.e. when loading files, where the server/service expects an Authorization header
  93719. */
  93720. static CustomRequestHeaders: {
  93721. [key: string]: string;
  93722. };
  93723. /**
  93724. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  93725. */
  93726. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  93727. /**
  93728. * Default behaviour for cors in the application.
  93729. * It can be a string if the expected behavior is identical in the entire app.
  93730. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  93731. */
  93732. static CorsBehavior: string | ((url: string | string[]) => string);
  93733. /**
  93734. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  93735. * @ignorenaming
  93736. */
  93737. static UseFallbackTexture: boolean;
  93738. /**
  93739. * Use this object to register external classes like custom textures or material
  93740. * to allow the laoders to instantiate them
  93741. */
  93742. static RegisteredExternalClasses: {
  93743. [key: string]: Object;
  93744. };
  93745. /**
  93746. * Texture content used if a texture cannot loaded
  93747. * @ignorenaming
  93748. */
  93749. static fallbackTexture: string;
  93750. /**
  93751. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  93752. * @param u defines the coordinate on X axis
  93753. * @param v defines the coordinate on Y axis
  93754. * @param width defines the width of the source data
  93755. * @param height defines the height of the source data
  93756. * @param pixels defines the source byte array
  93757. * @param color defines the output color
  93758. */
  93759. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  93760. /**
  93761. * Interpolates between a and b via alpha
  93762. * @param a The lower value (returned when alpha = 0)
  93763. * @param b The upper value (returned when alpha = 1)
  93764. * @param alpha The interpolation-factor
  93765. * @return The mixed value
  93766. */
  93767. static Mix(a: number, b: number, alpha: number): number;
  93768. /**
  93769. * Tries to instantiate a new object from a given class name
  93770. * @param className defines the class name to instantiate
  93771. * @returns the new object or null if the system was not able to do the instantiation
  93772. */
  93773. static Instantiate(className: string): any;
  93774. /**
  93775. * Provides a slice function that will work even on IE
  93776. * @param data defines the array to slice
  93777. * @param start defines the start of the data (optional)
  93778. * @param end defines the end of the data (optional)
  93779. * @returns the new sliced array
  93780. */
  93781. static Slice<T>(data: T, start?: number, end?: number): T;
  93782. /**
  93783. * Polyfill for setImmediate
  93784. * @param action defines the action to execute after the current execution block
  93785. */
  93786. static SetImmediate(action: () => void): void;
  93787. /**
  93788. * Function indicating if a number is an exponent of 2
  93789. * @param value defines the value to test
  93790. * @returns true if the value is an exponent of 2
  93791. */
  93792. static IsExponentOfTwo(value: number): boolean;
  93793. private static _tmpFloatArray;
  93794. /**
  93795. * Returns the nearest 32-bit single precision float representation of a Number
  93796. * @param value A Number. If the parameter is of a different type, it will get converted
  93797. * to a number or to NaN if it cannot be converted
  93798. * @returns number
  93799. */
  93800. static FloatRound(value: number): number;
  93801. /**
  93802. * Find the next highest power of two.
  93803. * @param x Number to start search from.
  93804. * @return Next highest power of two.
  93805. */
  93806. static CeilingPOT(x: number): number;
  93807. /**
  93808. * Find the next lowest power of two.
  93809. * @param x Number to start search from.
  93810. * @return Next lowest power of two.
  93811. */
  93812. static FloorPOT(x: number): number;
  93813. /**
  93814. * Find the nearest power of two.
  93815. * @param x Number to start search from.
  93816. * @return Next nearest power of two.
  93817. */
  93818. static NearestPOT(x: number): number;
  93819. /**
  93820. * Get the closest exponent of two
  93821. * @param value defines the value to approximate
  93822. * @param max defines the maximum value to return
  93823. * @param mode defines how to define the closest value
  93824. * @returns closest exponent of two of the given value
  93825. */
  93826. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  93827. /**
  93828. * Extracts the filename from a path
  93829. * @param path defines the path to use
  93830. * @returns the filename
  93831. */
  93832. static GetFilename(path: string): string;
  93833. /**
  93834. * Extracts the "folder" part of a path (everything before the filename).
  93835. * @param uri The URI to extract the info from
  93836. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  93837. * @returns The "folder" part of the path
  93838. */
  93839. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  93840. /**
  93841. * Extracts text content from a DOM element hierarchy
  93842. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  93843. */
  93844. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  93845. /**
  93846. * Convert an angle in radians to degrees
  93847. * @param angle defines the angle to convert
  93848. * @returns the angle in degrees
  93849. */
  93850. static ToDegrees(angle: number): number;
  93851. /**
  93852. * Convert an angle in degrees to radians
  93853. * @param angle defines the angle to convert
  93854. * @returns the angle in radians
  93855. */
  93856. static ToRadians(angle: number): number;
  93857. /**
  93858. * Encode a buffer to a base64 string
  93859. * @param buffer defines the buffer to encode
  93860. * @returns the encoded string
  93861. */
  93862. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  93863. /**
  93864. * Extracts minimum and maximum values from a list of indexed positions
  93865. * @param positions defines the positions to use
  93866. * @param indices defines the indices to the positions
  93867. * @param indexStart defines the start index
  93868. * @param indexCount defines the end index
  93869. * @param bias defines bias value to add to the result
  93870. * @return minimum and maximum values
  93871. */
  93872. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  93873. minimum: Vector3;
  93874. maximum: Vector3;
  93875. };
  93876. /**
  93877. * Extracts minimum and maximum values from a list of positions
  93878. * @param positions defines the positions to use
  93879. * @param start defines the start index in the positions array
  93880. * @param count defines the number of positions to handle
  93881. * @param bias defines bias value to add to the result
  93882. * @param stride defines the stride size to use (distance between two positions in the positions array)
  93883. * @return minimum and maximum values
  93884. */
  93885. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  93886. minimum: Vector3;
  93887. maximum: Vector3;
  93888. };
  93889. /**
  93890. * Returns an array if obj is not an array
  93891. * @param obj defines the object to evaluate as an array
  93892. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  93893. * @returns either obj directly if obj is an array or a new array containing obj
  93894. */
  93895. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  93896. /**
  93897. * Gets the pointer prefix to use
  93898. * @returns "pointer" if touch is enabled. Else returns "mouse"
  93899. */
  93900. static GetPointerPrefix(): string;
  93901. /**
  93902. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  93903. * @param func - the function to be called
  93904. * @param requester - the object that will request the next frame. Falls back to window.
  93905. * @returns frame number
  93906. */
  93907. static QueueNewFrame(func: () => void, requester?: any): number;
  93908. /**
  93909. * Ask the browser to promote the current element to fullscreen rendering mode
  93910. * @param element defines the DOM element to promote
  93911. */
  93912. static RequestFullscreen(element: HTMLElement): void;
  93913. /**
  93914. * Asks the browser to exit fullscreen mode
  93915. */
  93916. static ExitFullscreen(): void;
  93917. /**
  93918. * Ask the browser to promote the current element to pointerlock mode
  93919. * @param element defines the DOM element to promote
  93920. */
  93921. static RequestPointerlock(element: HTMLElement): void;
  93922. /**
  93923. * Asks the browser to exit pointerlock mode
  93924. */
  93925. static ExitPointerlock(): void;
  93926. /**
  93927. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  93928. * @param url define the url we are trying
  93929. * @param element define the dom element where to configure the cors policy
  93930. */
  93931. static SetCorsBehavior(url: string | string[], element: {
  93932. crossOrigin: string | null;
  93933. }): void;
  93934. /**
  93935. * Removes unwanted characters from an url
  93936. * @param url defines the url to clean
  93937. * @returns the cleaned url
  93938. */
  93939. static CleanUrl(url: string): string;
  93940. /**
  93941. * Gets or sets a function used to pre-process url before using them to load assets
  93942. */
  93943. static PreprocessUrl: (url: string) => string;
  93944. /**
  93945. * Loads an image as an HTMLImageElement.
  93946. * @param input url string, ArrayBuffer, or Blob to load
  93947. * @param onLoad callback called when the image successfully loads
  93948. * @param onError callback called when the image fails to load
  93949. * @param offlineProvider offline provider for caching
  93950. * @returns the HTMLImageElement of the loaded image
  93951. */
  93952. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  93953. /**
  93954. * Loads a file
  93955. * @param url url string, ArrayBuffer, or Blob to load
  93956. * @param onSuccess callback called when the file successfully loads
  93957. * @param onProgress callback called while file is loading (if the server supports this mode)
  93958. * @param offlineProvider defines the offline provider for caching
  93959. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  93960. * @param onError callback called when the file fails to load
  93961. * @returns a file request object
  93962. */
  93963. 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;
  93964. /**
  93965. * Loads a file from a url
  93966. * @param url the file url to load
  93967. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  93968. */
  93969. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  93970. /**
  93971. * Load a script (identified by an url). When the url returns, the
  93972. * content of this file is added into a new script element, attached to the DOM (body element)
  93973. * @param scriptUrl defines the url of the script to laod
  93974. * @param onSuccess defines the callback called when the script is loaded
  93975. * @param onError defines the callback to call if an error occurs
  93976. * @param scriptId defines the id of the script element
  93977. */
  93978. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  93979. /**
  93980. * Load an asynchronous script (identified by an url). When the url returns, the
  93981. * content of this file is added into a new script element, attached to the DOM (body element)
  93982. * @param scriptUrl defines the url of the script to laod
  93983. * @param scriptId defines the id of the script element
  93984. * @returns a promise request object
  93985. */
  93986. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  93987. /**
  93988. * Loads a file from a blob
  93989. * @param fileToLoad defines the blob to use
  93990. * @param callback defines the callback to call when data is loaded
  93991. * @param progressCallback defines the callback to call during loading process
  93992. * @returns a file request object
  93993. */
  93994. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  93995. /**
  93996. * Loads a file
  93997. * @param fileToLoad defines the file to load
  93998. * @param callback defines the callback to call when data is loaded
  93999. * @param progressCallBack defines the callback to call during loading process
  94000. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  94001. * @returns a file request object
  94002. */
  94003. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  94004. /**
  94005. * Creates a data url from a given string content
  94006. * @param content defines the content to convert
  94007. * @returns the new data url link
  94008. */
  94009. static FileAsURL(content: string): string;
  94010. /**
  94011. * Format the given number to a specific decimal format
  94012. * @param value defines the number to format
  94013. * @param decimals defines the number of decimals to use
  94014. * @returns the formatted string
  94015. */
  94016. static Format(value: number, decimals?: number): string;
  94017. /**
  94018. * Checks if a given vector is inside a specific range
  94019. * @param v defines the vector to test
  94020. * @param min defines the minimum range
  94021. * @param max defines the maximum range
  94022. */
  94023. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  94024. /**
  94025. * Tries to copy an object by duplicating every property
  94026. * @param source defines the source object
  94027. * @param destination defines the target object
  94028. * @param doNotCopyList defines a list of properties to avoid
  94029. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  94030. */
  94031. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  94032. /**
  94033. * Gets a boolean indicating if the given object has no own property
  94034. * @param obj defines the object to test
  94035. * @returns true if object has no own property
  94036. */
  94037. static IsEmpty(obj: any): boolean;
  94038. /**
  94039. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  94040. * @param str Source string
  94041. * @param suffix Suffix to search for in the source string
  94042. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  94043. */
  94044. static EndsWith(str: string, suffix: string): boolean;
  94045. /**
  94046. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  94047. * @param str Source string
  94048. * @param suffix Suffix to search for in the source string
  94049. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  94050. */
  94051. static StartsWith(str: string, suffix: string): boolean;
  94052. /**
  94053. * Function used to register events at window level
  94054. * @param events defines the events to register
  94055. */
  94056. static RegisterTopRootEvents(events: {
  94057. name: string;
  94058. handler: Nullable<(e: FocusEvent) => any>;
  94059. }[]): void;
  94060. /**
  94061. * Function used to unregister events from window level
  94062. * @param events defines the events to unregister
  94063. */
  94064. static UnregisterTopRootEvents(events: {
  94065. name: string;
  94066. handler: Nullable<(e: FocusEvent) => any>;
  94067. }[]): void;
  94068. /**
  94069. * @ignore
  94070. */
  94071. static _ScreenshotCanvas: HTMLCanvasElement;
  94072. /**
  94073. * Dumps the current bound framebuffer
  94074. * @param width defines the rendering width
  94075. * @param height defines the rendering height
  94076. * @param engine defines the hosting engine
  94077. * @param successCallback defines the callback triggered once the data are available
  94078. * @param mimeType defines the mime type of the result
  94079. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  94080. */
  94081. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  94082. /**
  94083. * Converts the canvas data to blob.
  94084. * This acts as a polyfill for browsers not supporting the to blob function.
  94085. * @param canvas Defines the canvas to extract the data from
  94086. * @param successCallback Defines the callback triggered once the data are available
  94087. * @param mimeType Defines the mime type of the result
  94088. */
  94089. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  94090. /**
  94091. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  94092. * @param successCallback defines the callback triggered once the data are available
  94093. * @param mimeType defines the mime type of the result
  94094. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  94095. */
  94096. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  94097. /**
  94098. * Downloads a blob in the browser
  94099. * @param blob defines the blob to download
  94100. * @param fileName defines the name of the downloaded file
  94101. */
  94102. static Download(blob: Blob, fileName: string): void;
  94103. /**
  94104. * Captures a screenshot of the current rendering
  94105. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  94106. * @param engine defines the rendering engine
  94107. * @param camera defines the source camera
  94108. * @param size This parameter can be set to a single number or to an object with the
  94109. * following (optional) properties: precision, width, height. If a single number is passed,
  94110. * it will be used for both width and height. If an object is passed, the screenshot size
  94111. * will be derived from the parameters. The precision property is a multiplier allowing
  94112. * rendering at a higher or lower resolution
  94113. * @param successCallback defines the callback receives a single parameter which contains the
  94114. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  94115. * src parameter of an <img> to display it
  94116. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  94117. * Check your browser for supported MIME types
  94118. */
  94119. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  94120. /**
  94121. * Generates an image screenshot from the specified camera.
  94122. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  94123. * @param engine The engine to use for rendering
  94124. * @param camera The camera to use for rendering
  94125. * @param size This parameter can be set to a single number or to an object with the
  94126. * following (optional) properties: precision, width, height. If a single number is passed,
  94127. * it will be used for both width and height. If an object is passed, the screenshot size
  94128. * will be derived from the parameters. The precision property is a multiplier allowing
  94129. * rendering at a higher or lower resolution
  94130. * @param successCallback The callback receives a single parameter which contains the
  94131. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  94132. * src parameter of an <img> to display it
  94133. * @param mimeType The MIME type of the screenshot image (default: image/png).
  94134. * Check your browser for supported MIME types
  94135. * @param samples Texture samples (default: 1)
  94136. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  94137. * @param fileName A name for for the downloaded file.
  94138. */
  94139. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  94140. /**
  94141. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  94142. * Be aware Math.random() could cause collisions, but:
  94143. * "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"
  94144. * @returns a pseudo random id
  94145. */
  94146. static RandomId(): string;
  94147. /**
  94148. * Test if the given uri is a base64 string
  94149. * @param uri The uri to test
  94150. * @return True if the uri is a base64 string or false otherwise
  94151. */
  94152. static IsBase64(uri: string): boolean;
  94153. /**
  94154. * Decode the given base64 uri.
  94155. * @param uri The uri to decode
  94156. * @return The decoded base64 data.
  94157. */
  94158. static DecodeBase64(uri: string): ArrayBuffer;
  94159. /**
  94160. * Gets the absolute url.
  94161. * @param url the input url
  94162. * @return the absolute url
  94163. */
  94164. static GetAbsoluteUrl(url: string): string;
  94165. /**
  94166. * No log
  94167. */
  94168. static readonly NoneLogLevel: number;
  94169. /**
  94170. * Only message logs
  94171. */
  94172. static readonly MessageLogLevel: number;
  94173. /**
  94174. * Only warning logs
  94175. */
  94176. static readonly WarningLogLevel: number;
  94177. /**
  94178. * Only error logs
  94179. */
  94180. static readonly ErrorLogLevel: number;
  94181. /**
  94182. * All logs
  94183. */
  94184. static readonly AllLogLevel: number;
  94185. /**
  94186. * Gets a value indicating the number of loading errors
  94187. * @ignorenaming
  94188. */
  94189. static readonly errorsCount: number;
  94190. /**
  94191. * Callback called when a new log is added
  94192. */
  94193. static OnNewCacheEntry: (entry: string) => void;
  94194. /**
  94195. * Log a message to the console
  94196. * @param message defines the message to log
  94197. */
  94198. static Log(message: string): void;
  94199. /**
  94200. * Write a warning message to the console
  94201. * @param message defines the message to log
  94202. */
  94203. static Warn(message: string): void;
  94204. /**
  94205. * Write an error message to the console
  94206. * @param message defines the message to log
  94207. */
  94208. static Error(message: string): void;
  94209. /**
  94210. * Gets current log cache (list of logs)
  94211. */
  94212. static readonly LogCache: string;
  94213. /**
  94214. * Clears the log cache
  94215. */
  94216. static ClearLogCache(): void;
  94217. /**
  94218. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  94219. */
  94220. static LogLevels: number;
  94221. /**
  94222. * Checks if the loaded document was accessed via `file:`-Protocol.
  94223. * @returns boolean
  94224. */
  94225. static IsFileURL(): boolean;
  94226. /**
  94227. * Checks if the window object exists
  94228. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  94229. */
  94230. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  94231. /**
  94232. * No performance log
  94233. */
  94234. static readonly PerformanceNoneLogLevel: number;
  94235. /**
  94236. * Use user marks to log performance
  94237. */
  94238. static readonly PerformanceUserMarkLogLevel: number;
  94239. /**
  94240. * Log performance to the console
  94241. */
  94242. static readonly PerformanceConsoleLogLevel: number;
  94243. private static _performance;
  94244. /**
  94245. * Sets the current performance log level
  94246. */
  94247. static PerformanceLogLevel: number;
  94248. private static _StartPerformanceCounterDisabled;
  94249. private static _EndPerformanceCounterDisabled;
  94250. private static _StartUserMark;
  94251. private static _EndUserMark;
  94252. private static _StartPerformanceConsole;
  94253. private static _EndPerformanceConsole;
  94254. /**
  94255. * Starts a performance counter
  94256. */
  94257. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  94258. /**
  94259. * Ends a specific performance coutner
  94260. */
  94261. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  94262. /**
  94263. * Gets either window.performance.now() if supported or Date.now() else
  94264. */
  94265. static readonly Now: number;
  94266. /**
  94267. * This method will return the name of the class used to create the instance of the given object.
  94268. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  94269. * @param object the object to get the class name from
  94270. * @param isType defines if the object is actually a type
  94271. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  94272. */
  94273. static GetClassName(object: any, isType?: boolean): string;
  94274. /**
  94275. * Gets the first element of an array satisfying a given predicate
  94276. * @param array defines the array to browse
  94277. * @param predicate defines the predicate to use
  94278. * @returns null if not found or the element
  94279. */
  94280. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  94281. /**
  94282. * This method will return the name of the full name of the class, including its owning module (if any).
  94283. * 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).
  94284. * @param object the object to get the class name from
  94285. * @param isType defines if the object is actually a type
  94286. * @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.
  94287. * @ignorenaming
  94288. */
  94289. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  94290. /**
  94291. * Returns a promise that resolves after the given amount of time.
  94292. * @param delay Number of milliseconds to delay
  94293. * @returns Promise that resolves after the given amount of time
  94294. */
  94295. static DelayAsync(delay: number): Promise<void>;
  94296. /**
  94297. * Gets the current gradient from an array of IValueGradient
  94298. * @param ratio defines the current ratio to get
  94299. * @param gradients defines the array of IValueGradient
  94300. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  94301. */
  94302. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  94303. }
  94304. /**
  94305. * This class is used to track a performance counter which is number based.
  94306. * The user has access to many properties which give statistics of different nature.
  94307. *
  94308. * The implementer can track two kinds of Performance Counter: time and count.
  94309. * 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.
  94310. * 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.
  94311. */
  94312. export class PerfCounter {
  94313. /**
  94314. * Gets or sets a global boolean to turn on and off all the counters
  94315. */
  94316. static Enabled: boolean;
  94317. /**
  94318. * Returns the smallest value ever
  94319. */
  94320. readonly min: number;
  94321. /**
  94322. * Returns the biggest value ever
  94323. */
  94324. readonly max: number;
  94325. /**
  94326. * Returns the average value since the performance counter is running
  94327. */
  94328. readonly average: number;
  94329. /**
  94330. * Returns the average value of the last second the counter was monitored
  94331. */
  94332. readonly lastSecAverage: number;
  94333. /**
  94334. * Returns the current value
  94335. */
  94336. readonly current: number;
  94337. /**
  94338. * Gets the accumulated total
  94339. */
  94340. readonly total: number;
  94341. /**
  94342. * Gets the total value count
  94343. */
  94344. readonly count: number;
  94345. /**
  94346. * Creates a new counter
  94347. */
  94348. constructor();
  94349. /**
  94350. * Call this method to start monitoring a new frame.
  94351. * 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.
  94352. */
  94353. fetchNewFrame(): void;
  94354. /**
  94355. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  94356. * @param newCount the count value to add to the monitored count
  94357. * @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.
  94358. */
  94359. addCount(newCount: number, fetchResult: boolean): void;
  94360. /**
  94361. * Start monitoring this performance counter
  94362. */
  94363. beginMonitoring(): void;
  94364. /**
  94365. * Compute the time lapsed since the previous beginMonitoring() call.
  94366. * @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
  94367. */
  94368. endMonitoring(newFrame?: boolean): void;
  94369. private _fetchResult;
  94370. private _startMonitoringTime;
  94371. private _min;
  94372. private _max;
  94373. private _average;
  94374. private _current;
  94375. private _totalValueCount;
  94376. private _totalAccumulated;
  94377. private _lastSecAverage;
  94378. private _lastSecAccumulated;
  94379. private _lastSecTime;
  94380. private _lastSecValueCount;
  94381. }
  94382. /**
  94383. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  94384. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  94385. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  94386. * @param name The name of the class, case should be preserved
  94387. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  94388. */
  94389. export function className(name: string, module?: string): (target: Object) => void;
  94390. /**
  94391. * An implementation of a loop for asynchronous functions.
  94392. */
  94393. export class AsyncLoop {
  94394. /**
  94395. * Defines the number of iterations for the loop
  94396. */
  94397. iterations: number;
  94398. /**
  94399. * Defines the current index of the loop.
  94400. */
  94401. index: number;
  94402. private _done;
  94403. private _fn;
  94404. private _successCallback;
  94405. /**
  94406. * Constructor.
  94407. * @param iterations the number of iterations.
  94408. * @param func the function to run each iteration
  94409. * @param successCallback the callback that will be called upon succesful execution
  94410. * @param offset starting offset.
  94411. */
  94412. constructor(
  94413. /**
  94414. * Defines the number of iterations for the loop
  94415. */
  94416. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  94417. /**
  94418. * Execute the next iteration. Must be called after the last iteration was finished.
  94419. */
  94420. executeNext(): void;
  94421. /**
  94422. * Break the loop and run the success callback.
  94423. */
  94424. breakLoop(): void;
  94425. /**
  94426. * Create and run an async loop.
  94427. * @param iterations the number of iterations.
  94428. * @param fn the function to run each iteration
  94429. * @param successCallback the callback that will be called upon succesful execution
  94430. * @param offset starting offset.
  94431. * @returns the created async loop object
  94432. */
  94433. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  94434. /**
  94435. * A for-loop that will run a given number of iterations synchronous and the rest async.
  94436. * @param iterations total number of iterations
  94437. * @param syncedIterations number of synchronous iterations in each async iteration.
  94438. * @param fn the function to call each iteration.
  94439. * @param callback a success call back that will be called when iterating stops.
  94440. * @param breakFunction a break condition (optional)
  94441. * @param timeout timeout settings for the setTimeout function. default - 0.
  94442. * @returns the created async loop object
  94443. */
  94444. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  94445. }
  94446. }
  94447. declare module BABYLON {
  94448. /** @hidden */
  94449. export interface ICollisionCoordinator {
  94450. createCollider(): Collider;
  94451. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  94452. init(scene: Scene): void;
  94453. }
  94454. /** @hidden */
  94455. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  94456. private _scene;
  94457. private _scaledPosition;
  94458. private _scaledVelocity;
  94459. private _finalPosition;
  94460. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  94461. createCollider(): Collider;
  94462. init(scene: Scene): void;
  94463. private _collideWithWorld;
  94464. }
  94465. }
  94466. declare module BABYLON {
  94467. /**
  94468. * Class used to manage all inputs for the scene.
  94469. */
  94470. export class InputManager {
  94471. /** The distance in pixel that you have to move to prevent some events */
  94472. static DragMovementThreshold: number;
  94473. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  94474. static LongPressDelay: number;
  94475. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  94476. static DoubleClickDelay: number;
  94477. /** If you need to check double click without raising a single click at first click, enable this flag */
  94478. static ExclusiveDoubleClickMode: boolean;
  94479. private _wheelEventName;
  94480. private _onPointerMove;
  94481. private _onPointerDown;
  94482. private _onPointerUp;
  94483. private _initClickEvent;
  94484. private _initActionManager;
  94485. private _delayedSimpleClick;
  94486. private _delayedSimpleClickTimeout;
  94487. private _previousDelayedSimpleClickTimeout;
  94488. private _meshPickProceed;
  94489. private _previousButtonPressed;
  94490. private _currentPickResult;
  94491. private _previousPickResult;
  94492. private _totalPointersPressed;
  94493. private _doubleClickOccured;
  94494. private _pointerOverMesh;
  94495. private _pickedDownMesh;
  94496. private _pickedUpMesh;
  94497. private _pointerX;
  94498. private _pointerY;
  94499. private _unTranslatedPointerX;
  94500. private _unTranslatedPointerY;
  94501. private _startingPointerPosition;
  94502. private _previousStartingPointerPosition;
  94503. private _startingPointerTime;
  94504. private _previousStartingPointerTime;
  94505. private _pointerCaptures;
  94506. private _onKeyDown;
  94507. private _onKeyUp;
  94508. private _onCanvasFocusObserver;
  94509. private _onCanvasBlurObserver;
  94510. private _scene;
  94511. /**
  94512. * Creates a new InputManager
  94513. * @param scene defines the hosting scene
  94514. */
  94515. constructor(scene: Scene);
  94516. /**
  94517. * Gets the mesh that is currently under the pointer
  94518. */
  94519. readonly meshUnderPointer: Nullable<AbstractMesh>;
  94520. /**
  94521. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  94522. */
  94523. readonly unTranslatedPointer: Vector2;
  94524. /**
  94525. * Gets or sets the current on-screen X position of the pointer
  94526. */
  94527. pointerX: number;
  94528. /**
  94529. * Gets or sets the current on-screen Y position of the pointer
  94530. */
  94531. pointerY: number;
  94532. private _updatePointerPosition;
  94533. private _processPointerMove;
  94534. private _setRayOnPointerInfo;
  94535. private _checkPrePointerObservable;
  94536. /**
  94537. * Use this method to simulate a pointer move on a mesh
  94538. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94539. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94540. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94541. */
  94542. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  94543. /**
  94544. * Use this method to simulate a pointer down on a mesh
  94545. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94546. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94547. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94548. */
  94549. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  94550. private _processPointerDown;
  94551. /** @hidden */
  94552. _isPointerSwiping(): boolean;
  94553. /**
  94554. * Use this method to simulate a pointer up on a mesh
  94555. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  94556. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  94557. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  94558. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  94559. */
  94560. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  94561. private _processPointerUp;
  94562. /**
  94563. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  94564. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  94565. * @returns true if the pointer was captured
  94566. */
  94567. isPointerCaptured(pointerId?: number): boolean;
  94568. /**
  94569. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  94570. * @param attachUp defines if you want to attach events to pointerup
  94571. * @param attachDown defines if you want to attach events to pointerdown
  94572. * @param attachMove defines if you want to attach events to pointermove
  94573. */
  94574. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  94575. /**
  94576. * Detaches all event handlers
  94577. */
  94578. detachControl(): void;
  94579. /**
  94580. * Force the value of meshUnderPointer
  94581. * @param mesh defines the mesh to use
  94582. */
  94583. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  94584. /**
  94585. * Gets the mesh under the pointer
  94586. * @returns a Mesh or null if no mesh is under the pointer
  94587. */
  94588. getPointerOverMesh(): Nullable<AbstractMesh>;
  94589. }
  94590. }
  94591. declare module BABYLON {
  94592. /**
  94593. * This class defines the direct association between an animation and a target
  94594. */
  94595. export class TargetedAnimation {
  94596. /**
  94597. * Animation to perform
  94598. */
  94599. animation: Animation;
  94600. /**
  94601. * Target to animate
  94602. */
  94603. target: any;
  94604. /**
  94605. * Serialize the object
  94606. * @returns the JSON object representing the current entity
  94607. */
  94608. serialize(): any;
  94609. }
  94610. /**
  94611. * Use this class to create coordinated animations on multiple targets
  94612. */
  94613. export class AnimationGroup implements IDisposable {
  94614. /** The name of the animation group */
  94615. name: string;
  94616. private _scene;
  94617. private _targetedAnimations;
  94618. private _animatables;
  94619. private _from;
  94620. private _to;
  94621. private _isStarted;
  94622. private _isPaused;
  94623. private _speedRatio;
  94624. private _loopAnimation;
  94625. /**
  94626. * Gets or sets the unique id of the node
  94627. */
  94628. uniqueId: number;
  94629. /**
  94630. * This observable will notify when one animation have ended
  94631. */
  94632. onAnimationEndObservable: Observable<TargetedAnimation>;
  94633. /**
  94634. * Observer raised when one animation loops
  94635. */
  94636. onAnimationLoopObservable: Observable<TargetedAnimation>;
  94637. /**
  94638. * This observable will notify when all animations have ended.
  94639. */
  94640. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  94641. /**
  94642. * This observable will notify when all animations have paused.
  94643. */
  94644. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  94645. /**
  94646. * This observable will notify when all animations are playing.
  94647. */
  94648. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  94649. /**
  94650. * Gets the first frame
  94651. */
  94652. readonly from: number;
  94653. /**
  94654. * Gets the last frame
  94655. */
  94656. readonly to: number;
  94657. /**
  94658. * Define if the animations are started
  94659. */
  94660. readonly isStarted: boolean;
  94661. /**
  94662. * Gets a value indicating that the current group is playing
  94663. */
  94664. readonly isPlaying: boolean;
  94665. /**
  94666. * Gets or sets the speed ratio to use for all animations
  94667. */
  94668. /**
  94669. * Gets or sets the speed ratio to use for all animations
  94670. */
  94671. speedRatio: number;
  94672. /**
  94673. * Gets or sets if all animations should loop or not
  94674. */
  94675. loopAnimation: boolean;
  94676. /**
  94677. * Gets the targeted animations for this animation group
  94678. */
  94679. readonly targetedAnimations: Array<TargetedAnimation>;
  94680. /**
  94681. * returning the list of animatables controlled by this animation group.
  94682. */
  94683. readonly animatables: Array<Animatable>;
  94684. /**
  94685. * Instantiates a new Animation Group.
  94686. * This helps managing several animations at once.
  94687. * @see http://doc.babylonjs.com/how_to/group
  94688. * @param name Defines the name of the group
  94689. * @param scene Defines the scene the group belongs to
  94690. */
  94691. constructor(
  94692. /** The name of the animation group */
  94693. name: string, scene?: Nullable<Scene>);
  94694. /**
  94695. * Add an animation (with its target) in the group
  94696. * @param animation defines the animation we want to add
  94697. * @param target defines the target of the animation
  94698. * @returns the TargetedAnimation object
  94699. */
  94700. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  94701. /**
  94702. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  94703. * It can add constant keys at begin or end
  94704. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  94705. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  94706. * @returns the animation group
  94707. */
  94708. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  94709. /**
  94710. * Start all animations on given targets
  94711. * @param loop defines if animations must loop
  94712. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  94713. * @param from defines the from key (optional)
  94714. * @param to defines the to key (optional)
  94715. * @returns the current animation group
  94716. */
  94717. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  94718. /**
  94719. * Pause all animations
  94720. * @returns the animation group
  94721. */
  94722. pause(): AnimationGroup;
  94723. /**
  94724. * Play all animations to initial state
  94725. * This function will start() the animations if they were not started or will restart() them if they were paused
  94726. * @param loop defines if animations must loop
  94727. * @returns the animation group
  94728. */
  94729. play(loop?: boolean): AnimationGroup;
  94730. /**
  94731. * Reset all animations to initial state
  94732. * @returns the animation group
  94733. */
  94734. reset(): AnimationGroup;
  94735. /**
  94736. * Restart animations from key 0
  94737. * @returns the animation group
  94738. */
  94739. restart(): AnimationGroup;
  94740. /**
  94741. * Stop all animations
  94742. * @returns the animation group
  94743. */
  94744. stop(): AnimationGroup;
  94745. /**
  94746. * Set animation weight for all animatables
  94747. * @param weight defines the weight to use
  94748. * @return the animationGroup
  94749. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  94750. */
  94751. setWeightForAllAnimatables(weight: number): AnimationGroup;
  94752. /**
  94753. * Synchronize and normalize all animatables with a source animatable
  94754. * @param root defines the root animatable to synchronize with
  94755. * @return the animationGroup
  94756. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  94757. */
  94758. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  94759. /**
  94760. * Goes to a specific frame in this animation group
  94761. * @param frame the frame number to go to
  94762. * @return the animationGroup
  94763. */
  94764. goToFrame(frame: number): AnimationGroup;
  94765. /**
  94766. * Dispose all associated resources
  94767. */
  94768. dispose(): void;
  94769. private _checkAnimationGroupEnded;
  94770. /**
  94771. * Clone the current animation group and returns a copy
  94772. * @param newName defines the name of the new group
  94773. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  94774. * @returns the new aniamtion group
  94775. */
  94776. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  94777. /**
  94778. * Serializes the animationGroup to an object
  94779. * @returns Serialized object
  94780. */
  94781. serialize(): any;
  94782. /**
  94783. * Returns a new AnimationGroup object parsed from the source provided.
  94784. * @param parsedAnimationGroup defines the source
  94785. * @param scene defines the scene that will receive the animationGroup
  94786. * @returns a new AnimationGroup
  94787. */
  94788. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  94789. /**
  94790. * Returns the string "AnimationGroup"
  94791. * @returns "AnimationGroup"
  94792. */
  94793. getClassName(): string;
  94794. /**
  94795. * Creates a detailled string about the object
  94796. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  94797. * @returns a string representing the object
  94798. */
  94799. toString(fullDetails?: boolean): string;
  94800. }
  94801. }
  94802. declare module BABYLON {
  94803. /**
  94804. * Define an interface for all classes that will hold resources
  94805. */
  94806. export interface IDisposable {
  94807. /**
  94808. * Releases all held resources
  94809. */
  94810. dispose(): void;
  94811. }
  94812. /** Interface defining initialization parameters for Scene class */
  94813. export interface SceneOptions {
  94814. /**
  94815. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  94816. * It will improve performance when the number of geometries becomes important.
  94817. */
  94818. useGeometryUniqueIdsMap?: boolean;
  94819. /**
  94820. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  94821. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  94822. */
  94823. useMaterialMeshMap?: boolean;
  94824. /**
  94825. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  94826. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  94827. */
  94828. useClonedMeshhMap?: boolean;
  94829. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  94830. virtual?: boolean;
  94831. }
  94832. /**
  94833. * Represents a scene to be rendered by the engine.
  94834. * @see http://doc.babylonjs.com/features/scene
  94835. */
  94836. export class Scene extends AbstractScene implements IAnimatable {
  94837. private static _uniqueIdCounter;
  94838. /** The fog is deactivated */
  94839. static readonly FOGMODE_NONE: number;
  94840. /** The fog density is following an exponential function */
  94841. static readonly FOGMODE_EXP: number;
  94842. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  94843. static readonly FOGMODE_EXP2: number;
  94844. /** The fog density is following a linear function. */
  94845. static readonly FOGMODE_LINEAR: number;
  94846. /**
  94847. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  94848. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94849. */
  94850. static MinDeltaTime: number;
  94851. /**
  94852. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  94853. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94854. */
  94855. static MaxDeltaTime: number;
  94856. /**
  94857. * Factory used to create the default material.
  94858. * @param name The name of the material to create
  94859. * @param scene The scene to create the material for
  94860. * @returns The default material
  94861. */
  94862. static DefaultMaterialFactory(scene: Scene): Material;
  94863. /**
  94864. * Factory used to create the a collision coordinator.
  94865. * @returns The collision coordinator
  94866. */
  94867. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  94868. /** @hidden */
  94869. _inputManager: InputManager;
  94870. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  94871. cameraToUseForPointers: Nullable<Camera>;
  94872. /** @hidden */
  94873. readonly _isScene: boolean;
  94874. /**
  94875. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  94876. */
  94877. autoClear: boolean;
  94878. /**
  94879. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  94880. */
  94881. autoClearDepthAndStencil: boolean;
  94882. /**
  94883. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  94884. */
  94885. clearColor: Color4;
  94886. /**
  94887. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  94888. */
  94889. ambientColor: Color3;
  94890. /**
  94891. * This is use to store the default BRDF lookup for PBR materials in your scene.
  94892. * It should only be one of the following (if not the default embedded one):
  94893. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  94894. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  94895. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  94896. * The material properties need to be setup according to the type of texture in use.
  94897. */
  94898. environmentBRDFTexture: BaseTexture;
  94899. /** @hidden */
  94900. protected _environmentTexture: Nullable<BaseTexture>;
  94901. /**
  94902. * Texture used in all pbr material as the reflection texture.
  94903. * As in the majority of the scene they are the same (exception for multi room and so on),
  94904. * this is easier to reference from here than from all the materials.
  94905. */
  94906. /**
  94907. * Texture used in all pbr material as the reflection texture.
  94908. * As in the majority of the scene they are the same (exception for multi room and so on),
  94909. * this is easier to set here than in all the materials.
  94910. */
  94911. environmentTexture: Nullable<BaseTexture>;
  94912. /** @hidden */
  94913. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  94914. /**
  94915. * Default image processing configuration used either in the rendering
  94916. * Forward main pass or through the imageProcessingPostProcess if present.
  94917. * As in the majority of the scene they are the same (exception for multi camera),
  94918. * this is easier to reference from here than from all the materials and post process.
  94919. *
  94920. * No setter as we it is a shared configuration, you can set the values instead.
  94921. */
  94922. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  94923. private _forceWireframe;
  94924. /**
  94925. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  94926. */
  94927. forceWireframe: boolean;
  94928. private _forcePointsCloud;
  94929. /**
  94930. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  94931. */
  94932. forcePointsCloud: boolean;
  94933. /**
  94934. * Gets or sets the active clipplane 1
  94935. */
  94936. clipPlane: Nullable<Plane>;
  94937. /**
  94938. * Gets or sets the active clipplane 2
  94939. */
  94940. clipPlane2: Nullable<Plane>;
  94941. /**
  94942. * Gets or sets the active clipplane 3
  94943. */
  94944. clipPlane3: Nullable<Plane>;
  94945. /**
  94946. * Gets or sets the active clipplane 4
  94947. */
  94948. clipPlane4: Nullable<Plane>;
  94949. /**
  94950. * Gets or sets a boolean indicating if animations are enabled
  94951. */
  94952. animationsEnabled: boolean;
  94953. private _animationPropertiesOverride;
  94954. /**
  94955. * Gets or sets the animation properties override
  94956. */
  94957. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  94958. /**
  94959. * Gets or sets a boolean indicating if a constant deltatime has to be used
  94960. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  94961. */
  94962. useConstantAnimationDeltaTime: boolean;
  94963. /**
  94964. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  94965. * Please note that it requires to run a ray cast through the scene on every frame
  94966. */
  94967. constantlyUpdateMeshUnderPointer: boolean;
  94968. /**
  94969. * Defines the HTML cursor to use when hovering over interactive elements
  94970. */
  94971. hoverCursor: string;
  94972. /**
  94973. * Defines the HTML default cursor to use (empty by default)
  94974. */
  94975. defaultCursor: string;
  94976. /**
  94977. * This is used to call preventDefault() on pointer down
  94978. * in order to block unwanted artifacts like system double clicks
  94979. */
  94980. preventDefaultOnPointerDown: boolean;
  94981. /**
  94982. * This is used to call preventDefault() on pointer up
  94983. * in order to block unwanted artifacts like system double clicks
  94984. */
  94985. preventDefaultOnPointerUp: boolean;
  94986. /**
  94987. * Gets or sets user defined metadata
  94988. */
  94989. metadata: any;
  94990. /**
  94991. * For internal use only. Please do not use.
  94992. */
  94993. reservedDataStore: any;
  94994. /**
  94995. * Gets the name of the plugin used to load this scene (null by default)
  94996. */
  94997. loadingPluginName: string;
  94998. /**
  94999. * Use this array to add regular expressions used to disable offline support for specific urls
  95000. */
  95001. disableOfflineSupportExceptionRules: RegExp[];
  95002. /**
  95003. * An event triggered when the scene is disposed.
  95004. */
  95005. onDisposeObservable: Observable<Scene>;
  95006. private _onDisposeObserver;
  95007. /** Sets a function to be executed when this scene is disposed. */
  95008. onDispose: () => void;
  95009. /**
  95010. * An event triggered before rendering the scene (right after animations and physics)
  95011. */
  95012. onBeforeRenderObservable: Observable<Scene>;
  95013. private _onBeforeRenderObserver;
  95014. /** Sets a function to be executed before rendering this scene */
  95015. beforeRender: Nullable<() => void>;
  95016. /**
  95017. * An event triggered after rendering the scene
  95018. */
  95019. onAfterRenderObservable: Observable<Scene>;
  95020. /**
  95021. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  95022. */
  95023. onAfterRenderCameraObservable: Observable<Camera>;
  95024. private _onAfterRenderObserver;
  95025. /** Sets a function to be executed after rendering this scene */
  95026. afterRender: Nullable<() => void>;
  95027. /**
  95028. * An event triggered before animating the scene
  95029. */
  95030. onBeforeAnimationsObservable: Observable<Scene>;
  95031. /**
  95032. * An event triggered after animations processing
  95033. */
  95034. onAfterAnimationsObservable: Observable<Scene>;
  95035. /**
  95036. * An event triggered before draw calls are ready to be sent
  95037. */
  95038. onBeforeDrawPhaseObservable: Observable<Scene>;
  95039. /**
  95040. * An event triggered after draw calls have been sent
  95041. */
  95042. onAfterDrawPhaseObservable: Observable<Scene>;
  95043. /**
  95044. * An event triggered when the scene is ready
  95045. */
  95046. onReadyObservable: Observable<Scene>;
  95047. /**
  95048. * An event triggered before rendering a camera
  95049. */
  95050. onBeforeCameraRenderObservable: Observable<Camera>;
  95051. private _onBeforeCameraRenderObserver;
  95052. /** Sets a function to be executed before rendering a camera*/
  95053. beforeCameraRender: () => void;
  95054. /**
  95055. * An event triggered after rendering a camera
  95056. */
  95057. onAfterCameraRenderObservable: Observable<Camera>;
  95058. private _onAfterCameraRenderObserver;
  95059. /** Sets a function to be executed after rendering a camera*/
  95060. afterCameraRender: () => void;
  95061. /**
  95062. * An event triggered when active meshes evaluation is about to start
  95063. */
  95064. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  95065. /**
  95066. * An event triggered when active meshes evaluation is done
  95067. */
  95068. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  95069. /**
  95070. * An event triggered when particles rendering is about to start
  95071. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  95072. */
  95073. onBeforeParticlesRenderingObservable: Observable<Scene>;
  95074. /**
  95075. * An event triggered when particles rendering is done
  95076. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  95077. */
  95078. onAfterParticlesRenderingObservable: Observable<Scene>;
  95079. /**
  95080. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  95081. */
  95082. onDataLoadedObservable: Observable<Scene>;
  95083. /**
  95084. * An event triggered when a camera is created
  95085. */
  95086. onNewCameraAddedObservable: Observable<Camera>;
  95087. /**
  95088. * An event triggered when a camera is removed
  95089. */
  95090. onCameraRemovedObservable: Observable<Camera>;
  95091. /**
  95092. * An event triggered when a light is created
  95093. */
  95094. onNewLightAddedObservable: Observable<Light>;
  95095. /**
  95096. * An event triggered when a light is removed
  95097. */
  95098. onLightRemovedObservable: Observable<Light>;
  95099. /**
  95100. * An event triggered when a geometry is created
  95101. */
  95102. onNewGeometryAddedObservable: Observable<Geometry>;
  95103. /**
  95104. * An event triggered when a geometry is removed
  95105. */
  95106. onGeometryRemovedObservable: Observable<Geometry>;
  95107. /**
  95108. * An event triggered when a transform node is created
  95109. */
  95110. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  95111. /**
  95112. * An event triggered when a transform node is removed
  95113. */
  95114. onTransformNodeRemovedObservable: Observable<TransformNode>;
  95115. /**
  95116. * An event triggered when a mesh is created
  95117. */
  95118. onNewMeshAddedObservable: Observable<AbstractMesh>;
  95119. /**
  95120. * An event triggered when a mesh is removed
  95121. */
  95122. onMeshRemovedObservable: Observable<AbstractMesh>;
  95123. /**
  95124. * An event triggered when a skeleton is created
  95125. */
  95126. onNewSkeletonAddedObservable: Observable<Skeleton>;
  95127. /**
  95128. * An event triggered when a skeleton is removed
  95129. */
  95130. onSkeletonRemovedObservable: Observable<Skeleton>;
  95131. /**
  95132. * An event triggered when a material is created
  95133. */
  95134. onNewMaterialAddedObservable: Observable<Material>;
  95135. /**
  95136. * An event triggered when a material is removed
  95137. */
  95138. onMaterialRemovedObservable: Observable<Material>;
  95139. /**
  95140. * An event triggered when a texture is created
  95141. */
  95142. onNewTextureAddedObservable: Observable<BaseTexture>;
  95143. /**
  95144. * An event triggered when a texture is removed
  95145. */
  95146. onTextureRemovedObservable: Observable<BaseTexture>;
  95147. /**
  95148. * An event triggered when render targets are about to be rendered
  95149. * Can happen multiple times per frame.
  95150. */
  95151. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  95152. /**
  95153. * An event triggered when render targets were rendered.
  95154. * Can happen multiple times per frame.
  95155. */
  95156. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  95157. /**
  95158. * An event triggered before calculating deterministic simulation step
  95159. */
  95160. onBeforeStepObservable: Observable<Scene>;
  95161. /**
  95162. * An event triggered after calculating deterministic simulation step
  95163. */
  95164. onAfterStepObservable: Observable<Scene>;
  95165. /**
  95166. * An event triggered when the activeCamera property is updated
  95167. */
  95168. onActiveCameraChanged: Observable<Scene>;
  95169. /**
  95170. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  95171. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  95172. * 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)
  95173. */
  95174. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  95175. /**
  95176. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  95177. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  95178. * 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)
  95179. */
  95180. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  95181. /**
  95182. * This Observable will when a mesh has been imported into the scene.
  95183. */
  95184. onMeshImportedObservable: Observable<AbstractMesh>;
  95185. /**
  95186. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  95187. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  95188. */
  95189. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  95190. /** @hidden */
  95191. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  95192. /**
  95193. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  95194. */
  95195. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  95196. /**
  95197. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  95198. */
  95199. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  95200. /**
  95201. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  95202. */
  95203. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  95204. /** Callback called when a pointer move is detected */
  95205. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  95206. /** Callback called when a pointer down is detected */
  95207. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  95208. /** Callback called when a pointer up is detected */
  95209. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  95210. /** Callback called when a pointer pick is detected */
  95211. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  95212. /**
  95213. * 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).
  95214. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  95215. */
  95216. onPrePointerObservable: Observable<PointerInfoPre>;
  95217. /**
  95218. * Observable event triggered each time an input event is received from the rendering canvas
  95219. */
  95220. onPointerObservable: Observable<PointerInfo>;
  95221. /**
  95222. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  95223. */
  95224. readonly unTranslatedPointer: Vector2;
  95225. /**
  95226. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  95227. */
  95228. static DragMovementThreshold: number;
  95229. /**
  95230. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  95231. */
  95232. static LongPressDelay: number;
  95233. /**
  95234. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  95235. */
  95236. static DoubleClickDelay: number;
  95237. /** If you need to check double click without raising a single click at first click, enable this flag */
  95238. static ExclusiveDoubleClickMode: boolean;
  95239. /** @hidden */
  95240. _mirroredCameraPosition: Nullable<Vector3>;
  95241. /**
  95242. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  95243. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  95244. */
  95245. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  95246. /**
  95247. * Observable event triggered each time an keyboard event is received from the hosting window
  95248. */
  95249. onKeyboardObservable: Observable<KeyboardInfo>;
  95250. private _useRightHandedSystem;
  95251. /**
  95252. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  95253. */
  95254. useRightHandedSystem: boolean;
  95255. private _timeAccumulator;
  95256. private _currentStepId;
  95257. private _currentInternalStep;
  95258. /**
  95259. * Sets the step Id used by deterministic lock step
  95260. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95261. * @param newStepId defines the step Id
  95262. */
  95263. setStepId(newStepId: number): void;
  95264. /**
  95265. * Gets the step Id used by deterministic lock step
  95266. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95267. * @returns the step Id
  95268. */
  95269. getStepId(): number;
  95270. /**
  95271. * Gets the internal step used by deterministic lock step
  95272. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95273. * @returns the internal step
  95274. */
  95275. getInternalStep(): number;
  95276. private _fogEnabled;
  95277. /**
  95278. * Gets or sets a boolean indicating if fog is enabled on this scene
  95279. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95280. * (Default is true)
  95281. */
  95282. fogEnabled: boolean;
  95283. private _fogMode;
  95284. /**
  95285. * Gets or sets the fog mode to use
  95286. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95287. * | mode | value |
  95288. * | --- | --- |
  95289. * | FOGMODE_NONE | 0 |
  95290. * | FOGMODE_EXP | 1 |
  95291. * | FOGMODE_EXP2 | 2 |
  95292. * | FOGMODE_LINEAR | 3 |
  95293. */
  95294. fogMode: number;
  95295. /**
  95296. * Gets or sets the fog color to use
  95297. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95298. * (Default is Color3(0.2, 0.2, 0.3))
  95299. */
  95300. fogColor: Color3;
  95301. /**
  95302. * Gets or sets the fog density to use
  95303. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95304. * (Default is 0.1)
  95305. */
  95306. fogDensity: number;
  95307. /**
  95308. * Gets or sets the fog start distance to use
  95309. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95310. * (Default is 0)
  95311. */
  95312. fogStart: number;
  95313. /**
  95314. * Gets or sets the fog end distance to use
  95315. * @see http://doc.babylonjs.com/babylon101/environment#fog
  95316. * (Default is 1000)
  95317. */
  95318. fogEnd: number;
  95319. private _shadowsEnabled;
  95320. /**
  95321. * Gets or sets a boolean indicating if shadows are enabled on this scene
  95322. */
  95323. shadowsEnabled: boolean;
  95324. private _lightsEnabled;
  95325. /**
  95326. * Gets or sets a boolean indicating if lights are enabled on this scene
  95327. */
  95328. lightsEnabled: boolean;
  95329. /** All of the active cameras added to this scene. */
  95330. activeCameras: Camera[];
  95331. /** @hidden */
  95332. _activeCamera: Nullable<Camera>;
  95333. /** Gets or sets the current active camera */
  95334. activeCamera: Nullable<Camera>;
  95335. private _defaultMaterial;
  95336. /** The default material used on meshes when no material is affected */
  95337. /** The default material used on meshes when no material is affected */
  95338. defaultMaterial: Material;
  95339. private _texturesEnabled;
  95340. /**
  95341. * Gets or sets a boolean indicating if textures are enabled on this scene
  95342. */
  95343. texturesEnabled: boolean;
  95344. /**
  95345. * Gets or sets a boolean indicating if particles are enabled on this scene
  95346. */
  95347. particlesEnabled: boolean;
  95348. /**
  95349. * Gets or sets a boolean indicating if sprites are enabled on this scene
  95350. */
  95351. spritesEnabled: boolean;
  95352. private _skeletonsEnabled;
  95353. /**
  95354. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  95355. */
  95356. skeletonsEnabled: boolean;
  95357. /**
  95358. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  95359. */
  95360. lensFlaresEnabled: boolean;
  95361. /**
  95362. * Gets or sets a boolean indicating if collisions are enabled on this scene
  95363. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95364. */
  95365. collisionsEnabled: boolean;
  95366. private _collisionCoordinator;
  95367. /** @hidden */
  95368. readonly collisionCoordinator: ICollisionCoordinator;
  95369. /**
  95370. * Defines the gravity applied to this scene (used only for collisions)
  95371. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  95372. */
  95373. gravity: Vector3;
  95374. /**
  95375. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  95376. */
  95377. postProcessesEnabled: boolean;
  95378. /**
  95379. * The list of postprocesses added to the scene
  95380. */
  95381. postProcesses: PostProcess[];
  95382. /**
  95383. * Gets the current postprocess manager
  95384. */
  95385. postProcessManager: PostProcessManager;
  95386. /**
  95387. * Gets or sets a boolean indicating if render targets are enabled on this scene
  95388. */
  95389. renderTargetsEnabled: boolean;
  95390. /**
  95391. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  95392. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  95393. */
  95394. dumpNextRenderTargets: boolean;
  95395. /**
  95396. * The list of user defined render targets added to the scene
  95397. */
  95398. customRenderTargets: RenderTargetTexture[];
  95399. /**
  95400. * Defines if texture loading must be delayed
  95401. * If true, textures will only be loaded when they need to be rendered
  95402. */
  95403. useDelayedTextureLoading: boolean;
  95404. /**
  95405. * Gets the list of meshes imported to the scene through SceneLoader
  95406. */
  95407. importedMeshesFiles: String[];
  95408. /**
  95409. * Gets or sets a boolean indicating if probes are enabled on this scene
  95410. */
  95411. probesEnabled: boolean;
  95412. /**
  95413. * Gets or sets the current offline provider to use to store scene data
  95414. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  95415. */
  95416. offlineProvider: IOfflineProvider;
  95417. /**
  95418. * Gets or sets the action manager associated with the scene
  95419. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  95420. */
  95421. actionManager: AbstractActionManager;
  95422. private _meshesForIntersections;
  95423. /**
  95424. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  95425. */
  95426. proceduralTexturesEnabled: boolean;
  95427. private _engine;
  95428. private _totalVertices;
  95429. /** @hidden */
  95430. _activeIndices: PerfCounter;
  95431. /** @hidden */
  95432. _activeParticles: PerfCounter;
  95433. /** @hidden */
  95434. _activeBones: PerfCounter;
  95435. private _animationRatio;
  95436. /** @hidden */
  95437. _animationTimeLast: number;
  95438. /** @hidden */
  95439. _animationTime: number;
  95440. /**
  95441. * Gets or sets a general scale for animation speed
  95442. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  95443. */
  95444. animationTimeScale: number;
  95445. /** @hidden */
  95446. _cachedMaterial: Nullable<Material>;
  95447. /** @hidden */
  95448. _cachedEffect: Nullable<Effect>;
  95449. /** @hidden */
  95450. _cachedVisibility: Nullable<number>;
  95451. private _renderId;
  95452. private _frameId;
  95453. private _executeWhenReadyTimeoutId;
  95454. private _intermediateRendering;
  95455. private _viewUpdateFlag;
  95456. private _projectionUpdateFlag;
  95457. /** @hidden */
  95458. _toBeDisposed: Nullable<IDisposable>[];
  95459. private _activeRequests;
  95460. /** @hidden */
  95461. _pendingData: any[];
  95462. private _isDisposed;
  95463. /**
  95464. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  95465. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  95466. */
  95467. dispatchAllSubMeshesOfActiveMeshes: boolean;
  95468. private _activeMeshes;
  95469. private _processedMaterials;
  95470. private _renderTargets;
  95471. /** @hidden */
  95472. _activeParticleSystems: SmartArray<IParticleSystem>;
  95473. private _activeSkeletons;
  95474. private _softwareSkinnedMeshes;
  95475. private _renderingManager;
  95476. /** @hidden */
  95477. _activeAnimatables: Animatable[];
  95478. private _transformMatrix;
  95479. private _sceneUbo;
  95480. /** @hidden */
  95481. _viewMatrix: Matrix;
  95482. private _projectionMatrix;
  95483. /** @hidden */
  95484. _forcedViewPosition: Nullable<Vector3>;
  95485. /** @hidden */
  95486. _frustumPlanes: Plane[];
  95487. /**
  95488. * Gets the list of frustum planes (built from the active camera)
  95489. */
  95490. readonly frustumPlanes: Plane[];
  95491. /**
  95492. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  95493. * This is useful if there are more lights that the maximum simulteanous authorized
  95494. */
  95495. requireLightSorting: boolean;
  95496. /** @hidden */
  95497. readonly useMaterialMeshMap: boolean;
  95498. /** @hidden */
  95499. readonly useClonedMeshhMap: boolean;
  95500. private _externalData;
  95501. private _uid;
  95502. /**
  95503. * @hidden
  95504. * Backing store of defined scene components.
  95505. */
  95506. _components: ISceneComponent[];
  95507. /**
  95508. * @hidden
  95509. * Backing store of defined scene components.
  95510. */
  95511. _serializableComponents: ISceneSerializableComponent[];
  95512. /**
  95513. * List of components to register on the next registration step.
  95514. */
  95515. private _transientComponents;
  95516. /**
  95517. * Registers the transient components if needed.
  95518. */
  95519. private _registerTransientComponents;
  95520. /**
  95521. * @hidden
  95522. * Add a component to the scene.
  95523. * Note that the ccomponent could be registered on th next frame if this is called after
  95524. * the register component stage.
  95525. * @param component Defines the component to add to the scene
  95526. */
  95527. _addComponent(component: ISceneComponent): void;
  95528. /**
  95529. * @hidden
  95530. * Gets a component from the scene.
  95531. * @param name defines the name of the component to retrieve
  95532. * @returns the component or null if not present
  95533. */
  95534. _getComponent(name: string): Nullable<ISceneComponent>;
  95535. /**
  95536. * @hidden
  95537. * Defines the actions happening before camera updates.
  95538. */
  95539. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  95540. /**
  95541. * @hidden
  95542. * Defines the actions happening before clear the canvas.
  95543. */
  95544. _beforeClearStage: Stage<SimpleStageAction>;
  95545. /**
  95546. * @hidden
  95547. * Defines the actions when collecting render targets for the frame.
  95548. */
  95549. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  95550. /**
  95551. * @hidden
  95552. * Defines the actions happening for one camera in the frame.
  95553. */
  95554. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  95555. /**
  95556. * @hidden
  95557. * Defines the actions happening during the per mesh ready checks.
  95558. */
  95559. _isReadyForMeshStage: Stage<MeshStageAction>;
  95560. /**
  95561. * @hidden
  95562. * Defines the actions happening before evaluate active mesh checks.
  95563. */
  95564. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  95565. /**
  95566. * @hidden
  95567. * Defines the actions happening during the evaluate sub mesh checks.
  95568. */
  95569. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  95570. /**
  95571. * @hidden
  95572. * Defines the actions happening during the active mesh stage.
  95573. */
  95574. _activeMeshStage: Stage<ActiveMeshStageAction>;
  95575. /**
  95576. * @hidden
  95577. * Defines the actions happening during the per camera render target step.
  95578. */
  95579. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  95580. /**
  95581. * @hidden
  95582. * Defines the actions happening just before the active camera is drawing.
  95583. */
  95584. _beforeCameraDrawStage: Stage<CameraStageAction>;
  95585. /**
  95586. * @hidden
  95587. * Defines the actions happening just before a render target is drawing.
  95588. */
  95589. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  95590. /**
  95591. * @hidden
  95592. * Defines the actions happening just before a rendering group is drawing.
  95593. */
  95594. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  95595. /**
  95596. * @hidden
  95597. * Defines the actions happening just before a mesh is drawing.
  95598. */
  95599. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  95600. /**
  95601. * @hidden
  95602. * Defines the actions happening just after a mesh has been drawn.
  95603. */
  95604. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  95605. /**
  95606. * @hidden
  95607. * Defines the actions happening just after a rendering group has been drawn.
  95608. */
  95609. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  95610. /**
  95611. * @hidden
  95612. * Defines the actions happening just after the active camera has been drawn.
  95613. */
  95614. _afterCameraDrawStage: Stage<CameraStageAction>;
  95615. /**
  95616. * @hidden
  95617. * Defines the actions happening just after a render target has been drawn.
  95618. */
  95619. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  95620. /**
  95621. * @hidden
  95622. * Defines the actions happening just after rendering all cameras and computing intersections.
  95623. */
  95624. _afterRenderStage: Stage<SimpleStageAction>;
  95625. /**
  95626. * @hidden
  95627. * Defines the actions happening when a pointer move event happens.
  95628. */
  95629. _pointerMoveStage: Stage<PointerMoveStageAction>;
  95630. /**
  95631. * @hidden
  95632. * Defines the actions happening when a pointer down event happens.
  95633. */
  95634. _pointerDownStage: Stage<PointerUpDownStageAction>;
  95635. /**
  95636. * @hidden
  95637. * Defines the actions happening when a pointer up event happens.
  95638. */
  95639. _pointerUpStage: Stage<PointerUpDownStageAction>;
  95640. /**
  95641. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  95642. */
  95643. private geometriesByUniqueId;
  95644. /**
  95645. * Creates a new Scene
  95646. * @param engine defines the engine to use to render this scene
  95647. * @param options defines the scene options
  95648. */
  95649. constructor(engine: Engine, options?: SceneOptions);
  95650. /**
  95651. * Gets a string idenfifying the name of the class
  95652. * @returns "Scene" string
  95653. */
  95654. getClassName(): string;
  95655. private _defaultMeshCandidates;
  95656. /**
  95657. * @hidden
  95658. */
  95659. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  95660. private _defaultSubMeshCandidates;
  95661. /**
  95662. * @hidden
  95663. */
  95664. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  95665. /**
  95666. * Sets the default candidate providers for the scene.
  95667. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  95668. * and getCollidingSubMeshCandidates to their default function
  95669. */
  95670. setDefaultCandidateProviders(): void;
  95671. /**
  95672. * Gets the mesh that is currently under the pointer
  95673. */
  95674. readonly meshUnderPointer: Nullable<AbstractMesh>;
  95675. /**
  95676. * Gets or sets the current on-screen X position of the pointer
  95677. */
  95678. pointerX: number;
  95679. /**
  95680. * Gets or sets the current on-screen Y position of the pointer
  95681. */
  95682. pointerY: number;
  95683. /**
  95684. * Gets the cached material (ie. the latest rendered one)
  95685. * @returns the cached material
  95686. */
  95687. getCachedMaterial(): Nullable<Material>;
  95688. /**
  95689. * Gets the cached effect (ie. the latest rendered one)
  95690. * @returns the cached effect
  95691. */
  95692. getCachedEffect(): Nullable<Effect>;
  95693. /**
  95694. * Gets the cached visibility state (ie. the latest rendered one)
  95695. * @returns the cached visibility state
  95696. */
  95697. getCachedVisibility(): Nullable<number>;
  95698. /**
  95699. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  95700. * @param material defines the current material
  95701. * @param effect defines the current effect
  95702. * @param visibility defines the current visibility state
  95703. * @returns true if one parameter is not cached
  95704. */
  95705. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  95706. /**
  95707. * Gets the engine associated with the scene
  95708. * @returns an Engine
  95709. */
  95710. getEngine(): Engine;
  95711. /**
  95712. * Gets the total number of vertices rendered per frame
  95713. * @returns the total number of vertices rendered per frame
  95714. */
  95715. getTotalVertices(): number;
  95716. /**
  95717. * Gets the performance counter for total vertices
  95718. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95719. */
  95720. readonly totalVerticesPerfCounter: PerfCounter;
  95721. /**
  95722. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  95723. * @returns the total number of active indices rendered per frame
  95724. */
  95725. getActiveIndices(): number;
  95726. /**
  95727. * Gets the performance counter for active indices
  95728. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95729. */
  95730. readonly totalActiveIndicesPerfCounter: PerfCounter;
  95731. /**
  95732. * Gets the total number of active particles rendered per frame
  95733. * @returns the total number of active particles rendered per frame
  95734. */
  95735. getActiveParticles(): number;
  95736. /**
  95737. * Gets the performance counter for active particles
  95738. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95739. */
  95740. readonly activeParticlesPerfCounter: PerfCounter;
  95741. /**
  95742. * Gets the total number of active bones rendered per frame
  95743. * @returns the total number of active bones rendered per frame
  95744. */
  95745. getActiveBones(): number;
  95746. /**
  95747. * Gets the performance counter for active bones
  95748. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  95749. */
  95750. readonly activeBonesPerfCounter: PerfCounter;
  95751. /**
  95752. * Gets the array of active meshes
  95753. * @returns an array of AbstractMesh
  95754. */
  95755. getActiveMeshes(): SmartArray<AbstractMesh>;
  95756. /**
  95757. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  95758. * @returns a number
  95759. */
  95760. getAnimationRatio(): number;
  95761. /**
  95762. * Gets an unique Id for the current render phase
  95763. * @returns a number
  95764. */
  95765. getRenderId(): number;
  95766. /**
  95767. * Gets an unique Id for the current frame
  95768. * @returns a number
  95769. */
  95770. getFrameId(): number;
  95771. /** Call this function if you want to manually increment the render Id*/
  95772. incrementRenderId(): void;
  95773. private _createUbo;
  95774. /**
  95775. * Use this method to simulate a pointer move on a mesh
  95776. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95777. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95778. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95779. * @returns the current scene
  95780. */
  95781. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  95782. /**
  95783. * Use this method to simulate a pointer down on a mesh
  95784. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95785. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95786. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95787. * @returns the current scene
  95788. */
  95789. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  95790. /**
  95791. * Use this method to simulate a pointer up on a mesh
  95792. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95793. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95794. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95795. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  95796. * @returns the current scene
  95797. */
  95798. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  95799. /**
  95800. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  95801. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  95802. * @returns true if the pointer was captured
  95803. */
  95804. isPointerCaptured(pointerId?: number): boolean;
  95805. /**
  95806. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  95807. * @param attachUp defines if you want to attach events to pointerup
  95808. * @param attachDown defines if you want to attach events to pointerdown
  95809. * @param attachMove defines if you want to attach events to pointermove
  95810. */
  95811. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  95812. /** Detaches all event handlers*/
  95813. detachControl(): void;
  95814. /**
  95815. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  95816. * Delay loaded resources are not taking in account
  95817. * @return true if all required resources are ready
  95818. */
  95819. isReady(): boolean;
  95820. /** Resets all cached information relative to material (including effect and visibility) */
  95821. resetCachedMaterial(): void;
  95822. /**
  95823. * Registers a function to be called before every frame render
  95824. * @param func defines the function to register
  95825. */
  95826. registerBeforeRender(func: () => void): void;
  95827. /**
  95828. * Unregisters a function called before every frame render
  95829. * @param func defines the function to unregister
  95830. */
  95831. unregisterBeforeRender(func: () => void): void;
  95832. /**
  95833. * Registers a function to be called after every frame render
  95834. * @param func defines the function to register
  95835. */
  95836. registerAfterRender(func: () => void): void;
  95837. /**
  95838. * Unregisters a function called after every frame render
  95839. * @param func defines the function to unregister
  95840. */
  95841. unregisterAfterRender(func: () => void): void;
  95842. private _executeOnceBeforeRender;
  95843. /**
  95844. * The provided function will run before render once and will be disposed afterwards.
  95845. * A timeout delay can be provided so that the function will be executed in N ms.
  95846. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  95847. * @param func The function to be executed.
  95848. * @param timeout optional delay in ms
  95849. */
  95850. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  95851. /** @hidden */
  95852. _addPendingData(data: any): void;
  95853. /** @hidden */
  95854. _removePendingData(data: any): void;
  95855. /**
  95856. * Returns the number of items waiting to be loaded
  95857. * @returns the number of items waiting to be loaded
  95858. */
  95859. getWaitingItemsCount(): number;
  95860. /**
  95861. * Returns a boolean indicating if the scene is still loading data
  95862. */
  95863. readonly isLoading: boolean;
  95864. /**
  95865. * Registers a function to be executed when the scene is ready
  95866. * @param {Function} func - the function to be executed
  95867. */
  95868. executeWhenReady(func: () => void): void;
  95869. /**
  95870. * Returns a promise that resolves when the scene is ready
  95871. * @returns A promise that resolves when the scene is ready
  95872. */
  95873. whenReadyAsync(): Promise<void>;
  95874. /** @hidden */
  95875. _checkIsReady(): void;
  95876. /**
  95877. * Gets all animatable attached to the scene
  95878. */
  95879. readonly animatables: Animatable[];
  95880. /**
  95881. * Resets the last animation time frame.
  95882. * Useful to override when animations start running when loading a scene for the first time.
  95883. */
  95884. resetLastAnimationTimeFrame(): void;
  95885. /**
  95886. * Gets the current view matrix
  95887. * @returns a Matrix
  95888. */
  95889. getViewMatrix(): Matrix;
  95890. /**
  95891. * Gets the current projection matrix
  95892. * @returns a Matrix
  95893. */
  95894. getProjectionMatrix(): Matrix;
  95895. /**
  95896. * Gets the current transform matrix
  95897. * @returns a Matrix made of View * Projection
  95898. */
  95899. getTransformMatrix(): Matrix;
  95900. /**
  95901. * Sets the current transform matrix
  95902. * @param viewL defines the View matrix to use
  95903. * @param projectionL defines the Projection matrix to use
  95904. * @param viewR defines the right View matrix to use (if provided)
  95905. * @param projectionR defines the right Projection matrix to use (if provided)
  95906. */
  95907. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  95908. /**
  95909. * Gets the uniform buffer used to store scene data
  95910. * @returns a UniformBuffer
  95911. */
  95912. getSceneUniformBuffer(): UniformBuffer;
  95913. /**
  95914. * Gets an unique (relatively to the current scene) Id
  95915. * @returns an unique number for the scene
  95916. */
  95917. getUniqueId(): number;
  95918. /**
  95919. * Add a mesh to the list of scene's meshes
  95920. * @param newMesh defines the mesh to add
  95921. * @param recursive if all child meshes should also be added to the scene
  95922. */
  95923. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  95924. /**
  95925. * Remove a mesh for the list of scene's meshes
  95926. * @param toRemove defines the mesh to remove
  95927. * @param recursive if all child meshes should also be removed from the scene
  95928. * @returns the index where the mesh was in the mesh list
  95929. */
  95930. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  95931. /**
  95932. * Add a transform node to the list of scene's transform nodes
  95933. * @param newTransformNode defines the transform node to add
  95934. */
  95935. addTransformNode(newTransformNode: TransformNode): void;
  95936. /**
  95937. * Remove a transform node for the list of scene's transform nodes
  95938. * @param toRemove defines the transform node to remove
  95939. * @returns the index where the transform node was in the transform node list
  95940. */
  95941. removeTransformNode(toRemove: TransformNode): number;
  95942. /**
  95943. * Remove a skeleton for the list of scene's skeletons
  95944. * @param toRemove defines the skeleton to remove
  95945. * @returns the index where the skeleton was in the skeleton list
  95946. */
  95947. removeSkeleton(toRemove: Skeleton): number;
  95948. /**
  95949. * Remove a morph target for the list of scene's morph targets
  95950. * @param toRemove defines the morph target to remove
  95951. * @returns the index where the morph target was in the morph target list
  95952. */
  95953. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  95954. /**
  95955. * Remove a light for the list of scene's lights
  95956. * @param toRemove defines the light to remove
  95957. * @returns the index where the light was in the light list
  95958. */
  95959. removeLight(toRemove: Light): number;
  95960. /**
  95961. * Remove a camera for the list of scene's cameras
  95962. * @param toRemove defines the camera to remove
  95963. * @returns the index where the camera was in the camera list
  95964. */
  95965. removeCamera(toRemove: Camera): number;
  95966. /**
  95967. * Remove a particle system for the list of scene's particle systems
  95968. * @param toRemove defines the particle system to remove
  95969. * @returns the index where the particle system was in the particle system list
  95970. */
  95971. removeParticleSystem(toRemove: IParticleSystem): number;
  95972. /**
  95973. * Remove a animation for the list of scene's animations
  95974. * @param toRemove defines the animation to remove
  95975. * @returns the index where the animation was in the animation list
  95976. */
  95977. removeAnimation(toRemove: Animation): number;
  95978. /**
  95979. * Will stop the animation of the given target
  95980. * @param target - the target
  95981. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  95982. * @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)
  95983. */
  95984. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  95985. /**
  95986. * Removes the given animation group from this scene.
  95987. * @param toRemove The animation group to remove
  95988. * @returns The index of the removed animation group
  95989. */
  95990. removeAnimationGroup(toRemove: AnimationGroup): number;
  95991. /**
  95992. * Removes the given multi-material from this scene.
  95993. * @param toRemove The multi-material to remove
  95994. * @returns The index of the removed multi-material
  95995. */
  95996. removeMultiMaterial(toRemove: MultiMaterial): number;
  95997. /**
  95998. * Removes the given material from this scene.
  95999. * @param toRemove The material to remove
  96000. * @returns The index of the removed material
  96001. */
  96002. removeMaterial(toRemove: Material): number;
  96003. /**
  96004. * Removes the given action manager from this scene.
  96005. * @param toRemove The action manager to remove
  96006. * @returns The index of the removed action manager
  96007. */
  96008. removeActionManager(toRemove: AbstractActionManager): number;
  96009. /**
  96010. * Removes the given texture from this scene.
  96011. * @param toRemove The texture to remove
  96012. * @returns The index of the removed texture
  96013. */
  96014. removeTexture(toRemove: BaseTexture): number;
  96015. /**
  96016. * Adds the given light to this scene
  96017. * @param newLight The light to add
  96018. */
  96019. addLight(newLight: Light): void;
  96020. /**
  96021. * Sorts the list list based on light priorities
  96022. */
  96023. sortLightsByPriority(): void;
  96024. /**
  96025. * Adds the given camera to this scene
  96026. * @param newCamera The camera to add
  96027. */
  96028. addCamera(newCamera: Camera): void;
  96029. /**
  96030. * Adds the given skeleton to this scene
  96031. * @param newSkeleton The skeleton to add
  96032. */
  96033. addSkeleton(newSkeleton: Skeleton): void;
  96034. /**
  96035. * Adds the given particle system to this scene
  96036. * @param newParticleSystem The particle system to add
  96037. */
  96038. addParticleSystem(newParticleSystem: IParticleSystem): void;
  96039. /**
  96040. * Adds the given animation to this scene
  96041. * @param newAnimation The animation to add
  96042. */
  96043. addAnimation(newAnimation: Animation): void;
  96044. /**
  96045. * Adds the given animation group to this scene.
  96046. * @param newAnimationGroup The animation group to add
  96047. */
  96048. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  96049. /**
  96050. * Adds the given multi-material to this scene
  96051. * @param newMultiMaterial The multi-material to add
  96052. */
  96053. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  96054. /**
  96055. * Adds the given material to this scene
  96056. * @param newMaterial The material to add
  96057. */
  96058. addMaterial(newMaterial: Material): void;
  96059. /**
  96060. * Adds the given morph target to this scene
  96061. * @param newMorphTargetManager The morph target to add
  96062. */
  96063. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  96064. /**
  96065. * Adds the given geometry to this scene
  96066. * @param newGeometry The geometry to add
  96067. */
  96068. addGeometry(newGeometry: Geometry): void;
  96069. /**
  96070. * Adds the given action manager to this scene
  96071. * @param newActionManager The action manager to add
  96072. */
  96073. addActionManager(newActionManager: AbstractActionManager): void;
  96074. /**
  96075. * Adds the given texture to this scene.
  96076. * @param newTexture The texture to add
  96077. */
  96078. addTexture(newTexture: BaseTexture): void;
  96079. /**
  96080. * Switch active camera
  96081. * @param newCamera defines the new active camera
  96082. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  96083. */
  96084. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  96085. /**
  96086. * sets the active camera of the scene using its ID
  96087. * @param id defines the camera's ID
  96088. * @return the new active camera or null if none found.
  96089. */
  96090. setActiveCameraByID(id: string): Nullable<Camera>;
  96091. /**
  96092. * sets the active camera of the scene using its name
  96093. * @param name defines the camera's name
  96094. * @returns the new active camera or null if none found.
  96095. */
  96096. setActiveCameraByName(name: string): Nullable<Camera>;
  96097. /**
  96098. * get an animation group using its name
  96099. * @param name defines the material's name
  96100. * @return the animation group or null if none found.
  96101. */
  96102. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  96103. /**
  96104. * Get a material using its unique id
  96105. * @param uniqueId defines the material's unique id
  96106. * @return the material or null if none found.
  96107. */
  96108. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  96109. /**
  96110. * get a material using its id
  96111. * @param id defines the material's ID
  96112. * @return the material or null if none found.
  96113. */
  96114. getMaterialByID(id: string): Nullable<Material>;
  96115. /**
  96116. * Gets a the last added material using a given id
  96117. * @param id defines the material's ID
  96118. * @return the last material with the given id or null if none found.
  96119. */
  96120. getLastMaterialByID(id: string): Nullable<Material>;
  96121. /**
  96122. * Gets a material using its name
  96123. * @param name defines the material's name
  96124. * @return the material or null if none found.
  96125. */
  96126. getMaterialByName(name: string): Nullable<Material>;
  96127. /**
  96128. * Gets a camera using its id
  96129. * @param id defines the id to look for
  96130. * @returns the camera or null if not found
  96131. */
  96132. getCameraByID(id: string): Nullable<Camera>;
  96133. /**
  96134. * Gets a camera using its unique id
  96135. * @param uniqueId defines the unique id to look for
  96136. * @returns the camera or null if not found
  96137. */
  96138. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  96139. /**
  96140. * Gets a camera using its name
  96141. * @param name defines the camera's name
  96142. * @return the camera or null if none found.
  96143. */
  96144. getCameraByName(name: string): Nullable<Camera>;
  96145. /**
  96146. * Gets a bone using its id
  96147. * @param id defines the bone's id
  96148. * @return the bone or null if not found
  96149. */
  96150. getBoneByID(id: string): Nullable<Bone>;
  96151. /**
  96152. * Gets a bone using its id
  96153. * @param name defines the bone's name
  96154. * @return the bone or null if not found
  96155. */
  96156. getBoneByName(name: string): Nullable<Bone>;
  96157. /**
  96158. * Gets a light node using its name
  96159. * @param name defines the the light's name
  96160. * @return the light or null if none found.
  96161. */
  96162. getLightByName(name: string): Nullable<Light>;
  96163. /**
  96164. * Gets a light node using its id
  96165. * @param id defines the light's id
  96166. * @return the light or null if none found.
  96167. */
  96168. getLightByID(id: string): Nullable<Light>;
  96169. /**
  96170. * Gets a light node using its scene-generated unique ID
  96171. * @param uniqueId defines the light's unique id
  96172. * @return the light or null if none found.
  96173. */
  96174. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  96175. /**
  96176. * Gets a particle system by id
  96177. * @param id defines the particle system id
  96178. * @return the corresponding system or null if none found
  96179. */
  96180. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  96181. /**
  96182. * Gets a geometry using its ID
  96183. * @param id defines the geometry's id
  96184. * @return the geometry or null if none found.
  96185. */
  96186. getGeometryByID(id: string): Nullable<Geometry>;
  96187. private _getGeometryByUniqueID;
  96188. /**
  96189. * Add a new geometry to this scene
  96190. * @param geometry defines the geometry to be added to the scene.
  96191. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  96192. * @return a boolean defining if the geometry was added or not
  96193. */
  96194. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  96195. /**
  96196. * Removes an existing geometry
  96197. * @param geometry defines the geometry to be removed from the scene
  96198. * @return a boolean defining if the geometry was removed or not
  96199. */
  96200. removeGeometry(geometry: Geometry): boolean;
  96201. /**
  96202. * Gets the list of geometries attached to the scene
  96203. * @returns an array of Geometry
  96204. */
  96205. getGeometries(): Geometry[];
  96206. /**
  96207. * Gets the first added mesh found of a given ID
  96208. * @param id defines the id to search for
  96209. * @return the mesh found or null if not found at all
  96210. */
  96211. getMeshByID(id: string): Nullable<AbstractMesh>;
  96212. /**
  96213. * Gets a list of meshes using their id
  96214. * @param id defines the id to search for
  96215. * @returns a list of meshes
  96216. */
  96217. getMeshesByID(id: string): Array<AbstractMesh>;
  96218. /**
  96219. * Gets the first added transform node found of a given ID
  96220. * @param id defines the id to search for
  96221. * @return the found transform node or null if not found at all.
  96222. */
  96223. getTransformNodeByID(id: string): Nullable<TransformNode>;
  96224. /**
  96225. * Gets a transform node with its auto-generated unique id
  96226. * @param uniqueId efines the unique id to search for
  96227. * @return the found transform node or null if not found at all.
  96228. */
  96229. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  96230. /**
  96231. * Gets a list of transform nodes using their id
  96232. * @param id defines the id to search for
  96233. * @returns a list of transform nodes
  96234. */
  96235. getTransformNodesByID(id: string): Array<TransformNode>;
  96236. /**
  96237. * Gets a mesh with its auto-generated unique id
  96238. * @param uniqueId defines the unique id to search for
  96239. * @return the found mesh or null if not found at all.
  96240. */
  96241. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  96242. /**
  96243. * Gets a the last added mesh using a given id
  96244. * @param id defines the id to search for
  96245. * @return the found mesh or null if not found at all.
  96246. */
  96247. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  96248. /**
  96249. * Gets a the last added node (Mesh, Camera, Light) using a given id
  96250. * @param id defines the id to search for
  96251. * @return the found node or null if not found at all
  96252. */
  96253. getLastEntryByID(id: string): Nullable<Node>;
  96254. /**
  96255. * Gets a node (Mesh, Camera, Light) using a given id
  96256. * @param id defines the id to search for
  96257. * @return the found node or null if not found at all
  96258. */
  96259. getNodeByID(id: string): Nullable<Node>;
  96260. /**
  96261. * Gets a node (Mesh, Camera, Light) using a given name
  96262. * @param name defines the name to search for
  96263. * @return the found node or null if not found at all.
  96264. */
  96265. getNodeByName(name: string): Nullable<Node>;
  96266. /**
  96267. * Gets a mesh using a given name
  96268. * @param name defines the name to search for
  96269. * @return the found mesh or null if not found at all.
  96270. */
  96271. getMeshByName(name: string): Nullable<AbstractMesh>;
  96272. /**
  96273. * Gets a transform node using a given name
  96274. * @param name defines the name to search for
  96275. * @return the found transform node or null if not found at all.
  96276. */
  96277. getTransformNodeByName(name: string): Nullable<TransformNode>;
  96278. /**
  96279. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  96280. * @param id defines the id to search for
  96281. * @return the found skeleton or null if not found at all.
  96282. */
  96283. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  96284. /**
  96285. * Gets a skeleton using a given auto generated unique id
  96286. * @param uniqueId defines the unique id to search for
  96287. * @return the found skeleton or null if not found at all.
  96288. */
  96289. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  96290. /**
  96291. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  96292. * @param id defines the id to search for
  96293. * @return the found skeleton or null if not found at all.
  96294. */
  96295. getSkeletonById(id: string): Nullable<Skeleton>;
  96296. /**
  96297. * Gets a skeleton using a given name
  96298. * @param name defines the name to search for
  96299. * @return the found skeleton or null if not found at all.
  96300. */
  96301. getSkeletonByName(name: string): Nullable<Skeleton>;
  96302. /**
  96303. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  96304. * @param id defines the id to search for
  96305. * @return the found morph target manager or null if not found at all.
  96306. */
  96307. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  96308. /**
  96309. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  96310. * @param id defines the id to search for
  96311. * @return the found morph target or null if not found at all.
  96312. */
  96313. getMorphTargetById(id: string): Nullable<MorphTarget>;
  96314. /**
  96315. * Gets a boolean indicating if the given mesh is active
  96316. * @param mesh defines the mesh to look for
  96317. * @returns true if the mesh is in the active list
  96318. */
  96319. isActiveMesh(mesh: AbstractMesh): boolean;
  96320. /**
  96321. * Return a unique id as a string which can serve as an identifier for the scene
  96322. */
  96323. readonly uid: string;
  96324. /**
  96325. * Add an externaly attached data from its key.
  96326. * This method call will fail and return false, if such key already exists.
  96327. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  96328. * @param key the unique key that identifies the data
  96329. * @param data the data object to associate to the key for this Engine instance
  96330. * @return true if no such key were already present and the data was added successfully, false otherwise
  96331. */
  96332. addExternalData<T>(key: string, data: T): boolean;
  96333. /**
  96334. * Get an externaly attached data from its key
  96335. * @param key the unique key that identifies the data
  96336. * @return the associated data, if present (can be null), or undefined if not present
  96337. */
  96338. getExternalData<T>(key: string): Nullable<T>;
  96339. /**
  96340. * Get an externaly attached data from its key, create it using a factory if it's not already present
  96341. * @param key the unique key that identifies the data
  96342. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  96343. * @return the associated data, can be null if the factory returned null.
  96344. */
  96345. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  96346. /**
  96347. * Remove an externaly attached data from the Engine instance
  96348. * @param key the unique key that identifies the data
  96349. * @return true if the data was successfully removed, false if it doesn't exist
  96350. */
  96351. removeExternalData(key: string): boolean;
  96352. private _evaluateSubMesh;
  96353. /**
  96354. * Clear the processed materials smart array preventing retention point in material dispose.
  96355. */
  96356. freeProcessedMaterials(): void;
  96357. private _preventFreeActiveMeshesAndRenderingGroups;
  96358. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  96359. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  96360. * when disposing several meshes in a row or a hierarchy of meshes.
  96361. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  96362. */
  96363. blockfreeActiveMeshesAndRenderingGroups: boolean;
  96364. /**
  96365. * Clear the active meshes smart array preventing retention point in mesh dispose.
  96366. */
  96367. freeActiveMeshes(): void;
  96368. /**
  96369. * Clear the info related to rendering groups preventing retention points during dispose.
  96370. */
  96371. freeRenderingGroups(): void;
  96372. /** @hidden */
  96373. _isInIntermediateRendering(): boolean;
  96374. /**
  96375. * Lambda returning the list of potentially active meshes.
  96376. */
  96377. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  96378. /**
  96379. * Lambda returning the list of potentially active sub meshes.
  96380. */
  96381. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  96382. /**
  96383. * Lambda returning the list of potentially intersecting sub meshes.
  96384. */
  96385. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  96386. /**
  96387. * Lambda returning the list of potentially colliding sub meshes.
  96388. */
  96389. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  96390. private _activeMeshesFrozen;
  96391. /**
  96392. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  96393. * @returns the current scene
  96394. */
  96395. freezeActiveMeshes(): Scene;
  96396. /**
  96397. * Use this function to restart evaluating active meshes on every frame
  96398. * @returns the current scene
  96399. */
  96400. unfreezeActiveMeshes(): Scene;
  96401. private _evaluateActiveMeshes;
  96402. private _activeMesh;
  96403. /**
  96404. * Update the transform matrix to update from the current active camera
  96405. * @param force defines a boolean used to force the update even if cache is up to date
  96406. */
  96407. updateTransformMatrix(force?: boolean): void;
  96408. private _bindFrameBuffer;
  96409. /** @hidden */
  96410. _allowPostProcessClearColor: boolean;
  96411. /** @hidden */
  96412. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  96413. private _processSubCameras;
  96414. private _checkIntersections;
  96415. /** @hidden */
  96416. _advancePhysicsEngineStep(step: number): void;
  96417. /**
  96418. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  96419. */
  96420. getDeterministicFrameTime: () => number;
  96421. /** @hidden */
  96422. _animate(): void;
  96423. /** Execute all animations (for a frame) */
  96424. animate(): void;
  96425. /**
  96426. * Render the scene
  96427. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  96428. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  96429. */
  96430. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  96431. /**
  96432. * Freeze all materials
  96433. * A frozen material will not be updatable but should be faster to render
  96434. */
  96435. freezeMaterials(): void;
  96436. /**
  96437. * Unfreeze all materials
  96438. * A frozen material will not be updatable but should be faster to render
  96439. */
  96440. unfreezeMaterials(): void;
  96441. /**
  96442. * Releases all held ressources
  96443. */
  96444. dispose(): void;
  96445. /**
  96446. * Gets if the scene is already disposed
  96447. */
  96448. readonly isDisposed: boolean;
  96449. /**
  96450. * Call this function to reduce memory footprint of the scene.
  96451. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  96452. */
  96453. clearCachedVertexData(): void;
  96454. /**
  96455. * This function will remove the local cached buffer data from texture.
  96456. * It will save memory but will prevent the texture from being rebuilt
  96457. */
  96458. cleanCachedTextureBuffer(): void;
  96459. /**
  96460. * Get the world extend vectors with an optional filter
  96461. *
  96462. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  96463. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  96464. */
  96465. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  96466. min: Vector3;
  96467. max: Vector3;
  96468. };
  96469. /**
  96470. * Creates a ray that can be used to pick in the scene
  96471. * @param x defines the x coordinate of the origin (on-screen)
  96472. * @param y defines the y coordinate of the origin (on-screen)
  96473. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  96474. * @param camera defines the camera to use for the picking
  96475. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  96476. * @returns a Ray
  96477. */
  96478. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  96479. /**
  96480. * Creates a ray that can be used to pick in the scene
  96481. * @param x defines the x coordinate of the origin (on-screen)
  96482. * @param y defines the y coordinate of the origin (on-screen)
  96483. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  96484. * @param result defines the ray where to store the picking ray
  96485. * @param camera defines the camera to use for the picking
  96486. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  96487. * @returns the current scene
  96488. */
  96489. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  96490. /**
  96491. * Creates a ray that can be used to pick in the scene
  96492. * @param x defines the x coordinate of the origin (on-screen)
  96493. * @param y defines the y coordinate of the origin (on-screen)
  96494. * @param camera defines the camera to use for the picking
  96495. * @returns a Ray
  96496. */
  96497. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  96498. /**
  96499. * Creates a ray that can be used to pick in the scene
  96500. * @param x defines the x coordinate of the origin (on-screen)
  96501. * @param y defines the y coordinate of the origin (on-screen)
  96502. * @param result defines the ray where to store the picking ray
  96503. * @param camera defines the camera to use for the picking
  96504. * @returns the current scene
  96505. */
  96506. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  96507. /** Launch a ray to try to pick a mesh in the scene
  96508. * @param x position on screen
  96509. * @param y position on screen
  96510. * @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
  96511. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  96512. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  96513. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96514. * @returns a PickingInfo
  96515. */
  96516. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  96517. /** Use the given ray to pick a mesh in the scene
  96518. * @param ray The ray to use to pick meshes
  96519. * @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
  96520. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  96521. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96522. * @returns a PickingInfo
  96523. */
  96524. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  96525. /**
  96526. * Launch a ray to try to pick a mesh in the scene
  96527. * @param x X position on screen
  96528. * @param y Y position on screen
  96529. * @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
  96530. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  96531. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96532. * @returns an array of PickingInfo
  96533. */
  96534. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  96535. /**
  96536. * Launch a ray to try to pick a mesh in the scene
  96537. * @param ray Ray to use
  96538. * @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
  96539. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96540. * @returns an array of PickingInfo
  96541. */
  96542. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  96543. /**
  96544. * Force the value of meshUnderPointer
  96545. * @param mesh defines the mesh to use
  96546. */
  96547. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  96548. /**
  96549. * Gets the mesh under the pointer
  96550. * @returns a Mesh or null if no mesh is under the pointer
  96551. */
  96552. getPointerOverMesh(): Nullable<AbstractMesh>;
  96553. /** @hidden */
  96554. _rebuildGeometries(): void;
  96555. /** @hidden */
  96556. _rebuildTextures(): void;
  96557. private _getByTags;
  96558. /**
  96559. * Get a list of meshes by tags
  96560. * @param tagsQuery defines the tags query to use
  96561. * @param forEach defines a predicate used to filter results
  96562. * @returns an array of Mesh
  96563. */
  96564. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  96565. /**
  96566. * Get a list of cameras by tags
  96567. * @param tagsQuery defines the tags query to use
  96568. * @param forEach defines a predicate used to filter results
  96569. * @returns an array of Camera
  96570. */
  96571. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  96572. /**
  96573. * Get a list of lights by tags
  96574. * @param tagsQuery defines the tags query to use
  96575. * @param forEach defines a predicate used to filter results
  96576. * @returns an array of Light
  96577. */
  96578. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  96579. /**
  96580. * Get a list of materials by tags
  96581. * @param tagsQuery defines the tags query to use
  96582. * @param forEach defines a predicate used to filter results
  96583. * @returns an array of Material
  96584. */
  96585. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  96586. /**
  96587. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  96588. * This allowed control for front to back rendering or reversly depending of the special needs.
  96589. *
  96590. * @param renderingGroupId The rendering group id corresponding to its index
  96591. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  96592. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  96593. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  96594. */
  96595. 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;
  96596. /**
  96597. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  96598. *
  96599. * @param renderingGroupId The rendering group id corresponding to its index
  96600. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  96601. * @param depth Automatically clears depth between groups if true and autoClear is true.
  96602. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  96603. */
  96604. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  96605. /**
  96606. * Gets the current auto clear configuration for one rendering group of the rendering
  96607. * manager.
  96608. * @param index the rendering group index to get the information for
  96609. * @returns The auto clear setup for the requested rendering group
  96610. */
  96611. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  96612. private _blockMaterialDirtyMechanism;
  96613. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  96614. blockMaterialDirtyMechanism: boolean;
  96615. /**
  96616. * Will flag all materials as dirty to trigger new shader compilation
  96617. * @param flag defines the flag used to specify which material part must be marked as dirty
  96618. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  96619. */
  96620. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  96621. /** @hidden */
  96622. _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;
  96623. /** @hidden */
  96624. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  96625. }
  96626. }
  96627. declare module BABYLON {
  96628. /**
  96629. * Set of assets to keep when moving a scene into an asset container.
  96630. */
  96631. export class KeepAssets extends AbstractScene {
  96632. }
  96633. /**
  96634. * Container with a set of assets that can be added or removed from a scene.
  96635. */
  96636. export class AssetContainer extends AbstractScene {
  96637. /**
  96638. * The scene the AssetContainer belongs to.
  96639. */
  96640. scene: Scene;
  96641. /**
  96642. * Instantiates an AssetContainer.
  96643. * @param scene The scene the AssetContainer belongs to.
  96644. */
  96645. constructor(scene: Scene);
  96646. /**
  96647. * Adds all the assets from the container to the scene.
  96648. */
  96649. addAllToScene(): void;
  96650. /**
  96651. * Removes all the assets in the container from the scene
  96652. */
  96653. removeAllFromScene(): void;
  96654. /**
  96655. * Disposes all the assets in the container
  96656. */
  96657. dispose(): void;
  96658. private _moveAssets;
  96659. /**
  96660. * Removes all the assets contained in the scene and adds them to the container.
  96661. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  96662. */
  96663. moveAllFromScene(keepAssets?: KeepAssets): void;
  96664. /**
  96665. * 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.
  96666. * @returns the root mesh
  96667. */
  96668. createRootMesh(): Mesh;
  96669. }
  96670. }
  96671. declare module BABYLON {
  96672. /**
  96673. * Defines how the parser contract is defined.
  96674. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  96675. */
  96676. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  96677. /**
  96678. * Defines how the individual parser contract is defined.
  96679. * These parser can parse an individual asset
  96680. */
  96681. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  96682. /**
  96683. * Base class of the scene acting as a container for the different elements composing a scene.
  96684. * This class is dynamically extended by the different components of the scene increasing
  96685. * flexibility and reducing coupling
  96686. */
  96687. export abstract class AbstractScene {
  96688. /**
  96689. * Stores the list of available parsers in the application.
  96690. */
  96691. private static _BabylonFileParsers;
  96692. /**
  96693. * Stores the list of available individual parsers in the application.
  96694. */
  96695. private static _IndividualBabylonFileParsers;
  96696. /**
  96697. * Adds a parser in the list of available ones
  96698. * @param name Defines the name of the parser
  96699. * @param parser Defines the parser to add
  96700. */
  96701. static AddParser(name: string, parser: BabylonFileParser): void;
  96702. /**
  96703. * Gets a general parser from the list of avaialble ones
  96704. * @param name Defines the name of the parser
  96705. * @returns the requested parser or null
  96706. */
  96707. static GetParser(name: string): Nullable<BabylonFileParser>;
  96708. /**
  96709. * Adds n individual parser in the list of available ones
  96710. * @param name Defines the name of the parser
  96711. * @param parser Defines the parser to add
  96712. */
  96713. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  96714. /**
  96715. * Gets an individual parser from the list of avaialble ones
  96716. * @param name Defines the name of the parser
  96717. * @returns the requested parser or null
  96718. */
  96719. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  96720. /**
  96721. * Parser json data and populate both a scene and its associated container object
  96722. * @param jsonData Defines the data to parse
  96723. * @param scene Defines the scene to parse the data for
  96724. * @param container Defines the container attached to the parsing sequence
  96725. * @param rootUrl Defines the root url of the data
  96726. */
  96727. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  96728. /**
  96729. * Gets the list of root nodes (ie. nodes with no parent)
  96730. */
  96731. rootNodes: Node[];
  96732. /** All of the cameras added to this scene
  96733. * @see http://doc.babylonjs.com/babylon101/cameras
  96734. */
  96735. cameras: Camera[];
  96736. /**
  96737. * All of the lights added to this scene
  96738. * @see http://doc.babylonjs.com/babylon101/lights
  96739. */
  96740. lights: Light[];
  96741. /**
  96742. * All of the (abstract) meshes added to this scene
  96743. */
  96744. meshes: AbstractMesh[];
  96745. /**
  96746. * The list of skeletons added to the scene
  96747. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96748. */
  96749. skeletons: Skeleton[];
  96750. /**
  96751. * All of the particle systems added to this scene
  96752. * @see http://doc.babylonjs.com/babylon101/particles
  96753. */
  96754. particleSystems: IParticleSystem[];
  96755. /**
  96756. * Gets a list of Animations associated with the scene
  96757. */
  96758. animations: Animation[];
  96759. /**
  96760. * All of the animation groups added to this scene
  96761. * @see http://doc.babylonjs.com/how_to/group
  96762. */
  96763. animationGroups: AnimationGroup[];
  96764. /**
  96765. * All of the multi-materials added to this scene
  96766. * @see http://doc.babylonjs.com/how_to/multi_materials
  96767. */
  96768. multiMaterials: MultiMaterial[];
  96769. /**
  96770. * All of the materials added to this scene
  96771. * In the context of a Scene, it is not supposed to be modified manually.
  96772. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  96773. * Note also that the order of the Material wihin the array is not significant and might change.
  96774. * @see http://doc.babylonjs.com/babylon101/materials
  96775. */
  96776. materials: Material[];
  96777. /**
  96778. * The list of morph target managers added to the scene
  96779. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  96780. */
  96781. morphTargetManagers: MorphTargetManager[];
  96782. /**
  96783. * The list of geometries used in the scene.
  96784. */
  96785. geometries: Geometry[];
  96786. /**
  96787. * All of the tranform nodes added to this scene
  96788. * In the context of a Scene, it is not supposed to be modified manually.
  96789. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  96790. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  96791. * @see http://doc.babylonjs.com/how_to/transformnode
  96792. */
  96793. transformNodes: TransformNode[];
  96794. /**
  96795. * ActionManagers available on the scene.
  96796. */
  96797. actionManagers: AbstractActionManager[];
  96798. /**
  96799. * Textures to keep.
  96800. */
  96801. textures: BaseTexture[];
  96802. /**
  96803. * Environment texture for the scene
  96804. */
  96805. environmentTexture: Nullable<BaseTexture>;
  96806. }
  96807. }
  96808. declare module BABYLON {
  96809. /**
  96810. * Interface used to define options for Sound class
  96811. */
  96812. export interface ISoundOptions {
  96813. /**
  96814. * Does the sound autoplay once loaded.
  96815. */
  96816. autoplay?: boolean;
  96817. /**
  96818. * Does the sound loop after it finishes playing once.
  96819. */
  96820. loop?: boolean;
  96821. /**
  96822. * Sound's volume
  96823. */
  96824. volume?: number;
  96825. /**
  96826. * Is it a spatial sound?
  96827. */
  96828. spatialSound?: boolean;
  96829. /**
  96830. * Maximum distance to hear that sound
  96831. */
  96832. maxDistance?: number;
  96833. /**
  96834. * Uses user defined attenuation function
  96835. */
  96836. useCustomAttenuation?: boolean;
  96837. /**
  96838. * Define the roll off factor of spatial sounds.
  96839. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96840. */
  96841. rolloffFactor?: number;
  96842. /**
  96843. * Define the reference distance the sound should be heard perfectly.
  96844. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96845. */
  96846. refDistance?: number;
  96847. /**
  96848. * Define the distance attenuation model the sound will follow.
  96849. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96850. */
  96851. distanceModel?: string;
  96852. /**
  96853. * Defines the playback speed (1 by default)
  96854. */
  96855. playbackRate?: number;
  96856. /**
  96857. * Defines if the sound is from a streaming source
  96858. */
  96859. streaming?: boolean;
  96860. /**
  96861. * Defines an optional length (in seconds) inside the sound file
  96862. */
  96863. length?: number;
  96864. /**
  96865. * Defines an optional offset (in seconds) inside the sound file
  96866. */
  96867. offset?: number;
  96868. /**
  96869. * If true, URLs will not be required to state the audio file codec to use.
  96870. */
  96871. skipCodecCheck?: boolean;
  96872. }
  96873. /**
  96874. * Defines a sound that can be played in the application.
  96875. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  96876. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96877. */
  96878. export class Sound {
  96879. /**
  96880. * The name of the sound in the scene.
  96881. */
  96882. name: string;
  96883. /**
  96884. * Does the sound autoplay once loaded.
  96885. */
  96886. autoplay: boolean;
  96887. /**
  96888. * Does the sound loop after it finishes playing once.
  96889. */
  96890. loop: boolean;
  96891. /**
  96892. * Does the sound use a custom attenuation curve to simulate the falloff
  96893. * happening when the source gets further away from the camera.
  96894. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  96895. */
  96896. useCustomAttenuation: boolean;
  96897. /**
  96898. * The sound track id this sound belongs to.
  96899. */
  96900. soundTrackId: number;
  96901. /**
  96902. * Is this sound currently played.
  96903. */
  96904. isPlaying: boolean;
  96905. /**
  96906. * Is this sound currently paused.
  96907. */
  96908. isPaused: boolean;
  96909. /**
  96910. * Does this sound enables spatial sound.
  96911. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96912. */
  96913. spatialSound: boolean;
  96914. /**
  96915. * Define the reference distance the sound should be heard perfectly.
  96916. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96917. */
  96918. refDistance: number;
  96919. /**
  96920. * Define the roll off factor of spatial sounds.
  96921. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96922. */
  96923. rolloffFactor: number;
  96924. /**
  96925. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  96926. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96927. */
  96928. maxDistance: number;
  96929. /**
  96930. * Define the distance attenuation model the sound will follow.
  96931. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96932. */
  96933. distanceModel: string;
  96934. /**
  96935. * @hidden
  96936. * Back Compat
  96937. **/
  96938. onended: () => any;
  96939. /**
  96940. * Observable event when the current playing sound finishes.
  96941. */
  96942. onEndedObservable: Observable<Sound>;
  96943. private _panningModel;
  96944. private _playbackRate;
  96945. private _streaming;
  96946. private _startTime;
  96947. private _startOffset;
  96948. private _position;
  96949. /** @hidden */
  96950. _positionInEmitterSpace: boolean;
  96951. private _localDirection;
  96952. private _volume;
  96953. private _isReadyToPlay;
  96954. private _isDirectional;
  96955. private _readyToPlayCallback;
  96956. private _audioBuffer;
  96957. private _soundSource;
  96958. private _streamingSource;
  96959. private _soundPanner;
  96960. private _soundGain;
  96961. private _inputAudioNode;
  96962. private _outputAudioNode;
  96963. private _coneInnerAngle;
  96964. private _coneOuterAngle;
  96965. private _coneOuterGain;
  96966. private _scene;
  96967. private _connectedTransformNode;
  96968. private _customAttenuationFunction;
  96969. private _registerFunc;
  96970. private _isOutputConnected;
  96971. private _htmlAudioElement;
  96972. private _urlType;
  96973. private _length?;
  96974. private _offset?;
  96975. /** @hidden */
  96976. static _SceneComponentInitialization: (scene: Scene) => void;
  96977. /**
  96978. * Create a sound and attach it to a scene
  96979. * @param name Name of your sound
  96980. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  96981. * @param scene defines the scene the sound belongs to
  96982. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  96983. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  96984. */
  96985. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  96986. /**
  96987. * Release the sound and its associated resources
  96988. */
  96989. dispose(): void;
  96990. /**
  96991. * Gets if the sounds is ready to be played or not.
  96992. * @returns true if ready, otherwise false
  96993. */
  96994. isReady(): boolean;
  96995. private _soundLoaded;
  96996. /**
  96997. * Sets the data of the sound from an audiobuffer
  96998. * @param audioBuffer The audioBuffer containing the data
  96999. */
  97000. setAudioBuffer(audioBuffer: AudioBuffer): void;
  97001. /**
  97002. * Updates the current sounds options such as maxdistance, loop...
  97003. * @param options A JSON object containing values named as the object properties
  97004. */
  97005. updateOptions(options: ISoundOptions): void;
  97006. private _createSpatialParameters;
  97007. private _updateSpatialParameters;
  97008. /**
  97009. * Switch the panning model to HRTF:
  97010. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  97011. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97012. */
  97013. switchPanningModelToHRTF(): void;
  97014. /**
  97015. * Switch the panning model to Equal Power:
  97016. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  97017. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97018. */
  97019. switchPanningModelToEqualPower(): void;
  97020. private _switchPanningModel;
  97021. /**
  97022. * Connect this sound to a sound track audio node like gain...
  97023. * @param soundTrackAudioNode the sound track audio node to connect to
  97024. */
  97025. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  97026. /**
  97027. * Transform this sound into a directional source
  97028. * @param coneInnerAngle Size of the inner cone in degree
  97029. * @param coneOuterAngle Size of the outer cone in degree
  97030. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  97031. */
  97032. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  97033. /**
  97034. * Gets or sets the inner angle for the directional cone.
  97035. */
  97036. /**
  97037. * Gets or sets the inner angle for the directional cone.
  97038. */
  97039. directionalConeInnerAngle: number;
  97040. /**
  97041. * Gets or sets the outer angle for the directional cone.
  97042. */
  97043. /**
  97044. * Gets or sets the outer angle for the directional cone.
  97045. */
  97046. directionalConeOuterAngle: number;
  97047. /**
  97048. * Sets the position of the emitter if spatial sound is enabled
  97049. * @param newPosition Defines the new posisiton
  97050. */
  97051. setPosition(newPosition: Vector3): void;
  97052. /**
  97053. * Sets the local direction of the emitter if spatial sound is enabled
  97054. * @param newLocalDirection Defines the new local direction
  97055. */
  97056. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  97057. private _updateDirection;
  97058. /** @hidden */
  97059. updateDistanceFromListener(): void;
  97060. /**
  97061. * Sets a new custom attenuation function for the sound.
  97062. * @param callback Defines the function used for the attenuation
  97063. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  97064. */
  97065. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  97066. /**
  97067. * Play the sound
  97068. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  97069. * @param offset (optional) Start the sound at a specific time in seconds
  97070. * @param length (optional) Sound duration (in seconds)
  97071. */
  97072. play(time?: number, offset?: number, length?: number): void;
  97073. private _onended;
  97074. /**
  97075. * Stop the sound
  97076. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  97077. */
  97078. stop(time?: number): void;
  97079. /**
  97080. * Put the sound in pause
  97081. */
  97082. pause(): void;
  97083. /**
  97084. * Sets a dedicated volume for this sounds
  97085. * @param newVolume Define the new volume of the sound
  97086. * @param time Define time for gradual change to new volume
  97087. */
  97088. setVolume(newVolume: number, time?: number): void;
  97089. /**
  97090. * Set the sound play back rate
  97091. * @param newPlaybackRate Define the playback rate the sound should be played at
  97092. */
  97093. setPlaybackRate(newPlaybackRate: number): void;
  97094. /**
  97095. * Gets the volume of the sound.
  97096. * @returns the volume of the sound
  97097. */
  97098. getVolume(): number;
  97099. /**
  97100. * Attach the sound to a dedicated mesh
  97101. * @param transformNode The transform node to connect the sound with
  97102. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  97103. */
  97104. attachToMesh(transformNode: TransformNode): void;
  97105. /**
  97106. * Detach the sound from the previously attached mesh
  97107. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  97108. */
  97109. detachFromMesh(): void;
  97110. private _onRegisterAfterWorldMatrixUpdate;
  97111. /**
  97112. * Clone the current sound in the scene.
  97113. * @returns the new sound clone
  97114. */
  97115. clone(): Nullable<Sound>;
  97116. /**
  97117. * Gets the current underlying audio buffer containing the data
  97118. * @returns the audio buffer
  97119. */
  97120. getAudioBuffer(): Nullable<AudioBuffer>;
  97121. /**
  97122. * Serializes the Sound in a JSON representation
  97123. * @returns the JSON representation of the sound
  97124. */
  97125. serialize(): any;
  97126. /**
  97127. * Parse a JSON representation of a sound to innstantiate in a given scene
  97128. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  97129. * @param scene Define the scene the new parsed sound should be created in
  97130. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  97131. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  97132. * @returns the newly parsed sound
  97133. */
  97134. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  97135. }
  97136. }
  97137. declare module BABYLON {
  97138. /**
  97139. * This defines an action helpful to play a defined sound on a triggered action.
  97140. */
  97141. export class PlaySoundAction extends Action {
  97142. private _sound;
  97143. /**
  97144. * Instantiate the action
  97145. * @param triggerOptions defines the trigger options
  97146. * @param sound defines the sound to play
  97147. * @param condition defines the trigger related conditions
  97148. */
  97149. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  97150. /** @hidden */
  97151. _prepare(): void;
  97152. /**
  97153. * Execute the action and play the sound.
  97154. */
  97155. execute(): void;
  97156. /**
  97157. * Serializes the actions and its related information.
  97158. * @param parent defines the object to serialize in
  97159. * @returns the serialized object
  97160. */
  97161. serialize(parent: any): any;
  97162. }
  97163. /**
  97164. * This defines an action helpful to stop a defined sound on a triggered action.
  97165. */
  97166. export class StopSoundAction extends Action {
  97167. private _sound;
  97168. /**
  97169. * Instantiate the action
  97170. * @param triggerOptions defines the trigger options
  97171. * @param sound defines the sound to stop
  97172. * @param condition defines the trigger related conditions
  97173. */
  97174. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  97175. /** @hidden */
  97176. _prepare(): void;
  97177. /**
  97178. * Execute the action and stop the sound.
  97179. */
  97180. execute(): void;
  97181. /**
  97182. * Serializes the actions and its related information.
  97183. * @param parent defines the object to serialize in
  97184. * @returns the serialized object
  97185. */
  97186. serialize(parent: any): any;
  97187. }
  97188. }
  97189. declare module BABYLON {
  97190. /**
  97191. * This defines an action responsible to change the value of a property
  97192. * by interpolating between its current value and the newly set one once triggered.
  97193. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  97194. */
  97195. export class InterpolateValueAction extends Action {
  97196. /**
  97197. * Defines the path of the property where the value should be interpolated
  97198. */
  97199. propertyPath: string;
  97200. /**
  97201. * Defines the target value at the end of the interpolation.
  97202. */
  97203. value: any;
  97204. /**
  97205. * Defines the time it will take for the property to interpolate to the value.
  97206. */
  97207. duration: number;
  97208. /**
  97209. * Defines if the other scene animations should be stopped when the action has been triggered
  97210. */
  97211. stopOtherAnimations?: boolean;
  97212. /**
  97213. * Defines a callback raised once the interpolation animation has been done.
  97214. */
  97215. onInterpolationDone?: () => void;
  97216. /**
  97217. * Observable triggered once the interpolation animation has been done.
  97218. */
  97219. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  97220. private _target;
  97221. private _effectiveTarget;
  97222. private _property;
  97223. /**
  97224. * Instantiate the action
  97225. * @param triggerOptions defines the trigger options
  97226. * @param target defines the object containing the value to interpolate
  97227. * @param propertyPath defines the path to the property in the target object
  97228. * @param value defines the target value at the end of the interpolation
  97229. * @param duration deines the time it will take for the property to interpolate to the value.
  97230. * @param condition defines the trigger related conditions
  97231. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  97232. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  97233. */
  97234. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  97235. /** @hidden */
  97236. _prepare(): void;
  97237. /**
  97238. * Execute the action starts the value interpolation.
  97239. */
  97240. execute(): void;
  97241. /**
  97242. * Serializes the actions and its related information.
  97243. * @param parent defines the object to serialize in
  97244. * @returns the serialized object
  97245. */
  97246. serialize(parent: any): any;
  97247. }
  97248. }
  97249. declare module BABYLON {
  97250. /**
  97251. * Options allowed during the creation of a sound track.
  97252. */
  97253. export interface ISoundTrackOptions {
  97254. /**
  97255. * The volume the sound track should take during creation
  97256. */
  97257. volume?: number;
  97258. /**
  97259. * Define if the sound track is the main sound track of the scene
  97260. */
  97261. mainTrack?: boolean;
  97262. }
  97263. /**
  97264. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  97265. * It will be also used in a future release to apply effects on a specific track.
  97266. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  97267. */
  97268. export class SoundTrack {
  97269. /**
  97270. * The unique identifier of the sound track in the scene.
  97271. */
  97272. id: number;
  97273. /**
  97274. * The list of sounds included in the sound track.
  97275. */
  97276. soundCollection: Array<Sound>;
  97277. private _outputAudioNode;
  97278. private _scene;
  97279. private _isMainTrack;
  97280. private _connectedAnalyser;
  97281. private _options;
  97282. private _isInitialized;
  97283. /**
  97284. * Creates a new sound track.
  97285. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  97286. * @param scene Define the scene the sound track belongs to
  97287. * @param options
  97288. */
  97289. constructor(scene: Scene, options?: ISoundTrackOptions);
  97290. private _initializeSoundTrackAudioGraph;
  97291. /**
  97292. * Release the sound track and its associated resources
  97293. */
  97294. dispose(): void;
  97295. /**
  97296. * Adds a sound to this sound track
  97297. * @param sound define the cound to add
  97298. * @ignoreNaming
  97299. */
  97300. AddSound(sound: Sound): void;
  97301. /**
  97302. * Removes a sound to this sound track
  97303. * @param sound define the cound to remove
  97304. * @ignoreNaming
  97305. */
  97306. RemoveSound(sound: Sound): void;
  97307. /**
  97308. * Set a global volume for the full sound track.
  97309. * @param newVolume Define the new volume of the sound track
  97310. */
  97311. setVolume(newVolume: number): void;
  97312. /**
  97313. * Switch the panning model to HRTF:
  97314. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  97315. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97316. */
  97317. switchPanningModelToHRTF(): void;
  97318. /**
  97319. * Switch the panning model to Equal Power:
  97320. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  97321. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  97322. */
  97323. switchPanningModelToEqualPower(): void;
  97324. /**
  97325. * Connect the sound track to an audio analyser allowing some amazing
  97326. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  97327. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  97328. * @param analyser The analyser to connect to the engine
  97329. */
  97330. connectToAnalyser(analyser: Analyser): void;
  97331. }
  97332. }
  97333. declare module BABYLON {
  97334. interface AbstractScene {
  97335. /**
  97336. * The list of sounds used in the scene.
  97337. */
  97338. sounds: Nullable<Array<Sound>>;
  97339. }
  97340. interface Scene {
  97341. /**
  97342. * @hidden
  97343. * Backing field
  97344. */
  97345. _mainSoundTrack: SoundTrack;
  97346. /**
  97347. * The main sound track played by the scene.
  97348. * It cotains your primary collection of sounds.
  97349. */
  97350. mainSoundTrack: SoundTrack;
  97351. /**
  97352. * The list of sound tracks added to the scene
  97353. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97354. */
  97355. soundTracks: Nullable<Array<SoundTrack>>;
  97356. /**
  97357. * Gets a sound using a given name
  97358. * @param name defines the name to search for
  97359. * @return the found sound or null if not found at all.
  97360. */
  97361. getSoundByName(name: string): Nullable<Sound>;
  97362. /**
  97363. * Gets or sets if audio support is enabled
  97364. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97365. */
  97366. audioEnabled: boolean;
  97367. /**
  97368. * Gets or sets if audio will be output to headphones
  97369. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97370. */
  97371. headphone: boolean;
  97372. }
  97373. /**
  97374. * Defines the sound scene component responsible to manage any sounds
  97375. * in a given scene.
  97376. */
  97377. export class AudioSceneComponent implements ISceneSerializableComponent {
  97378. /**
  97379. * The component name helpfull to identify the component in the list of scene components.
  97380. */
  97381. readonly name: string;
  97382. /**
  97383. * The scene the component belongs to.
  97384. */
  97385. scene: Scene;
  97386. private _audioEnabled;
  97387. /**
  97388. * Gets whether audio is enabled or not.
  97389. * Please use related enable/disable method to switch state.
  97390. */
  97391. readonly audioEnabled: boolean;
  97392. private _headphone;
  97393. /**
  97394. * Gets whether audio is outputing to headphone or not.
  97395. * Please use the according Switch methods to change output.
  97396. */
  97397. readonly headphone: boolean;
  97398. /**
  97399. * Creates a new instance of the component for the given scene
  97400. * @param scene Defines the scene to register the component in
  97401. */
  97402. constructor(scene: Scene);
  97403. /**
  97404. * Registers the component in a given scene
  97405. */
  97406. register(): void;
  97407. /**
  97408. * Rebuilds the elements related to this component in case of
  97409. * context lost for instance.
  97410. */
  97411. rebuild(): void;
  97412. /**
  97413. * Serializes the component data to the specified json object
  97414. * @param serializationObject The object to serialize to
  97415. */
  97416. serialize(serializationObject: any): void;
  97417. /**
  97418. * Adds all the elements from the container to the scene
  97419. * @param container the container holding the elements
  97420. */
  97421. addFromContainer(container: AbstractScene): void;
  97422. /**
  97423. * Removes all the elements in the container from the scene
  97424. * @param container contains the elements to remove
  97425. * @param dispose if the removed element should be disposed (default: false)
  97426. */
  97427. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  97428. /**
  97429. * Disposes the component and the associated ressources.
  97430. */
  97431. dispose(): void;
  97432. /**
  97433. * Disables audio in the associated scene.
  97434. */
  97435. disableAudio(): void;
  97436. /**
  97437. * Enables audio in the associated scene.
  97438. */
  97439. enableAudio(): void;
  97440. /**
  97441. * Switch audio to headphone output.
  97442. */
  97443. switchAudioModeForHeadphones(): void;
  97444. /**
  97445. * Switch audio to normal speakers.
  97446. */
  97447. switchAudioModeForNormalSpeakers(): void;
  97448. private _afterRender;
  97449. }
  97450. }
  97451. declare module BABYLON {
  97452. /**
  97453. * Wraps one or more Sound objects and selects one with random weight for playback.
  97454. */
  97455. export class WeightedSound {
  97456. /** When true a Sound will be selected and played when the current playing Sound completes. */
  97457. loop: boolean;
  97458. private _coneInnerAngle;
  97459. private _coneOuterAngle;
  97460. private _volume;
  97461. /** A Sound is currently playing. */
  97462. isPlaying: boolean;
  97463. /** A Sound is currently paused. */
  97464. isPaused: boolean;
  97465. private _sounds;
  97466. private _weights;
  97467. private _currentIndex?;
  97468. /**
  97469. * Creates a new WeightedSound from the list of sounds given.
  97470. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  97471. * @param sounds Array of Sounds that will be selected from.
  97472. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  97473. */
  97474. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  97475. /**
  97476. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  97477. */
  97478. /**
  97479. * The size of cone in degress for a directional sound in which there will be no attenuation.
  97480. */
  97481. directionalConeInnerAngle: number;
  97482. /**
  97483. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  97484. * Listener angles between innerAngle and outerAngle will falloff linearly.
  97485. */
  97486. /**
  97487. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  97488. * Listener angles between innerAngle and outerAngle will falloff linearly.
  97489. */
  97490. directionalConeOuterAngle: number;
  97491. /**
  97492. * Playback volume.
  97493. */
  97494. /**
  97495. * Playback volume.
  97496. */
  97497. volume: number;
  97498. private _onended;
  97499. /**
  97500. * Suspend playback
  97501. */
  97502. pause(): void;
  97503. /**
  97504. * Stop playback
  97505. */
  97506. stop(): void;
  97507. /**
  97508. * Start playback.
  97509. * @param startOffset Position the clip head at a specific time in seconds.
  97510. */
  97511. play(startOffset?: number): void;
  97512. }
  97513. }
  97514. declare module BABYLON {
  97515. /**
  97516. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  97517. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  97518. */
  97519. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  97520. /**
  97521. * Gets the name of the behavior.
  97522. */
  97523. readonly name: string;
  97524. /**
  97525. * The easing function used by animations
  97526. */
  97527. static EasingFunction: BackEase;
  97528. /**
  97529. * The easing mode used by animations
  97530. */
  97531. static EasingMode: number;
  97532. /**
  97533. * The duration of the animation, in milliseconds
  97534. */
  97535. transitionDuration: number;
  97536. /**
  97537. * Length of the distance animated by the transition when lower radius is reached
  97538. */
  97539. lowerRadiusTransitionRange: number;
  97540. /**
  97541. * Length of the distance animated by the transition when upper radius is reached
  97542. */
  97543. upperRadiusTransitionRange: number;
  97544. private _autoTransitionRange;
  97545. /**
  97546. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  97547. */
  97548. /**
  97549. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  97550. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  97551. */
  97552. autoTransitionRange: boolean;
  97553. private _attachedCamera;
  97554. private _onAfterCheckInputsObserver;
  97555. private _onMeshTargetChangedObserver;
  97556. /**
  97557. * Initializes the behavior.
  97558. */
  97559. init(): void;
  97560. /**
  97561. * Attaches the behavior to its arc rotate camera.
  97562. * @param camera Defines the camera to attach the behavior to
  97563. */
  97564. attach(camera: ArcRotateCamera): void;
  97565. /**
  97566. * Detaches the behavior from its current arc rotate camera.
  97567. */
  97568. detach(): void;
  97569. private _radiusIsAnimating;
  97570. private _radiusBounceTransition;
  97571. private _animatables;
  97572. private _cachedWheelPrecision;
  97573. /**
  97574. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  97575. * @param radiusLimit The limit to check against.
  97576. * @return Bool to indicate if at limit.
  97577. */
  97578. private _isRadiusAtLimit;
  97579. /**
  97580. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  97581. * @param radiusDelta The delta by which to animate to. Can be negative.
  97582. */
  97583. private _applyBoundRadiusAnimation;
  97584. /**
  97585. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  97586. */
  97587. protected _clearAnimationLocks(): void;
  97588. /**
  97589. * Stops and removes all animations that have been applied to the camera
  97590. */
  97591. stopAllAnimations(): void;
  97592. }
  97593. }
  97594. declare module BABYLON {
  97595. /**
  97596. * 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.
  97597. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  97598. */
  97599. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  97600. /**
  97601. * Gets the name of the behavior.
  97602. */
  97603. readonly name: string;
  97604. private _mode;
  97605. private _radiusScale;
  97606. private _positionScale;
  97607. private _defaultElevation;
  97608. private _elevationReturnTime;
  97609. private _elevationReturnWaitTime;
  97610. private _zoomStopsAnimation;
  97611. private _framingTime;
  97612. /**
  97613. * The easing function used by animations
  97614. */
  97615. static EasingFunction: ExponentialEase;
  97616. /**
  97617. * The easing mode used by animations
  97618. */
  97619. static EasingMode: number;
  97620. /**
  97621. * Sets the current mode used by the behavior
  97622. */
  97623. /**
  97624. * Gets current mode used by the behavior.
  97625. */
  97626. mode: number;
  97627. /**
  97628. * Sets the scale applied to the radius (1 by default)
  97629. */
  97630. /**
  97631. * Gets the scale applied to the radius
  97632. */
  97633. radiusScale: number;
  97634. /**
  97635. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  97636. */
  97637. /**
  97638. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  97639. */
  97640. positionScale: number;
  97641. /**
  97642. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  97643. * behaviour is triggered, in radians.
  97644. */
  97645. /**
  97646. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  97647. * behaviour is triggered, in radians.
  97648. */
  97649. defaultElevation: number;
  97650. /**
  97651. * Sets the time (in milliseconds) taken to return to the default beta position.
  97652. * Negative value indicates camera should not return to default.
  97653. */
  97654. /**
  97655. * Gets the time (in milliseconds) taken to return to the default beta position.
  97656. * Negative value indicates camera should not return to default.
  97657. */
  97658. elevationReturnTime: number;
  97659. /**
  97660. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  97661. */
  97662. /**
  97663. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  97664. */
  97665. elevationReturnWaitTime: number;
  97666. /**
  97667. * Sets the flag that indicates if user zooming should stop animation.
  97668. */
  97669. /**
  97670. * Gets the flag that indicates if user zooming should stop animation.
  97671. */
  97672. zoomStopsAnimation: boolean;
  97673. /**
  97674. * Sets the transition time when framing the mesh, in milliseconds
  97675. */
  97676. /**
  97677. * Gets the transition time when framing the mesh, in milliseconds
  97678. */
  97679. framingTime: number;
  97680. /**
  97681. * Define if the behavior should automatically change the configured
  97682. * camera limits and sensibilities.
  97683. */
  97684. autoCorrectCameraLimitsAndSensibility: boolean;
  97685. private _onPrePointerObservableObserver;
  97686. private _onAfterCheckInputsObserver;
  97687. private _onMeshTargetChangedObserver;
  97688. private _attachedCamera;
  97689. private _isPointerDown;
  97690. private _lastInteractionTime;
  97691. /**
  97692. * Initializes the behavior.
  97693. */
  97694. init(): void;
  97695. /**
  97696. * Attaches the behavior to its arc rotate camera.
  97697. * @param camera Defines the camera to attach the behavior to
  97698. */
  97699. attach(camera: ArcRotateCamera): void;
  97700. /**
  97701. * Detaches the behavior from its current arc rotate camera.
  97702. */
  97703. detach(): void;
  97704. private _animatables;
  97705. private _betaIsAnimating;
  97706. private _betaTransition;
  97707. private _radiusTransition;
  97708. private _vectorTransition;
  97709. /**
  97710. * Targets the given mesh and updates zoom level accordingly.
  97711. * @param mesh The mesh to target.
  97712. * @param radius Optional. If a cached radius position already exists, overrides default.
  97713. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  97714. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97715. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97716. */
  97717. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97718. /**
  97719. * Targets the given mesh with its children and updates zoom level accordingly.
  97720. * @param mesh The mesh to target.
  97721. * @param radius Optional. If a cached radius position already exists, overrides default.
  97722. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  97723. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97724. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97725. */
  97726. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97727. /**
  97728. * Targets the given meshes with their children and updates zoom level accordingly.
  97729. * @param meshes The mesh to target.
  97730. * @param radius Optional. If a cached radius position already exists, overrides default.
  97731. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  97732. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97733. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97734. */
  97735. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97736. /**
  97737. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  97738. * @param minimumWorld Determines the smaller position of the bounding box extend
  97739. * @param maximumWorld Determines the bigger position of the bounding box extend
  97740. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  97741. * @param onAnimationEnd Callback triggered at the end of the framing animation
  97742. */
  97743. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  97744. /**
  97745. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  97746. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  97747. * frustum width.
  97748. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  97749. * to fully enclose the mesh in the viewing frustum.
  97750. */
  97751. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  97752. /**
  97753. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  97754. * is automatically returned to its default position (expected to be above ground plane).
  97755. */
  97756. private _maintainCameraAboveGround;
  97757. /**
  97758. * Returns the frustum slope based on the canvas ratio and camera FOV
  97759. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  97760. */
  97761. private _getFrustumSlope;
  97762. /**
  97763. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  97764. */
  97765. private _clearAnimationLocks;
  97766. /**
  97767. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  97768. */
  97769. private _applyUserInteraction;
  97770. /**
  97771. * Stops and removes all animations that have been applied to the camera
  97772. */
  97773. stopAllAnimations(): void;
  97774. /**
  97775. * Gets a value indicating if the user is moving the camera
  97776. */
  97777. readonly isUserIsMoving: boolean;
  97778. /**
  97779. * The camera can move all the way towards the mesh.
  97780. */
  97781. static IgnoreBoundsSizeMode: number;
  97782. /**
  97783. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  97784. */
  97785. static FitFrustumSidesMode: number;
  97786. }
  97787. }
  97788. declare module BABYLON {
  97789. /**
  97790. * Base class for Camera Pointer Inputs.
  97791. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  97792. * for example usage.
  97793. */
  97794. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  97795. /**
  97796. * Defines the camera the input is attached to.
  97797. */
  97798. abstract camera: Camera;
  97799. /**
  97800. * Whether keyboard modifier keys are pressed at time of last mouse event.
  97801. */
  97802. protected _altKey: boolean;
  97803. protected _ctrlKey: boolean;
  97804. protected _metaKey: boolean;
  97805. protected _shiftKey: boolean;
  97806. /**
  97807. * Which mouse buttons were pressed at time of last mouse event.
  97808. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  97809. */
  97810. protected _buttonsPressed: number;
  97811. /**
  97812. * Defines the buttons associated with the input to handle camera move.
  97813. */
  97814. buttons: number[];
  97815. /**
  97816. * Attach the input controls to a specific dom element to get the input from.
  97817. * @param element Defines the element the controls should be listened from
  97818. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97819. */
  97820. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97821. /**
  97822. * Detach the current controls from the specified dom element.
  97823. * @param element Defines the element to stop listening the inputs from
  97824. */
  97825. detachControl(element: Nullable<HTMLElement>): void;
  97826. /**
  97827. * Gets the class name of the current input.
  97828. * @returns the class name
  97829. */
  97830. getClassName(): string;
  97831. /**
  97832. * Get the friendly name associated with the input class.
  97833. * @returns the input friendly name
  97834. */
  97835. getSimpleName(): string;
  97836. /**
  97837. * Called on pointer POINTERDOUBLETAP event.
  97838. * Override this method to provide functionality on POINTERDOUBLETAP event.
  97839. */
  97840. protected onDoubleTap(type: string): void;
  97841. /**
  97842. * Called on pointer POINTERMOVE event if only a single touch is active.
  97843. * Override this method to provide functionality.
  97844. */
  97845. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  97846. /**
  97847. * Called on pointer POINTERMOVE event if multiple touches are active.
  97848. * Override this method to provide functionality.
  97849. */
  97850. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  97851. /**
  97852. * Called on JS contextmenu event.
  97853. * Override this method to provide functionality.
  97854. */
  97855. protected onContextMenu(evt: PointerEvent): void;
  97856. /**
  97857. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  97858. * press.
  97859. * Override this method to provide functionality.
  97860. */
  97861. protected onButtonDown(evt: PointerEvent): void;
  97862. /**
  97863. * Called each time a new POINTERUP event occurs. Ie, for each button
  97864. * release.
  97865. * Override this method to provide functionality.
  97866. */
  97867. protected onButtonUp(evt: PointerEvent): void;
  97868. /**
  97869. * Called when window becomes inactive.
  97870. * Override this method to provide functionality.
  97871. */
  97872. protected onLostFocus(): void;
  97873. private _pointerInput;
  97874. private _observer;
  97875. private _onLostFocus;
  97876. private pointA;
  97877. private pointB;
  97878. }
  97879. }
  97880. declare module BABYLON {
  97881. /**
  97882. * Manage the pointers inputs to control an arc rotate camera.
  97883. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97884. */
  97885. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  97886. /**
  97887. * Defines the camera the input is attached to.
  97888. */
  97889. camera: ArcRotateCamera;
  97890. /**
  97891. * Gets the class name of the current input.
  97892. * @returns the class name
  97893. */
  97894. getClassName(): string;
  97895. /**
  97896. * Defines the buttons associated with the input to handle camera move.
  97897. */
  97898. buttons: number[];
  97899. /**
  97900. * Defines the pointer angular sensibility along the X axis or how fast is
  97901. * the camera rotating.
  97902. */
  97903. angularSensibilityX: number;
  97904. /**
  97905. * Defines the pointer angular sensibility along the Y axis or how fast is
  97906. * the camera rotating.
  97907. */
  97908. angularSensibilityY: number;
  97909. /**
  97910. * Defines the pointer pinch precision or how fast is the camera zooming.
  97911. */
  97912. pinchPrecision: number;
  97913. /**
  97914. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  97915. * from 0.
  97916. * It defines the percentage of current camera.radius to use as delta when
  97917. * pinch zoom is used.
  97918. */
  97919. pinchDeltaPercentage: number;
  97920. /**
  97921. * Defines the pointer panning sensibility or how fast is the camera moving.
  97922. */
  97923. panningSensibility: number;
  97924. /**
  97925. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  97926. */
  97927. multiTouchPanning: boolean;
  97928. /**
  97929. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  97930. * zoom (pinch) through multitouch.
  97931. */
  97932. multiTouchPanAndZoom: boolean;
  97933. /**
  97934. * Revers pinch action direction.
  97935. */
  97936. pinchInwards: boolean;
  97937. private _isPanClick;
  97938. private _twoFingerActivityCount;
  97939. private _isPinching;
  97940. /**
  97941. * Called on pointer POINTERMOVE event if only a single touch is active.
  97942. */
  97943. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  97944. /**
  97945. * Called on pointer POINTERDOUBLETAP event.
  97946. */
  97947. protected onDoubleTap(type: string): void;
  97948. /**
  97949. * Called on pointer POINTERMOVE event if multiple touches are active.
  97950. */
  97951. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  97952. /**
  97953. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  97954. * press.
  97955. */
  97956. protected onButtonDown(evt: PointerEvent): void;
  97957. /**
  97958. * Called each time a new POINTERUP event occurs. Ie, for each button
  97959. * release.
  97960. */
  97961. protected onButtonUp(evt: PointerEvent): void;
  97962. /**
  97963. * Called when window becomes inactive.
  97964. */
  97965. protected onLostFocus(): void;
  97966. }
  97967. }
  97968. declare module BABYLON {
  97969. /**
  97970. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  97971. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97972. */
  97973. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  97974. /**
  97975. * Defines the camera the input is attached to.
  97976. */
  97977. camera: ArcRotateCamera;
  97978. /**
  97979. * Defines the list of key codes associated with the up action (increase alpha)
  97980. */
  97981. keysUp: number[];
  97982. /**
  97983. * Defines the list of key codes associated with the down action (decrease alpha)
  97984. */
  97985. keysDown: number[];
  97986. /**
  97987. * Defines the list of key codes associated with the left action (increase beta)
  97988. */
  97989. keysLeft: number[];
  97990. /**
  97991. * Defines the list of key codes associated with the right action (decrease beta)
  97992. */
  97993. keysRight: number[];
  97994. /**
  97995. * Defines the list of key codes associated with the reset action.
  97996. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  97997. */
  97998. keysReset: number[];
  97999. /**
  98000. * Defines the panning sensibility of the inputs.
  98001. * (How fast is the camera paning)
  98002. */
  98003. panningSensibility: number;
  98004. /**
  98005. * Defines the zooming sensibility of the inputs.
  98006. * (How fast is the camera zooming)
  98007. */
  98008. zoomingSensibility: number;
  98009. /**
  98010. * Defines wether maintaining the alt key down switch the movement mode from
  98011. * orientation to zoom.
  98012. */
  98013. useAltToZoom: boolean;
  98014. /**
  98015. * Rotation speed of the camera
  98016. */
  98017. angularSpeed: number;
  98018. private _keys;
  98019. private _ctrlPressed;
  98020. private _altPressed;
  98021. private _onCanvasBlurObserver;
  98022. private _onKeyboardObserver;
  98023. private _engine;
  98024. private _scene;
  98025. /**
  98026. * Attach the input controls to a specific dom element to get the input from.
  98027. * @param element Defines the element the controls should be listened from
  98028. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98029. */
  98030. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98031. /**
  98032. * Detach the current controls from the specified dom element.
  98033. * @param element Defines the element to stop listening the inputs from
  98034. */
  98035. detachControl(element: Nullable<HTMLElement>): void;
  98036. /**
  98037. * Update the current camera state depending on the inputs that have been used this frame.
  98038. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98039. */
  98040. checkInputs(): void;
  98041. /**
  98042. * Gets the class name of the current intput.
  98043. * @returns the class name
  98044. */
  98045. getClassName(): string;
  98046. /**
  98047. * Get the friendly name associated with the input class.
  98048. * @returns the input friendly name
  98049. */
  98050. getSimpleName(): string;
  98051. }
  98052. }
  98053. declare module BABYLON {
  98054. /**
  98055. * Manage the mouse wheel inputs to control an arc rotate camera.
  98056. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98057. */
  98058. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  98059. /**
  98060. * Defines the camera the input is attached to.
  98061. */
  98062. camera: ArcRotateCamera;
  98063. /**
  98064. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  98065. */
  98066. wheelPrecision: number;
  98067. /**
  98068. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  98069. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  98070. */
  98071. wheelDeltaPercentage: number;
  98072. private _wheel;
  98073. private _observer;
  98074. private computeDeltaFromMouseWheelLegacyEvent;
  98075. /**
  98076. * Attach the input controls to a specific dom element to get the input from.
  98077. * @param element Defines the element the controls should be listened from
  98078. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98079. */
  98080. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98081. /**
  98082. * Detach the current controls from the specified dom element.
  98083. * @param element Defines the element to stop listening the inputs from
  98084. */
  98085. detachControl(element: Nullable<HTMLElement>): void;
  98086. /**
  98087. * Gets the class name of the current intput.
  98088. * @returns the class name
  98089. */
  98090. getClassName(): string;
  98091. /**
  98092. * Get the friendly name associated with the input class.
  98093. * @returns the input friendly name
  98094. */
  98095. getSimpleName(): string;
  98096. }
  98097. }
  98098. declare module BABYLON {
  98099. /**
  98100. * Default Inputs manager for the ArcRotateCamera.
  98101. * It groups all the default supported inputs for ease of use.
  98102. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98103. */
  98104. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  98105. /**
  98106. * Instantiates a new ArcRotateCameraInputsManager.
  98107. * @param camera Defines the camera the inputs belong to
  98108. */
  98109. constructor(camera: ArcRotateCamera);
  98110. /**
  98111. * Add mouse wheel input support to the input manager.
  98112. * @returns the current input manager
  98113. */
  98114. addMouseWheel(): ArcRotateCameraInputsManager;
  98115. /**
  98116. * Add pointers input support to the input manager.
  98117. * @returns the current input manager
  98118. */
  98119. addPointers(): ArcRotateCameraInputsManager;
  98120. /**
  98121. * Add keyboard input support to the input manager.
  98122. * @returns the current input manager
  98123. */
  98124. addKeyboard(): ArcRotateCameraInputsManager;
  98125. }
  98126. }
  98127. declare module BABYLON {
  98128. /**
  98129. * This represents an orbital type of camera.
  98130. *
  98131. * 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.
  98132. * 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.
  98133. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  98134. */
  98135. export class ArcRotateCamera extends TargetCamera {
  98136. /**
  98137. * Defines the rotation angle of the camera along the longitudinal axis.
  98138. */
  98139. alpha: number;
  98140. /**
  98141. * Defines the rotation angle of the camera along the latitudinal axis.
  98142. */
  98143. beta: number;
  98144. /**
  98145. * Defines the radius of the camera from it s target point.
  98146. */
  98147. radius: number;
  98148. protected _target: Vector3;
  98149. protected _targetHost: Nullable<AbstractMesh>;
  98150. /**
  98151. * Defines the target point of the camera.
  98152. * The camera looks towards it form the radius distance.
  98153. */
  98154. target: Vector3;
  98155. /**
  98156. * Define the current local position of the camera in the scene
  98157. */
  98158. position: Vector3;
  98159. protected _upVector: Vector3;
  98160. protected _upToYMatrix: Matrix;
  98161. protected _YToUpMatrix: Matrix;
  98162. /**
  98163. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  98164. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  98165. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  98166. */
  98167. upVector: Vector3;
  98168. /**
  98169. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  98170. */
  98171. setMatUp(): void;
  98172. /**
  98173. * Current inertia value on the longitudinal axis.
  98174. * The bigger this number the longer it will take for the camera to stop.
  98175. */
  98176. inertialAlphaOffset: number;
  98177. /**
  98178. * Current inertia value on the latitudinal axis.
  98179. * The bigger this number the longer it will take for the camera to stop.
  98180. */
  98181. inertialBetaOffset: number;
  98182. /**
  98183. * Current inertia value on the radius axis.
  98184. * The bigger this number the longer it will take for the camera to stop.
  98185. */
  98186. inertialRadiusOffset: number;
  98187. /**
  98188. * Minimum allowed angle on the longitudinal axis.
  98189. * This can help limiting how the Camera is able to move in the scene.
  98190. */
  98191. lowerAlphaLimit: Nullable<number>;
  98192. /**
  98193. * Maximum allowed angle on the longitudinal axis.
  98194. * This can help limiting how the Camera is able to move in the scene.
  98195. */
  98196. upperAlphaLimit: Nullable<number>;
  98197. /**
  98198. * Minimum allowed angle on the latitudinal axis.
  98199. * This can help limiting how the Camera is able to move in the scene.
  98200. */
  98201. lowerBetaLimit: number;
  98202. /**
  98203. * Maximum allowed angle on the latitudinal axis.
  98204. * This can help limiting how the Camera is able to move in the scene.
  98205. */
  98206. upperBetaLimit: number;
  98207. /**
  98208. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  98209. * This can help limiting how the Camera is able to move in the scene.
  98210. */
  98211. lowerRadiusLimit: Nullable<number>;
  98212. /**
  98213. * Maximum allowed distance of the camera to the target (The camera can not get further).
  98214. * This can help limiting how the Camera is able to move in the scene.
  98215. */
  98216. upperRadiusLimit: Nullable<number>;
  98217. /**
  98218. * Defines the current inertia value used during panning of the camera along the X axis.
  98219. */
  98220. inertialPanningX: number;
  98221. /**
  98222. * Defines the current inertia value used during panning of the camera along the Y axis.
  98223. */
  98224. inertialPanningY: number;
  98225. /**
  98226. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  98227. * Basically if your fingers moves away from more than this distance you will be considered
  98228. * in pinch mode.
  98229. */
  98230. pinchToPanMaxDistance: number;
  98231. /**
  98232. * Defines the maximum distance the camera can pan.
  98233. * This could help keeping the cammera always in your scene.
  98234. */
  98235. panningDistanceLimit: Nullable<number>;
  98236. /**
  98237. * Defines the target of the camera before paning.
  98238. */
  98239. panningOriginTarget: Vector3;
  98240. /**
  98241. * Defines the value of the inertia used during panning.
  98242. * 0 would mean stop inertia and one would mean no decelleration at all.
  98243. */
  98244. panningInertia: number;
  98245. /**
  98246. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  98247. */
  98248. angularSensibilityX: number;
  98249. /**
  98250. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  98251. */
  98252. angularSensibilityY: number;
  98253. /**
  98254. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  98255. */
  98256. pinchPrecision: number;
  98257. /**
  98258. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  98259. * It will be used instead of pinchDeltaPrecision if different from 0.
  98260. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  98261. */
  98262. pinchDeltaPercentage: number;
  98263. /**
  98264. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  98265. */
  98266. panningSensibility: number;
  98267. /**
  98268. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  98269. */
  98270. keysUp: number[];
  98271. /**
  98272. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  98273. */
  98274. keysDown: number[];
  98275. /**
  98276. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  98277. */
  98278. keysLeft: number[];
  98279. /**
  98280. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  98281. */
  98282. keysRight: number[];
  98283. /**
  98284. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  98285. */
  98286. wheelPrecision: number;
  98287. /**
  98288. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  98289. * It will be used instead of pinchDeltaPrecision if different from 0.
  98290. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  98291. */
  98292. wheelDeltaPercentage: number;
  98293. /**
  98294. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  98295. */
  98296. zoomOnFactor: number;
  98297. /**
  98298. * Defines a screen offset for the camera position.
  98299. */
  98300. targetScreenOffset: Vector2;
  98301. /**
  98302. * Allows the camera to be completely reversed.
  98303. * If false the camera can not arrive upside down.
  98304. */
  98305. allowUpsideDown: boolean;
  98306. /**
  98307. * Define if double tap/click is used to restore the previously saved state of the camera.
  98308. */
  98309. useInputToRestoreState: boolean;
  98310. /** @hidden */
  98311. _viewMatrix: Matrix;
  98312. /** @hidden */
  98313. _useCtrlForPanning: boolean;
  98314. /** @hidden */
  98315. _panningMouseButton: number;
  98316. /**
  98317. * Defines the input associated to the camera.
  98318. */
  98319. inputs: ArcRotateCameraInputsManager;
  98320. /** @hidden */
  98321. _reset: () => void;
  98322. /**
  98323. * Defines the allowed panning axis.
  98324. */
  98325. panningAxis: Vector3;
  98326. protected _localDirection: Vector3;
  98327. protected _transformedDirection: Vector3;
  98328. private _bouncingBehavior;
  98329. /**
  98330. * Gets the bouncing behavior of the camera if it has been enabled.
  98331. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  98332. */
  98333. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  98334. /**
  98335. * Defines if the bouncing behavior of the camera is enabled on the camera.
  98336. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  98337. */
  98338. useBouncingBehavior: boolean;
  98339. private _framingBehavior;
  98340. /**
  98341. * Gets the framing behavior of the camera if it has been enabled.
  98342. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  98343. */
  98344. readonly framingBehavior: Nullable<FramingBehavior>;
  98345. /**
  98346. * Defines if the framing behavior of the camera is enabled on the camera.
  98347. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  98348. */
  98349. useFramingBehavior: boolean;
  98350. private _autoRotationBehavior;
  98351. /**
  98352. * Gets the auto rotation behavior of the camera if it has been enabled.
  98353. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98354. */
  98355. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  98356. /**
  98357. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  98358. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98359. */
  98360. useAutoRotationBehavior: boolean;
  98361. /**
  98362. * Observable triggered when the mesh target has been changed on the camera.
  98363. */
  98364. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  98365. /**
  98366. * Event raised when the camera is colliding with a mesh.
  98367. */
  98368. onCollide: (collidedMesh: AbstractMesh) => void;
  98369. /**
  98370. * Defines whether the camera should check collision with the objects oh the scene.
  98371. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  98372. */
  98373. checkCollisions: boolean;
  98374. /**
  98375. * Defines the collision radius of the camera.
  98376. * This simulates a sphere around the camera.
  98377. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  98378. */
  98379. collisionRadius: Vector3;
  98380. protected _collider: Collider;
  98381. protected _previousPosition: Vector3;
  98382. protected _collisionVelocity: Vector3;
  98383. protected _newPosition: Vector3;
  98384. protected _previousAlpha: number;
  98385. protected _previousBeta: number;
  98386. protected _previousRadius: number;
  98387. protected _collisionTriggered: boolean;
  98388. protected _targetBoundingCenter: Nullable<Vector3>;
  98389. private _computationVector;
  98390. /**
  98391. * Instantiates a new ArcRotateCamera in a given scene
  98392. * @param name Defines the name of the camera
  98393. * @param alpha Defines the camera rotation along the logitudinal axis
  98394. * @param beta Defines the camera rotation along the latitudinal axis
  98395. * @param radius Defines the camera distance from its target
  98396. * @param target Defines the camera target
  98397. * @param scene Defines the scene the camera belongs to
  98398. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  98399. */
  98400. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98401. /** @hidden */
  98402. _initCache(): void;
  98403. /** @hidden */
  98404. _updateCache(ignoreParentClass?: boolean): void;
  98405. protected _getTargetPosition(): Vector3;
  98406. private _storedAlpha;
  98407. private _storedBeta;
  98408. private _storedRadius;
  98409. private _storedTarget;
  98410. /**
  98411. * Stores the current state of the camera (alpha, beta, radius and target)
  98412. * @returns the camera itself
  98413. */
  98414. storeState(): Camera;
  98415. /**
  98416. * @hidden
  98417. * Restored camera state. You must call storeState() first
  98418. */
  98419. _restoreStateValues(): boolean;
  98420. /** @hidden */
  98421. _isSynchronizedViewMatrix(): boolean;
  98422. /**
  98423. * Attached controls to the current camera.
  98424. * @param element Defines the element the controls should be listened from
  98425. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98426. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  98427. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  98428. */
  98429. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  98430. /**
  98431. * Detach the current controls from the camera.
  98432. * The camera will stop reacting to inputs.
  98433. * @param element Defines the element to stop listening the inputs from
  98434. */
  98435. detachControl(element: HTMLElement): void;
  98436. /** @hidden */
  98437. _checkInputs(): void;
  98438. protected _checkLimits(): void;
  98439. /**
  98440. * Rebuilds angles (alpha, beta) and radius from the give position and target
  98441. */
  98442. rebuildAnglesAndRadius(): void;
  98443. /**
  98444. * Use a position to define the current camera related information like aplha, beta and radius
  98445. * @param position Defines the position to set the camera at
  98446. */
  98447. setPosition(position: Vector3): void;
  98448. /**
  98449. * Defines the target the camera should look at.
  98450. * This will automatically adapt alpha beta and radius to fit within the new target.
  98451. * @param target Defines the new target as a Vector or a mesh
  98452. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  98453. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  98454. */
  98455. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  98456. /** @hidden */
  98457. _getViewMatrix(): Matrix;
  98458. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  98459. /**
  98460. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  98461. * @param meshes Defines the mesh to zoom on
  98462. * @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)
  98463. */
  98464. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  98465. /**
  98466. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  98467. * The target will be changed but the radius
  98468. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  98469. * @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)
  98470. */
  98471. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  98472. min: Vector3;
  98473. max: Vector3;
  98474. distance: number;
  98475. }, doNotUpdateMaxZ?: boolean): void;
  98476. /**
  98477. * @override
  98478. * Override Camera.createRigCamera
  98479. */
  98480. createRigCamera(name: string, cameraIndex: number): Camera;
  98481. /**
  98482. * @hidden
  98483. * @override
  98484. * Override Camera._updateRigCameras
  98485. */
  98486. _updateRigCameras(): void;
  98487. /**
  98488. * Destroy the camera and release the current resources hold by it.
  98489. */
  98490. dispose(): void;
  98491. /**
  98492. * Gets the current object class name.
  98493. * @return the class name
  98494. */
  98495. getClassName(): string;
  98496. }
  98497. }
  98498. declare module BABYLON {
  98499. /**
  98500. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  98501. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  98502. */
  98503. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  98504. /**
  98505. * Gets the name of the behavior.
  98506. */
  98507. readonly name: string;
  98508. private _zoomStopsAnimation;
  98509. private _idleRotationSpeed;
  98510. private _idleRotationWaitTime;
  98511. private _idleRotationSpinupTime;
  98512. /**
  98513. * Sets the flag that indicates if user zooming should stop animation.
  98514. */
  98515. /**
  98516. * Gets the flag that indicates if user zooming should stop animation.
  98517. */
  98518. zoomStopsAnimation: boolean;
  98519. /**
  98520. * Sets the default speed at which the camera rotates around the model.
  98521. */
  98522. /**
  98523. * Gets the default speed at which the camera rotates around the model.
  98524. */
  98525. idleRotationSpeed: number;
  98526. /**
  98527. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  98528. */
  98529. /**
  98530. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  98531. */
  98532. idleRotationWaitTime: number;
  98533. /**
  98534. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  98535. */
  98536. /**
  98537. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  98538. */
  98539. idleRotationSpinupTime: number;
  98540. /**
  98541. * Gets a value indicating if the camera is currently rotating because of this behavior
  98542. */
  98543. readonly rotationInProgress: boolean;
  98544. private _onPrePointerObservableObserver;
  98545. private _onAfterCheckInputsObserver;
  98546. private _attachedCamera;
  98547. private _isPointerDown;
  98548. private _lastFrameTime;
  98549. private _lastInteractionTime;
  98550. private _cameraRotationSpeed;
  98551. /**
  98552. * Initializes the behavior.
  98553. */
  98554. init(): void;
  98555. /**
  98556. * Attaches the behavior to its arc rotate camera.
  98557. * @param camera Defines the camera to attach the behavior to
  98558. */
  98559. attach(camera: ArcRotateCamera): void;
  98560. /**
  98561. * Detaches the behavior from its current arc rotate camera.
  98562. */
  98563. detach(): void;
  98564. /**
  98565. * Returns true if user is scrolling.
  98566. * @return true if user is scrolling.
  98567. */
  98568. private _userIsZooming;
  98569. private _lastFrameRadius;
  98570. private _shouldAnimationStopForInteraction;
  98571. /**
  98572. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  98573. */
  98574. private _applyUserInteraction;
  98575. private _userIsMoving;
  98576. }
  98577. }
  98578. declare module BABYLON {
  98579. /**
  98580. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  98581. */
  98582. export class AttachToBoxBehavior implements Behavior<Mesh> {
  98583. private ui;
  98584. /**
  98585. * The name of the behavior
  98586. */
  98587. name: string;
  98588. /**
  98589. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  98590. */
  98591. distanceAwayFromFace: number;
  98592. /**
  98593. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  98594. */
  98595. distanceAwayFromBottomOfFace: number;
  98596. private _faceVectors;
  98597. private _target;
  98598. private _scene;
  98599. private _onRenderObserver;
  98600. private _tmpMatrix;
  98601. private _tmpVector;
  98602. /**
  98603. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  98604. * @param ui The transform node that should be attched to the mesh
  98605. */
  98606. constructor(ui: TransformNode);
  98607. /**
  98608. * Initializes the behavior
  98609. */
  98610. init(): void;
  98611. private _closestFace;
  98612. private _zeroVector;
  98613. private _lookAtTmpMatrix;
  98614. private _lookAtToRef;
  98615. /**
  98616. * Attaches the AttachToBoxBehavior to the passed in mesh
  98617. * @param target The mesh that the specified node will be attached to
  98618. */
  98619. attach(target: Mesh): void;
  98620. /**
  98621. * Detaches the behavior from the mesh
  98622. */
  98623. detach(): void;
  98624. }
  98625. }
  98626. declare module BABYLON {
  98627. /**
  98628. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  98629. */
  98630. export class FadeInOutBehavior implements Behavior<Mesh> {
  98631. /**
  98632. * Time in milliseconds to delay before fading in (Default: 0)
  98633. */
  98634. delay: number;
  98635. /**
  98636. * Time in milliseconds for the mesh to fade in (Default: 300)
  98637. */
  98638. fadeInTime: number;
  98639. private _millisecondsPerFrame;
  98640. private _hovered;
  98641. private _hoverValue;
  98642. private _ownerNode;
  98643. /**
  98644. * Instatiates the FadeInOutBehavior
  98645. */
  98646. constructor();
  98647. /**
  98648. * The name of the behavior
  98649. */
  98650. readonly name: string;
  98651. /**
  98652. * Initializes the behavior
  98653. */
  98654. init(): void;
  98655. /**
  98656. * Attaches the fade behavior on the passed in mesh
  98657. * @param ownerNode The mesh that will be faded in/out once attached
  98658. */
  98659. attach(ownerNode: Mesh): void;
  98660. /**
  98661. * Detaches the behavior from the mesh
  98662. */
  98663. detach(): void;
  98664. /**
  98665. * Triggers the mesh to begin fading in or out
  98666. * @param value if the object should fade in or out (true to fade in)
  98667. */
  98668. fadeIn(value: boolean): void;
  98669. private _update;
  98670. private _setAllVisibility;
  98671. }
  98672. }
  98673. declare module BABYLON {
  98674. /**
  98675. * Class containing a set of static utilities functions for managing Pivots
  98676. * @hidden
  98677. */
  98678. export class PivotTools {
  98679. private static _PivotCached;
  98680. private static _OldPivotPoint;
  98681. private static _PivotTranslation;
  98682. private static _PivotTmpVector;
  98683. /** @hidden */
  98684. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  98685. /** @hidden */
  98686. static _RestorePivotPoint(mesh: AbstractMesh): void;
  98687. }
  98688. }
  98689. declare module BABYLON {
  98690. /**
  98691. * Class containing static functions to help procedurally build meshes
  98692. */
  98693. export class PlaneBuilder {
  98694. /**
  98695. * Creates a plane mesh
  98696. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  98697. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  98698. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  98699. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98700. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98702. * @param name defines the name of the mesh
  98703. * @param options defines the options used to create the mesh
  98704. * @param scene defines the hosting scene
  98705. * @returns the plane mesh
  98706. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  98707. */
  98708. static CreatePlane(name: string, options: {
  98709. size?: number;
  98710. width?: number;
  98711. height?: number;
  98712. sideOrientation?: number;
  98713. frontUVs?: Vector4;
  98714. backUVs?: Vector4;
  98715. updatable?: boolean;
  98716. sourcePlane?: Plane;
  98717. }, scene?: Nullable<Scene>): Mesh;
  98718. }
  98719. }
  98720. declare module BABYLON {
  98721. /**
  98722. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  98723. */
  98724. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  98725. private static _AnyMouseID;
  98726. /**
  98727. * Abstract mesh the behavior is set on
  98728. */
  98729. attachedNode: AbstractMesh;
  98730. private _dragPlane;
  98731. private _scene;
  98732. private _pointerObserver;
  98733. private _beforeRenderObserver;
  98734. private static _planeScene;
  98735. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  98736. /**
  98737. * 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)
  98738. */
  98739. maxDragAngle: number;
  98740. /**
  98741. * @hidden
  98742. */
  98743. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  98744. /**
  98745. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  98746. */
  98747. currentDraggingPointerID: number;
  98748. /**
  98749. * The last position where the pointer hit the drag plane in world space
  98750. */
  98751. lastDragPosition: Vector3;
  98752. /**
  98753. * If the behavior is currently in a dragging state
  98754. */
  98755. dragging: boolean;
  98756. /**
  98757. * 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)
  98758. */
  98759. dragDeltaRatio: number;
  98760. /**
  98761. * If the drag plane orientation should be updated during the dragging (Default: true)
  98762. */
  98763. updateDragPlane: boolean;
  98764. private _debugMode;
  98765. private _moving;
  98766. /**
  98767. * Fires each time the attached mesh is dragged with the pointer
  98768. * * delta between last drag position and current drag position in world space
  98769. * * dragDistance along the drag axis
  98770. * * dragPlaneNormal normal of the current drag plane used during the drag
  98771. * * dragPlanePoint in world space where the drag intersects the drag plane
  98772. */
  98773. onDragObservable: Observable<{
  98774. delta: Vector3;
  98775. dragPlanePoint: Vector3;
  98776. dragPlaneNormal: Vector3;
  98777. dragDistance: number;
  98778. pointerId: number;
  98779. }>;
  98780. /**
  98781. * Fires each time a drag begins (eg. mouse down on mesh)
  98782. */
  98783. onDragStartObservable: Observable<{
  98784. dragPlanePoint: Vector3;
  98785. pointerId: number;
  98786. }>;
  98787. /**
  98788. * Fires each time a drag ends (eg. mouse release after drag)
  98789. */
  98790. onDragEndObservable: Observable<{
  98791. dragPlanePoint: Vector3;
  98792. pointerId: number;
  98793. }>;
  98794. /**
  98795. * If the attached mesh should be moved when dragged
  98796. */
  98797. moveAttached: boolean;
  98798. /**
  98799. * If the drag behavior will react to drag events (Default: true)
  98800. */
  98801. enabled: boolean;
  98802. /**
  98803. * If pointer events should start and release the drag (Default: true)
  98804. */
  98805. startAndReleaseDragOnPointerEvents: boolean;
  98806. /**
  98807. * If camera controls should be detached during the drag
  98808. */
  98809. detachCameraControls: boolean;
  98810. /**
  98811. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  98812. */
  98813. useObjectOrienationForDragging: boolean;
  98814. private _options;
  98815. /**
  98816. * Creates a pointer drag behavior that can be attached to a mesh
  98817. * @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)
  98818. */
  98819. constructor(options?: {
  98820. dragAxis?: Vector3;
  98821. dragPlaneNormal?: Vector3;
  98822. });
  98823. /**
  98824. * Predicate to determine if it is valid to move the object to a new position when it is moved
  98825. */
  98826. validateDrag: (targetPosition: Vector3) => boolean;
  98827. /**
  98828. * The name of the behavior
  98829. */
  98830. readonly name: string;
  98831. /**
  98832. * Initializes the behavior
  98833. */
  98834. init(): void;
  98835. private _tmpVector;
  98836. private _alternatePickedPoint;
  98837. private _worldDragAxis;
  98838. private _targetPosition;
  98839. private _attachedElement;
  98840. /**
  98841. * Attaches the drag behavior the passed in mesh
  98842. * @param ownerNode The mesh that will be dragged around once attached
  98843. */
  98844. attach(ownerNode: AbstractMesh): void;
  98845. /**
  98846. * Force relase the drag action by code.
  98847. */
  98848. releaseDrag(): void;
  98849. private _startDragRay;
  98850. private _lastPointerRay;
  98851. /**
  98852. * Simulates the start of a pointer drag event on the behavior
  98853. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  98854. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  98855. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  98856. */
  98857. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  98858. private _startDrag;
  98859. private _dragDelta;
  98860. private _moveDrag;
  98861. private _pickWithRayOnDragPlane;
  98862. private _pointA;
  98863. private _pointB;
  98864. private _pointC;
  98865. private _lineA;
  98866. private _lineB;
  98867. private _localAxis;
  98868. private _lookAt;
  98869. private _updateDragPlanePosition;
  98870. /**
  98871. * Detaches the behavior from the mesh
  98872. */
  98873. detach(): void;
  98874. }
  98875. }
  98876. declare module BABYLON {
  98877. /**
  98878. * A behavior that when attached to a mesh will allow the mesh to be scaled
  98879. */
  98880. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  98881. private _dragBehaviorA;
  98882. private _dragBehaviorB;
  98883. private _startDistance;
  98884. private _initialScale;
  98885. private _targetScale;
  98886. private _ownerNode;
  98887. private _sceneRenderObserver;
  98888. /**
  98889. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  98890. */
  98891. constructor();
  98892. /**
  98893. * The name of the behavior
  98894. */
  98895. readonly name: string;
  98896. /**
  98897. * Initializes the behavior
  98898. */
  98899. init(): void;
  98900. private _getCurrentDistance;
  98901. /**
  98902. * Attaches the scale behavior the passed in mesh
  98903. * @param ownerNode The mesh that will be scaled around once attached
  98904. */
  98905. attach(ownerNode: Mesh): void;
  98906. /**
  98907. * Detaches the behavior from the mesh
  98908. */
  98909. detach(): void;
  98910. }
  98911. }
  98912. declare module BABYLON {
  98913. /**
  98914. * 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
  98915. */
  98916. export class SixDofDragBehavior implements Behavior<Mesh> {
  98917. private static _virtualScene;
  98918. private _ownerNode;
  98919. private _sceneRenderObserver;
  98920. private _scene;
  98921. private _targetPosition;
  98922. private _virtualOriginMesh;
  98923. private _virtualDragMesh;
  98924. private _pointerObserver;
  98925. private _moving;
  98926. private _startingOrientation;
  98927. /**
  98928. * 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)
  98929. */
  98930. private zDragFactor;
  98931. /**
  98932. * If the object should rotate to face the drag origin
  98933. */
  98934. rotateDraggedObject: boolean;
  98935. /**
  98936. * If the behavior is currently in a dragging state
  98937. */
  98938. dragging: boolean;
  98939. /**
  98940. * 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)
  98941. */
  98942. dragDeltaRatio: number;
  98943. /**
  98944. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  98945. */
  98946. currentDraggingPointerID: number;
  98947. /**
  98948. * If camera controls should be detached during the drag
  98949. */
  98950. detachCameraControls: boolean;
  98951. /**
  98952. * Fires each time a drag starts
  98953. */
  98954. onDragStartObservable: Observable<{}>;
  98955. /**
  98956. * Fires each time a drag ends (eg. mouse release after drag)
  98957. */
  98958. onDragEndObservable: Observable<{}>;
  98959. /**
  98960. * 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
  98961. */
  98962. constructor();
  98963. /**
  98964. * The name of the behavior
  98965. */
  98966. readonly name: string;
  98967. /**
  98968. * Initializes the behavior
  98969. */
  98970. init(): void;
  98971. /**
  98972. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  98973. */
  98974. private readonly _pointerCamera;
  98975. /**
  98976. * Attaches the scale behavior the passed in mesh
  98977. * @param ownerNode The mesh that will be scaled around once attached
  98978. */
  98979. attach(ownerNode: Mesh): void;
  98980. /**
  98981. * Detaches the behavior from the mesh
  98982. */
  98983. detach(): void;
  98984. }
  98985. }
  98986. declare module BABYLON {
  98987. /**
  98988. * Class used to apply inverse kinematics to bones
  98989. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  98990. */
  98991. export class BoneIKController {
  98992. private static _tmpVecs;
  98993. private static _tmpQuat;
  98994. private static _tmpMats;
  98995. /**
  98996. * Gets or sets the target mesh
  98997. */
  98998. targetMesh: AbstractMesh;
  98999. /** Gets or sets the mesh used as pole */
  99000. poleTargetMesh: AbstractMesh;
  99001. /**
  99002. * Gets or sets the bone used as pole
  99003. */
  99004. poleTargetBone: Nullable<Bone>;
  99005. /**
  99006. * Gets or sets the target position
  99007. */
  99008. targetPosition: Vector3;
  99009. /**
  99010. * Gets or sets the pole target position
  99011. */
  99012. poleTargetPosition: Vector3;
  99013. /**
  99014. * Gets or sets the pole target local offset
  99015. */
  99016. poleTargetLocalOffset: Vector3;
  99017. /**
  99018. * Gets or sets the pole angle
  99019. */
  99020. poleAngle: number;
  99021. /**
  99022. * Gets or sets the mesh associated with the controller
  99023. */
  99024. mesh: AbstractMesh;
  99025. /**
  99026. * 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)
  99027. */
  99028. slerpAmount: number;
  99029. private _bone1Quat;
  99030. private _bone1Mat;
  99031. private _bone2Ang;
  99032. private _bone1;
  99033. private _bone2;
  99034. private _bone1Length;
  99035. private _bone2Length;
  99036. private _maxAngle;
  99037. private _maxReach;
  99038. private _rightHandedSystem;
  99039. private _bendAxis;
  99040. private _slerping;
  99041. private _adjustRoll;
  99042. /**
  99043. * Gets or sets maximum allowed angle
  99044. */
  99045. maxAngle: number;
  99046. /**
  99047. * Creates a new BoneIKController
  99048. * @param mesh defines the mesh to control
  99049. * @param bone defines the bone to control
  99050. * @param options defines options to set up the controller
  99051. */
  99052. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  99053. targetMesh?: AbstractMesh;
  99054. poleTargetMesh?: AbstractMesh;
  99055. poleTargetBone?: Bone;
  99056. poleTargetLocalOffset?: Vector3;
  99057. poleAngle?: number;
  99058. bendAxis?: Vector3;
  99059. maxAngle?: number;
  99060. slerpAmount?: number;
  99061. });
  99062. private _setMaxAngle;
  99063. /**
  99064. * Force the controller to update the bones
  99065. */
  99066. update(): void;
  99067. }
  99068. }
  99069. declare module BABYLON {
  99070. /**
  99071. * Class used to make a bone look toward a point in space
  99072. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  99073. */
  99074. export class BoneLookController {
  99075. private static _tmpVecs;
  99076. private static _tmpQuat;
  99077. private static _tmpMats;
  99078. /**
  99079. * The target Vector3 that the bone will look at
  99080. */
  99081. target: Vector3;
  99082. /**
  99083. * The mesh that the bone is attached to
  99084. */
  99085. mesh: AbstractMesh;
  99086. /**
  99087. * The bone that will be looking to the target
  99088. */
  99089. bone: Bone;
  99090. /**
  99091. * The up axis of the coordinate system that is used when the bone is rotated
  99092. */
  99093. upAxis: Vector3;
  99094. /**
  99095. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  99096. */
  99097. upAxisSpace: Space;
  99098. /**
  99099. * Used to make an adjustment to the yaw of the bone
  99100. */
  99101. adjustYaw: number;
  99102. /**
  99103. * Used to make an adjustment to the pitch of the bone
  99104. */
  99105. adjustPitch: number;
  99106. /**
  99107. * Used to make an adjustment to the roll of the bone
  99108. */
  99109. adjustRoll: number;
  99110. /**
  99111. * 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)
  99112. */
  99113. slerpAmount: number;
  99114. private _minYaw;
  99115. private _maxYaw;
  99116. private _minPitch;
  99117. private _maxPitch;
  99118. private _minYawSin;
  99119. private _minYawCos;
  99120. private _maxYawSin;
  99121. private _maxYawCos;
  99122. private _midYawConstraint;
  99123. private _minPitchTan;
  99124. private _maxPitchTan;
  99125. private _boneQuat;
  99126. private _slerping;
  99127. private _transformYawPitch;
  99128. private _transformYawPitchInv;
  99129. private _firstFrameSkipped;
  99130. private _yawRange;
  99131. private _fowardAxis;
  99132. /**
  99133. * Gets or sets the minimum yaw angle that the bone can look to
  99134. */
  99135. minYaw: number;
  99136. /**
  99137. * Gets or sets the maximum yaw angle that the bone can look to
  99138. */
  99139. maxYaw: number;
  99140. /**
  99141. * Gets or sets the minimum pitch angle that the bone can look to
  99142. */
  99143. minPitch: number;
  99144. /**
  99145. * Gets or sets the maximum pitch angle that the bone can look to
  99146. */
  99147. maxPitch: number;
  99148. /**
  99149. * Create a BoneLookController
  99150. * @param mesh the mesh that the bone belongs to
  99151. * @param bone the bone that will be looking to the target
  99152. * @param target the target Vector3 to look at
  99153. * @param options optional settings:
  99154. * * maxYaw: the maximum angle the bone will yaw to
  99155. * * minYaw: the minimum angle the bone will yaw to
  99156. * * maxPitch: the maximum angle the bone will pitch to
  99157. * * minPitch: the minimum angle the bone will yaw to
  99158. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  99159. * * upAxis: the up axis of the coordinate system
  99160. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  99161. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  99162. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  99163. * * adjustYaw: used to make an adjustment to the yaw of the bone
  99164. * * adjustPitch: used to make an adjustment to the pitch of the bone
  99165. * * adjustRoll: used to make an adjustment to the roll of the bone
  99166. **/
  99167. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  99168. maxYaw?: number;
  99169. minYaw?: number;
  99170. maxPitch?: number;
  99171. minPitch?: number;
  99172. slerpAmount?: number;
  99173. upAxis?: Vector3;
  99174. upAxisSpace?: Space;
  99175. yawAxis?: Vector3;
  99176. pitchAxis?: Vector3;
  99177. adjustYaw?: number;
  99178. adjustPitch?: number;
  99179. adjustRoll?: number;
  99180. });
  99181. /**
  99182. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  99183. */
  99184. update(): void;
  99185. private _getAngleDiff;
  99186. private _getAngleBetween;
  99187. private _isAngleBetween;
  99188. }
  99189. }
  99190. declare module BABYLON {
  99191. /**
  99192. * Manage the gamepad inputs to control an arc rotate camera.
  99193. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99194. */
  99195. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  99196. /**
  99197. * Defines the camera the input is attached to.
  99198. */
  99199. camera: ArcRotateCamera;
  99200. /**
  99201. * Defines the gamepad the input is gathering event from.
  99202. */
  99203. gamepad: Nullable<Gamepad>;
  99204. /**
  99205. * Defines the gamepad rotation sensiblity.
  99206. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  99207. */
  99208. gamepadRotationSensibility: number;
  99209. /**
  99210. * Defines the gamepad move sensiblity.
  99211. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  99212. */
  99213. gamepadMoveSensibility: number;
  99214. private _onGamepadConnectedObserver;
  99215. private _onGamepadDisconnectedObserver;
  99216. /**
  99217. * Attach the input controls to a specific dom element to get the input from.
  99218. * @param element Defines the element the controls should be listened from
  99219. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99220. */
  99221. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99222. /**
  99223. * Detach the current controls from the specified dom element.
  99224. * @param element Defines the element to stop listening the inputs from
  99225. */
  99226. detachControl(element: Nullable<HTMLElement>): void;
  99227. /**
  99228. * Update the current camera state depending on the inputs that have been used this frame.
  99229. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99230. */
  99231. checkInputs(): void;
  99232. /**
  99233. * Gets the class name of the current intput.
  99234. * @returns the class name
  99235. */
  99236. getClassName(): string;
  99237. /**
  99238. * Get the friendly name associated with the input class.
  99239. * @returns the input friendly name
  99240. */
  99241. getSimpleName(): string;
  99242. }
  99243. }
  99244. declare module BABYLON {
  99245. interface ArcRotateCameraInputsManager {
  99246. /**
  99247. * Add orientation input support to the input manager.
  99248. * @returns the current input manager
  99249. */
  99250. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  99251. }
  99252. /**
  99253. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  99254. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99255. */
  99256. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  99257. /**
  99258. * Defines the camera the input is attached to.
  99259. */
  99260. camera: ArcRotateCamera;
  99261. /**
  99262. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  99263. */
  99264. alphaCorrection: number;
  99265. /**
  99266. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  99267. */
  99268. gammaCorrection: number;
  99269. private _alpha;
  99270. private _gamma;
  99271. private _dirty;
  99272. private _deviceOrientationHandler;
  99273. /**
  99274. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  99275. */
  99276. constructor();
  99277. /**
  99278. * Attach the input controls to a specific dom element to get the input from.
  99279. * @param element Defines the element the controls should be listened from
  99280. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99281. */
  99282. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99283. /** @hidden */
  99284. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  99285. /**
  99286. * Update the current camera state depending on the inputs that have been used this frame.
  99287. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99288. */
  99289. checkInputs(): void;
  99290. /**
  99291. * Detach the current controls from the specified dom element.
  99292. * @param element Defines the element to stop listening the inputs from
  99293. */
  99294. detachControl(element: Nullable<HTMLElement>): void;
  99295. /**
  99296. * Gets the class name of the current intput.
  99297. * @returns the class name
  99298. */
  99299. getClassName(): string;
  99300. /**
  99301. * Get the friendly name associated with the input class.
  99302. * @returns the input friendly name
  99303. */
  99304. getSimpleName(): string;
  99305. }
  99306. }
  99307. declare module BABYLON {
  99308. /**
  99309. * Listen to mouse events to control the camera.
  99310. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99311. */
  99312. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  99313. /**
  99314. * Defines the camera the input is attached to.
  99315. */
  99316. camera: FlyCamera;
  99317. /**
  99318. * Defines if touch is enabled. (Default is true.)
  99319. */
  99320. touchEnabled: boolean;
  99321. /**
  99322. * Defines the buttons associated with the input to handle camera rotation.
  99323. */
  99324. buttons: number[];
  99325. /**
  99326. * Assign buttons for Yaw control.
  99327. */
  99328. buttonsYaw: number[];
  99329. /**
  99330. * Assign buttons for Pitch control.
  99331. */
  99332. buttonsPitch: number[];
  99333. /**
  99334. * Assign buttons for Roll control.
  99335. */
  99336. buttonsRoll: number[];
  99337. /**
  99338. * Detect if any button is being pressed while mouse is moved.
  99339. * -1 = Mouse locked.
  99340. * 0 = Left button.
  99341. * 1 = Middle Button.
  99342. * 2 = Right Button.
  99343. */
  99344. activeButton: number;
  99345. /**
  99346. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  99347. * Higher values reduce its sensitivity.
  99348. */
  99349. angularSensibility: number;
  99350. private _mousemoveCallback;
  99351. private _observer;
  99352. private _rollObserver;
  99353. private previousPosition;
  99354. private noPreventDefault;
  99355. private element;
  99356. /**
  99357. * Listen to mouse events to control the camera.
  99358. * @param touchEnabled Define if touch is enabled. (Default is true.)
  99359. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99360. */
  99361. constructor(touchEnabled?: boolean);
  99362. /**
  99363. * Attach the mouse control to the HTML DOM element.
  99364. * @param element Defines the element that listens to the input events.
  99365. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  99366. */
  99367. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99368. /**
  99369. * Detach the current controls from the specified dom element.
  99370. * @param element Defines the element to stop listening the inputs from
  99371. */
  99372. detachControl(element: Nullable<HTMLElement>): void;
  99373. /**
  99374. * Gets the class name of the current input.
  99375. * @returns the class name.
  99376. */
  99377. getClassName(): string;
  99378. /**
  99379. * Get the friendly name associated with the input class.
  99380. * @returns the input's friendly name.
  99381. */
  99382. getSimpleName(): string;
  99383. private _pointerInput;
  99384. private _onMouseMove;
  99385. /**
  99386. * Rotate camera by mouse offset.
  99387. */
  99388. private rotateCamera;
  99389. }
  99390. }
  99391. declare module BABYLON {
  99392. /**
  99393. * Default Inputs manager for the FlyCamera.
  99394. * It groups all the default supported inputs for ease of use.
  99395. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99396. */
  99397. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  99398. /**
  99399. * Instantiates a new FlyCameraInputsManager.
  99400. * @param camera Defines the camera the inputs belong to.
  99401. */
  99402. constructor(camera: FlyCamera);
  99403. /**
  99404. * Add keyboard input support to the input manager.
  99405. * @returns the new FlyCameraKeyboardMoveInput().
  99406. */
  99407. addKeyboard(): FlyCameraInputsManager;
  99408. /**
  99409. * Add mouse input support to the input manager.
  99410. * @param touchEnabled Enable touch screen support.
  99411. * @returns the new FlyCameraMouseInput().
  99412. */
  99413. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  99414. }
  99415. }
  99416. declare module BABYLON {
  99417. /**
  99418. * This is a flying camera, designed for 3D movement and rotation in all directions,
  99419. * such as in a 3D Space Shooter or a Flight Simulator.
  99420. */
  99421. export class FlyCamera extends TargetCamera {
  99422. /**
  99423. * Define the collision ellipsoid of the camera.
  99424. * This is helpful for simulating a camera body, like a player's body.
  99425. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  99426. */
  99427. ellipsoid: Vector3;
  99428. /**
  99429. * Define an offset for the position of the ellipsoid around the camera.
  99430. * This can be helpful if the camera is attached away from the player's body center,
  99431. * such as at its head.
  99432. */
  99433. ellipsoidOffset: Vector3;
  99434. /**
  99435. * Enable or disable collisions of the camera with the rest of the scene objects.
  99436. */
  99437. checkCollisions: boolean;
  99438. /**
  99439. * Enable or disable gravity on the camera.
  99440. */
  99441. applyGravity: boolean;
  99442. /**
  99443. * Define the current direction the camera is moving to.
  99444. */
  99445. cameraDirection: Vector3;
  99446. /**
  99447. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  99448. * This overrides and empties cameraRotation.
  99449. */
  99450. rotationQuaternion: Quaternion;
  99451. /**
  99452. * Track Roll to maintain the wanted Rolling when looking around.
  99453. */
  99454. _trackRoll: number;
  99455. /**
  99456. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  99457. */
  99458. rollCorrect: number;
  99459. /**
  99460. * Mimic a banked turn, Rolling the camera when Yawing.
  99461. * It's recommended to use rollCorrect = 10 for faster banking correction.
  99462. */
  99463. bankedTurn: boolean;
  99464. /**
  99465. * Limit in radians for how much Roll banking will add. (Default: 90°)
  99466. */
  99467. bankedTurnLimit: number;
  99468. /**
  99469. * Value of 0 disables the banked Roll.
  99470. * Value of 1 is equal to the Yaw angle in radians.
  99471. */
  99472. bankedTurnMultiplier: number;
  99473. /**
  99474. * The inputs manager loads all the input sources, such as keyboard and mouse.
  99475. */
  99476. inputs: FlyCameraInputsManager;
  99477. /**
  99478. * Gets the input sensibility for mouse input.
  99479. * Higher values reduce sensitivity.
  99480. */
  99481. /**
  99482. * Sets the input sensibility for a mouse input.
  99483. * Higher values reduce sensitivity.
  99484. */
  99485. angularSensibility: number;
  99486. /**
  99487. * Get the keys for camera movement forward.
  99488. */
  99489. /**
  99490. * Set the keys for camera movement forward.
  99491. */
  99492. keysForward: number[];
  99493. /**
  99494. * Get the keys for camera movement backward.
  99495. */
  99496. keysBackward: number[];
  99497. /**
  99498. * Get the keys for camera movement up.
  99499. */
  99500. /**
  99501. * Set the keys for camera movement up.
  99502. */
  99503. keysUp: number[];
  99504. /**
  99505. * Get the keys for camera movement down.
  99506. */
  99507. /**
  99508. * Set the keys for camera movement down.
  99509. */
  99510. keysDown: number[];
  99511. /**
  99512. * Get the keys for camera movement left.
  99513. */
  99514. /**
  99515. * Set the keys for camera movement left.
  99516. */
  99517. keysLeft: number[];
  99518. /**
  99519. * Set the keys for camera movement right.
  99520. */
  99521. /**
  99522. * Set the keys for camera movement right.
  99523. */
  99524. keysRight: number[];
  99525. /**
  99526. * Event raised when the camera collides with a mesh in the scene.
  99527. */
  99528. onCollide: (collidedMesh: AbstractMesh) => void;
  99529. private _collider;
  99530. private _needMoveForGravity;
  99531. private _oldPosition;
  99532. private _diffPosition;
  99533. private _newPosition;
  99534. /** @hidden */
  99535. _localDirection: Vector3;
  99536. /** @hidden */
  99537. _transformedDirection: Vector3;
  99538. /**
  99539. * Instantiates a FlyCamera.
  99540. * This is a flying camera, designed for 3D movement and rotation in all directions,
  99541. * such as in a 3D Space Shooter or a Flight Simulator.
  99542. * @param name Define the name of the camera in the scene.
  99543. * @param position Define the starting position of the camera in the scene.
  99544. * @param scene Define the scene the camera belongs to.
  99545. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  99546. */
  99547. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99548. /**
  99549. * Attach a control to the HTML DOM element.
  99550. * @param element Defines the element that listens to the input events.
  99551. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  99552. */
  99553. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99554. /**
  99555. * Detach a control from the HTML DOM element.
  99556. * The camera will stop reacting to that input.
  99557. * @param element Defines the element that listens to the input events.
  99558. */
  99559. detachControl(element: HTMLElement): void;
  99560. private _collisionMask;
  99561. /**
  99562. * Get the mask that the camera ignores in collision events.
  99563. */
  99564. /**
  99565. * Set the mask that the camera ignores in collision events.
  99566. */
  99567. collisionMask: number;
  99568. /** @hidden */
  99569. _collideWithWorld(displacement: Vector3): void;
  99570. /** @hidden */
  99571. private _onCollisionPositionChange;
  99572. /** @hidden */
  99573. _checkInputs(): void;
  99574. /** @hidden */
  99575. _decideIfNeedsToMove(): boolean;
  99576. /** @hidden */
  99577. _updatePosition(): void;
  99578. /**
  99579. * Restore the Roll to its target value at the rate specified.
  99580. * @param rate - Higher means slower restoring.
  99581. * @hidden
  99582. */
  99583. restoreRoll(rate: number): void;
  99584. /**
  99585. * Destroy the camera and release the current resources held by it.
  99586. */
  99587. dispose(): void;
  99588. /**
  99589. * Get the current object class name.
  99590. * @returns the class name.
  99591. */
  99592. getClassName(): string;
  99593. }
  99594. }
  99595. declare module BABYLON {
  99596. /**
  99597. * Listen to keyboard events to control the camera.
  99598. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99599. */
  99600. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  99601. /**
  99602. * Defines the camera the input is attached to.
  99603. */
  99604. camera: FlyCamera;
  99605. /**
  99606. * The list of keyboard keys used to control the forward move of the camera.
  99607. */
  99608. keysForward: number[];
  99609. /**
  99610. * The list of keyboard keys used to control the backward move of the camera.
  99611. */
  99612. keysBackward: number[];
  99613. /**
  99614. * The list of keyboard keys used to control the forward move of the camera.
  99615. */
  99616. keysUp: number[];
  99617. /**
  99618. * The list of keyboard keys used to control the backward move of the camera.
  99619. */
  99620. keysDown: number[];
  99621. /**
  99622. * The list of keyboard keys used to control the right strafe move of the camera.
  99623. */
  99624. keysRight: number[];
  99625. /**
  99626. * The list of keyboard keys used to control the left strafe move of the camera.
  99627. */
  99628. keysLeft: number[];
  99629. private _keys;
  99630. private _onCanvasBlurObserver;
  99631. private _onKeyboardObserver;
  99632. private _engine;
  99633. private _scene;
  99634. /**
  99635. * Attach the input controls to a specific dom element to get the input from.
  99636. * @param element Defines the element the controls should be listened from
  99637. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99638. */
  99639. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99640. /**
  99641. * Detach the current controls from the specified dom element.
  99642. * @param element Defines the element to stop listening the inputs from
  99643. */
  99644. detachControl(element: Nullable<HTMLElement>): void;
  99645. /**
  99646. * Gets the class name of the current intput.
  99647. * @returns the class name
  99648. */
  99649. getClassName(): string;
  99650. /** @hidden */
  99651. _onLostFocus(e: FocusEvent): void;
  99652. /**
  99653. * Get the friendly name associated with the input class.
  99654. * @returns the input friendly name
  99655. */
  99656. getSimpleName(): string;
  99657. /**
  99658. * Update the current camera state depending on the inputs that have been used this frame.
  99659. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99660. */
  99661. checkInputs(): void;
  99662. }
  99663. }
  99664. declare module BABYLON {
  99665. /**
  99666. * Manage the mouse wheel inputs to control a follow camera.
  99667. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99668. */
  99669. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  99670. /**
  99671. * Defines the camera the input is attached to.
  99672. */
  99673. camera: FollowCamera;
  99674. /**
  99675. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  99676. */
  99677. axisControlRadius: boolean;
  99678. /**
  99679. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  99680. */
  99681. axisControlHeight: boolean;
  99682. /**
  99683. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  99684. */
  99685. axisControlRotation: boolean;
  99686. /**
  99687. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  99688. * relation to mouseWheel events.
  99689. */
  99690. wheelPrecision: number;
  99691. /**
  99692. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  99693. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  99694. */
  99695. wheelDeltaPercentage: number;
  99696. private _wheel;
  99697. private _observer;
  99698. /**
  99699. * Attach the input controls to a specific dom element to get the input from.
  99700. * @param element Defines the element the controls should be listened from
  99701. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99702. */
  99703. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99704. /**
  99705. * Detach the current controls from the specified dom element.
  99706. * @param element Defines the element to stop listening the inputs from
  99707. */
  99708. detachControl(element: Nullable<HTMLElement>): void;
  99709. /**
  99710. * Gets the class name of the current intput.
  99711. * @returns the class name
  99712. */
  99713. getClassName(): string;
  99714. /**
  99715. * Get the friendly name associated with the input class.
  99716. * @returns the input friendly name
  99717. */
  99718. getSimpleName(): string;
  99719. }
  99720. }
  99721. declare module BABYLON {
  99722. /**
  99723. * Manage the pointers inputs to control an follow camera.
  99724. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99725. */
  99726. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  99727. /**
  99728. * Defines the camera the input is attached to.
  99729. */
  99730. camera: FollowCamera;
  99731. /**
  99732. * Gets the class name of the current input.
  99733. * @returns the class name
  99734. */
  99735. getClassName(): string;
  99736. /**
  99737. * Defines the pointer angular sensibility along the X axis or how fast is
  99738. * the camera rotating.
  99739. * A negative number will reverse the axis direction.
  99740. */
  99741. angularSensibilityX: number;
  99742. /**
  99743. * Defines the pointer angular sensibility along the Y axis or how fast is
  99744. * the camera rotating.
  99745. * A negative number will reverse the axis direction.
  99746. */
  99747. angularSensibilityY: number;
  99748. /**
  99749. * Defines the pointer pinch precision or how fast is the camera zooming.
  99750. * A negative number will reverse the axis direction.
  99751. */
  99752. pinchPrecision: number;
  99753. /**
  99754. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  99755. * from 0.
  99756. * It defines the percentage of current camera.radius to use as delta when
  99757. * pinch zoom is used.
  99758. */
  99759. pinchDeltaPercentage: number;
  99760. /**
  99761. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  99762. */
  99763. axisXControlRadius: boolean;
  99764. /**
  99765. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  99766. */
  99767. axisXControlHeight: boolean;
  99768. /**
  99769. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  99770. */
  99771. axisXControlRotation: boolean;
  99772. /**
  99773. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  99774. */
  99775. axisYControlRadius: boolean;
  99776. /**
  99777. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  99778. */
  99779. axisYControlHeight: boolean;
  99780. /**
  99781. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  99782. */
  99783. axisYControlRotation: boolean;
  99784. /**
  99785. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  99786. */
  99787. axisPinchControlRadius: boolean;
  99788. /**
  99789. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  99790. */
  99791. axisPinchControlHeight: boolean;
  99792. /**
  99793. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  99794. */
  99795. axisPinchControlRotation: boolean;
  99796. /**
  99797. * Log error messages if basic misconfiguration has occurred.
  99798. */
  99799. warningEnable: boolean;
  99800. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  99801. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  99802. private _warningCounter;
  99803. private _warning;
  99804. }
  99805. }
  99806. declare module BABYLON {
  99807. /**
  99808. * Default Inputs manager for the FollowCamera.
  99809. * It groups all the default supported inputs for ease of use.
  99810. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99811. */
  99812. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  99813. /**
  99814. * Instantiates a new FollowCameraInputsManager.
  99815. * @param camera Defines the camera the inputs belong to
  99816. */
  99817. constructor(camera: FollowCamera);
  99818. /**
  99819. * Add keyboard input support to the input manager.
  99820. * @returns the current input manager
  99821. */
  99822. addKeyboard(): FollowCameraInputsManager;
  99823. /**
  99824. * Add mouse wheel input support to the input manager.
  99825. * @returns the current input manager
  99826. */
  99827. addMouseWheel(): FollowCameraInputsManager;
  99828. /**
  99829. * Add pointers input support to the input manager.
  99830. * @returns the current input manager
  99831. */
  99832. addPointers(): FollowCameraInputsManager;
  99833. /**
  99834. * Add orientation input support to the input manager.
  99835. * @returns the current input manager
  99836. */
  99837. addVRDeviceOrientation(): FollowCameraInputsManager;
  99838. }
  99839. }
  99840. declare module BABYLON {
  99841. /**
  99842. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  99843. * an arc rotate version arcFollowCamera are available.
  99844. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  99845. */
  99846. export class FollowCamera extends TargetCamera {
  99847. /**
  99848. * Distance the follow camera should follow an object at
  99849. */
  99850. radius: number;
  99851. /**
  99852. * Minimum allowed distance of the camera to the axis of rotation
  99853. * (The camera can not get closer).
  99854. * This can help limiting how the Camera is able to move in the scene.
  99855. */
  99856. lowerRadiusLimit: Nullable<number>;
  99857. /**
  99858. * Maximum allowed distance of the camera to the axis of rotation
  99859. * (The camera can not get further).
  99860. * This can help limiting how the Camera is able to move in the scene.
  99861. */
  99862. upperRadiusLimit: Nullable<number>;
  99863. /**
  99864. * Define a rotation offset between the camera and the object it follows
  99865. */
  99866. rotationOffset: number;
  99867. /**
  99868. * Minimum allowed angle to camera position relative to target object.
  99869. * This can help limiting how the Camera is able to move in the scene.
  99870. */
  99871. lowerRotationOffsetLimit: Nullable<number>;
  99872. /**
  99873. * Maximum allowed angle to camera position relative to target object.
  99874. * This can help limiting how the Camera is able to move in the scene.
  99875. */
  99876. upperRotationOffsetLimit: Nullable<number>;
  99877. /**
  99878. * Define a height offset between the camera and the object it follows.
  99879. * It can help following an object from the top (like a car chaing a plane)
  99880. */
  99881. heightOffset: number;
  99882. /**
  99883. * Minimum allowed height of camera position relative to target object.
  99884. * This can help limiting how the Camera is able to move in the scene.
  99885. */
  99886. lowerHeightOffsetLimit: Nullable<number>;
  99887. /**
  99888. * Maximum allowed height of camera position relative to target object.
  99889. * This can help limiting how the Camera is able to move in the scene.
  99890. */
  99891. upperHeightOffsetLimit: Nullable<number>;
  99892. /**
  99893. * Define how fast the camera can accelerate to follow it s target.
  99894. */
  99895. cameraAcceleration: number;
  99896. /**
  99897. * Define the speed limit of the camera following an object.
  99898. */
  99899. maxCameraSpeed: number;
  99900. /**
  99901. * Define the target of the camera.
  99902. */
  99903. lockedTarget: Nullable<AbstractMesh>;
  99904. /**
  99905. * Defines the input associated with the camera.
  99906. */
  99907. inputs: FollowCameraInputsManager;
  99908. /**
  99909. * Instantiates the follow camera.
  99910. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  99911. * @param name Define the name of the camera in the scene
  99912. * @param position Define the position of the camera
  99913. * @param scene Define the scene the camera belong to
  99914. * @param lockedTarget Define the target of the camera
  99915. */
  99916. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  99917. private _follow;
  99918. /**
  99919. * Attached controls to the current camera.
  99920. * @param element Defines the element the controls should be listened from
  99921. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99922. */
  99923. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99924. /**
  99925. * Detach the current controls from the camera.
  99926. * The camera will stop reacting to inputs.
  99927. * @param element Defines the element to stop listening the inputs from
  99928. */
  99929. detachControl(element: HTMLElement): void;
  99930. /** @hidden */
  99931. _checkInputs(): void;
  99932. private _checkLimits;
  99933. /**
  99934. * Gets the camera class name.
  99935. * @returns the class name
  99936. */
  99937. getClassName(): string;
  99938. }
  99939. /**
  99940. * Arc Rotate version of the follow camera.
  99941. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  99942. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  99943. */
  99944. export class ArcFollowCamera extends TargetCamera {
  99945. /** The longitudinal angle of the camera */
  99946. alpha: number;
  99947. /** The latitudinal angle of the camera */
  99948. beta: number;
  99949. /** The radius of the camera from its target */
  99950. radius: number;
  99951. /** Define the camera target (the messh it should follow) */
  99952. target: Nullable<AbstractMesh>;
  99953. private _cartesianCoordinates;
  99954. /**
  99955. * Instantiates a new ArcFollowCamera
  99956. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  99957. * @param name Define the name of the camera
  99958. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  99959. * @param beta Define the rotation angle of the camera around the elevation axis
  99960. * @param radius Define the radius of the camera from its target point
  99961. * @param target Define the target of the camera
  99962. * @param scene Define the scene the camera belongs to
  99963. */
  99964. constructor(name: string,
  99965. /** The longitudinal angle of the camera */
  99966. alpha: number,
  99967. /** The latitudinal angle of the camera */
  99968. beta: number,
  99969. /** The radius of the camera from its target */
  99970. radius: number,
  99971. /** Define the camera target (the messh it should follow) */
  99972. target: Nullable<AbstractMesh>, scene: Scene);
  99973. private _follow;
  99974. /** @hidden */
  99975. _checkInputs(): void;
  99976. /**
  99977. * Returns the class name of the object.
  99978. * It is mostly used internally for serialization purposes.
  99979. */
  99980. getClassName(): string;
  99981. }
  99982. }
  99983. declare module BABYLON {
  99984. /**
  99985. * Manage the keyboard inputs to control the movement of a follow camera.
  99986. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99987. */
  99988. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  99989. /**
  99990. * Defines the camera the input is attached to.
  99991. */
  99992. camera: FollowCamera;
  99993. /**
  99994. * Defines the list of key codes associated with the up action (increase heightOffset)
  99995. */
  99996. keysHeightOffsetIncr: number[];
  99997. /**
  99998. * Defines the list of key codes associated with the down action (decrease heightOffset)
  99999. */
  100000. keysHeightOffsetDecr: number[];
  100001. /**
  100002. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  100003. */
  100004. keysHeightOffsetModifierAlt: boolean;
  100005. /**
  100006. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  100007. */
  100008. keysHeightOffsetModifierCtrl: boolean;
  100009. /**
  100010. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  100011. */
  100012. keysHeightOffsetModifierShift: boolean;
  100013. /**
  100014. * Defines the list of key codes associated with the left action (increase rotationOffset)
  100015. */
  100016. keysRotationOffsetIncr: number[];
  100017. /**
  100018. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  100019. */
  100020. keysRotationOffsetDecr: number[];
  100021. /**
  100022. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  100023. */
  100024. keysRotationOffsetModifierAlt: boolean;
  100025. /**
  100026. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  100027. */
  100028. keysRotationOffsetModifierCtrl: boolean;
  100029. /**
  100030. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  100031. */
  100032. keysRotationOffsetModifierShift: boolean;
  100033. /**
  100034. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  100035. */
  100036. keysRadiusIncr: number[];
  100037. /**
  100038. * Defines the list of key codes associated with the zoom-out action (increase radius)
  100039. */
  100040. keysRadiusDecr: number[];
  100041. /**
  100042. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  100043. */
  100044. keysRadiusModifierAlt: boolean;
  100045. /**
  100046. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  100047. */
  100048. keysRadiusModifierCtrl: boolean;
  100049. /**
  100050. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  100051. */
  100052. keysRadiusModifierShift: boolean;
  100053. /**
  100054. * Defines the rate of change of heightOffset.
  100055. */
  100056. heightSensibility: number;
  100057. /**
  100058. * Defines the rate of change of rotationOffset.
  100059. */
  100060. rotationSensibility: number;
  100061. /**
  100062. * Defines the rate of change of radius.
  100063. */
  100064. radiusSensibility: number;
  100065. private _keys;
  100066. private _ctrlPressed;
  100067. private _altPressed;
  100068. private _shiftPressed;
  100069. private _onCanvasBlurObserver;
  100070. private _onKeyboardObserver;
  100071. private _engine;
  100072. private _scene;
  100073. /**
  100074. * Attach the input controls to a specific dom element to get the input from.
  100075. * @param element Defines the element the controls should be listened from
  100076. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100077. */
  100078. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100079. /**
  100080. * Detach the current controls from the specified dom element.
  100081. * @param element Defines the element to stop listening the inputs from
  100082. */
  100083. detachControl(element: Nullable<HTMLElement>): void;
  100084. /**
  100085. * Update the current camera state depending on the inputs that have been used this frame.
  100086. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100087. */
  100088. checkInputs(): void;
  100089. /**
  100090. * Gets the class name of the current input.
  100091. * @returns the class name
  100092. */
  100093. getClassName(): string;
  100094. /**
  100095. * Get the friendly name associated with the input class.
  100096. * @returns the input friendly name
  100097. */
  100098. getSimpleName(): string;
  100099. /**
  100100. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  100101. * allow modification of the heightOffset value.
  100102. */
  100103. private _modifierHeightOffset;
  100104. /**
  100105. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  100106. * allow modification of the rotationOffset value.
  100107. */
  100108. private _modifierRotationOffset;
  100109. /**
  100110. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  100111. * allow modification of the radius value.
  100112. */
  100113. private _modifierRadius;
  100114. }
  100115. }
  100116. declare module BABYLON {
  100117. interface FreeCameraInputsManager {
  100118. /**
  100119. * @hidden
  100120. */
  100121. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  100122. /**
  100123. * Add orientation input support to the input manager.
  100124. * @returns the current input manager
  100125. */
  100126. addDeviceOrientation(): FreeCameraInputsManager;
  100127. }
  100128. /**
  100129. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  100130. * Screen rotation is taken into account.
  100131. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100132. */
  100133. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  100134. private _camera;
  100135. private _screenOrientationAngle;
  100136. private _constantTranform;
  100137. private _screenQuaternion;
  100138. private _alpha;
  100139. private _beta;
  100140. private _gamma;
  100141. /**
  100142. * Can be used to detect if a device orientation sensor is availible on a device
  100143. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  100144. * @returns a promise that will resolve on orientation change
  100145. */
  100146. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  100147. /**
  100148. * @hidden
  100149. */
  100150. _onDeviceOrientationChangedObservable: Observable<void>;
  100151. /**
  100152. * Instantiates a new input
  100153. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100154. */
  100155. constructor();
  100156. /**
  100157. * Define the camera controlled by the input.
  100158. */
  100159. camera: FreeCamera;
  100160. /**
  100161. * Attach the input controls to a specific dom element to get the input from.
  100162. * @param element Defines the element the controls should be listened from
  100163. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100164. */
  100165. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100166. private _orientationChanged;
  100167. private _deviceOrientation;
  100168. /**
  100169. * Detach the current controls from the specified dom element.
  100170. * @param element Defines the element to stop listening the inputs from
  100171. */
  100172. detachControl(element: Nullable<HTMLElement>): void;
  100173. /**
  100174. * Update the current camera state depending on the inputs that have been used this frame.
  100175. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100176. */
  100177. checkInputs(): void;
  100178. /**
  100179. * Gets the class name of the current intput.
  100180. * @returns the class name
  100181. */
  100182. getClassName(): string;
  100183. /**
  100184. * Get the friendly name associated with the input class.
  100185. * @returns the input friendly name
  100186. */
  100187. getSimpleName(): string;
  100188. }
  100189. }
  100190. declare module BABYLON {
  100191. /**
  100192. * Manage the gamepad inputs to control a free camera.
  100193. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100194. */
  100195. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  100196. /**
  100197. * Define the camera the input is attached to.
  100198. */
  100199. camera: FreeCamera;
  100200. /**
  100201. * Define the Gamepad controlling the input
  100202. */
  100203. gamepad: Nullable<Gamepad>;
  100204. /**
  100205. * Defines the gamepad rotation sensiblity.
  100206. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  100207. */
  100208. gamepadAngularSensibility: number;
  100209. /**
  100210. * Defines the gamepad move sensiblity.
  100211. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  100212. */
  100213. gamepadMoveSensibility: number;
  100214. private _onGamepadConnectedObserver;
  100215. private _onGamepadDisconnectedObserver;
  100216. private _cameraTransform;
  100217. private _deltaTransform;
  100218. private _vector3;
  100219. private _vector2;
  100220. /**
  100221. * Attach the input controls to a specific dom element to get the input from.
  100222. * @param element Defines the element the controls should be listened from
  100223. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100224. */
  100225. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100226. /**
  100227. * Detach the current controls from the specified dom element.
  100228. * @param element Defines the element to stop listening the inputs from
  100229. */
  100230. detachControl(element: Nullable<HTMLElement>): void;
  100231. /**
  100232. * Update the current camera state depending on the inputs that have been used this frame.
  100233. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100234. */
  100235. checkInputs(): void;
  100236. /**
  100237. * Gets the class name of the current intput.
  100238. * @returns the class name
  100239. */
  100240. getClassName(): string;
  100241. /**
  100242. * Get the friendly name associated with the input class.
  100243. * @returns the input friendly name
  100244. */
  100245. getSimpleName(): string;
  100246. }
  100247. }
  100248. declare module BABYLON {
  100249. /**
  100250. * Defines the potential axis of a Joystick
  100251. */
  100252. export enum JoystickAxis {
  100253. /** X axis */
  100254. X = 0,
  100255. /** Y axis */
  100256. Y = 1,
  100257. /** Z axis */
  100258. Z = 2
  100259. }
  100260. /**
  100261. * Class used to define virtual joystick (used in touch mode)
  100262. */
  100263. export class VirtualJoystick {
  100264. /**
  100265. * Gets or sets a boolean indicating that left and right values must be inverted
  100266. */
  100267. reverseLeftRight: boolean;
  100268. /**
  100269. * Gets or sets a boolean indicating that up and down values must be inverted
  100270. */
  100271. reverseUpDown: boolean;
  100272. /**
  100273. * Gets the offset value for the position (ie. the change of the position value)
  100274. */
  100275. deltaPosition: Vector3;
  100276. /**
  100277. * Gets a boolean indicating if the virtual joystick was pressed
  100278. */
  100279. pressed: boolean;
  100280. /**
  100281. * Canvas the virtual joystick will render onto, default z-index of this is 5
  100282. */
  100283. static Canvas: Nullable<HTMLCanvasElement>;
  100284. private static _globalJoystickIndex;
  100285. private static vjCanvasContext;
  100286. private static vjCanvasWidth;
  100287. private static vjCanvasHeight;
  100288. private static halfWidth;
  100289. private _action;
  100290. private _axisTargetedByLeftAndRight;
  100291. private _axisTargetedByUpAndDown;
  100292. private _joystickSensibility;
  100293. private _inversedSensibility;
  100294. private _joystickPointerID;
  100295. private _joystickColor;
  100296. private _joystickPointerPos;
  100297. private _joystickPreviousPointerPos;
  100298. private _joystickPointerStartPos;
  100299. private _deltaJoystickVector;
  100300. private _leftJoystick;
  100301. private _touches;
  100302. private _onPointerDownHandlerRef;
  100303. private _onPointerMoveHandlerRef;
  100304. private _onPointerUpHandlerRef;
  100305. private _onResize;
  100306. /**
  100307. * Creates a new virtual joystick
  100308. * @param leftJoystick defines that the joystick is for left hand (false by default)
  100309. */
  100310. constructor(leftJoystick?: boolean);
  100311. /**
  100312. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  100313. * @param newJoystickSensibility defines the new sensibility
  100314. */
  100315. setJoystickSensibility(newJoystickSensibility: number): void;
  100316. private _onPointerDown;
  100317. private _onPointerMove;
  100318. private _onPointerUp;
  100319. /**
  100320. * Change the color of the virtual joystick
  100321. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  100322. */
  100323. setJoystickColor(newColor: string): void;
  100324. /**
  100325. * Defines a callback to call when the joystick is touched
  100326. * @param action defines the callback
  100327. */
  100328. setActionOnTouch(action: () => any): void;
  100329. /**
  100330. * Defines which axis you'd like to control for left & right
  100331. * @param axis defines the axis to use
  100332. */
  100333. setAxisForLeftRight(axis: JoystickAxis): void;
  100334. /**
  100335. * Defines which axis you'd like to control for up & down
  100336. * @param axis defines the axis to use
  100337. */
  100338. setAxisForUpDown(axis: JoystickAxis): void;
  100339. private _drawVirtualJoystick;
  100340. /**
  100341. * Release internal HTML canvas
  100342. */
  100343. releaseCanvas(): void;
  100344. }
  100345. }
  100346. declare module BABYLON {
  100347. interface FreeCameraInputsManager {
  100348. /**
  100349. * Add virtual joystick input support to the input manager.
  100350. * @returns the current input manager
  100351. */
  100352. addVirtualJoystick(): FreeCameraInputsManager;
  100353. }
  100354. /**
  100355. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  100356. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  100357. */
  100358. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  100359. /**
  100360. * Defines the camera the input is attached to.
  100361. */
  100362. camera: FreeCamera;
  100363. private _leftjoystick;
  100364. private _rightjoystick;
  100365. /**
  100366. * Gets the left stick of the virtual joystick.
  100367. * @returns The virtual Joystick
  100368. */
  100369. getLeftJoystick(): VirtualJoystick;
  100370. /**
  100371. * Gets the right stick of the virtual joystick.
  100372. * @returns The virtual Joystick
  100373. */
  100374. getRightJoystick(): VirtualJoystick;
  100375. /**
  100376. * Update the current camera state depending on the inputs that have been used this frame.
  100377. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100378. */
  100379. checkInputs(): void;
  100380. /**
  100381. * Attach the input controls to a specific dom element to get the input from.
  100382. * @param element Defines the element the controls should be listened from
  100383. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100384. */
  100385. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100386. /**
  100387. * Detach the current controls from the specified dom element.
  100388. * @param element Defines the element to stop listening the inputs from
  100389. */
  100390. detachControl(element: Nullable<HTMLElement>): void;
  100391. /**
  100392. * Gets the class name of the current intput.
  100393. * @returns the class name
  100394. */
  100395. getClassName(): string;
  100396. /**
  100397. * Get the friendly name associated with the input class.
  100398. * @returns the input friendly name
  100399. */
  100400. getSimpleName(): string;
  100401. }
  100402. }
  100403. declare module BABYLON {
  100404. /**
  100405. * This represents a FPS type of camera controlled by touch.
  100406. * This is like a universal camera minus the Gamepad controls.
  100407. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100408. */
  100409. export class TouchCamera extends FreeCamera {
  100410. /**
  100411. * Defines the touch sensibility for rotation.
  100412. * The higher the faster.
  100413. */
  100414. touchAngularSensibility: number;
  100415. /**
  100416. * Defines the touch sensibility for move.
  100417. * The higher the faster.
  100418. */
  100419. touchMoveSensibility: number;
  100420. /**
  100421. * Instantiates a new touch camera.
  100422. * This represents a FPS type of camera controlled by touch.
  100423. * This is like a universal camera minus the Gamepad controls.
  100424. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100425. * @param name Define the name of the camera in the scene
  100426. * @param position Define the start position of the camera in the scene
  100427. * @param scene Define the scene the camera belongs to
  100428. */
  100429. constructor(name: string, position: Vector3, scene: Scene);
  100430. /**
  100431. * Gets the current object class name.
  100432. * @return the class name
  100433. */
  100434. getClassName(): string;
  100435. /** @hidden */
  100436. _setupInputs(): void;
  100437. }
  100438. }
  100439. declare module BABYLON {
  100440. /**
  100441. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  100442. * being tilted forward or back and left or right.
  100443. */
  100444. export class DeviceOrientationCamera extends FreeCamera {
  100445. private _initialQuaternion;
  100446. private _quaternionCache;
  100447. private _tmpDragQuaternion;
  100448. /**
  100449. * Creates a new device orientation camera
  100450. * @param name The name of the camera
  100451. * @param position The start position camera
  100452. * @param scene The scene the camera belongs to
  100453. */
  100454. constructor(name: string, position: Vector3, scene: Scene);
  100455. /**
  100456. * @hidden
  100457. * Disabled pointer input on first orientation sensor update (Default: true)
  100458. */
  100459. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  100460. private _dragFactor;
  100461. /**
  100462. * Enabled turning on the y axis when the orientation sensor is active
  100463. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  100464. */
  100465. enableHorizontalDragging(dragFactor?: number): void;
  100466. /**
  100467. * Gets the current instance class name ("DeviceOrientationCamera").
  100468. * This helps avoiding instanceof at run time.
  100469. * @returns the class name
  100470. */
  100471. getClassName(): string;
  100472. /**
  100473. * @hidden
  100474. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  100475. */
  100476. _checkInputs(): void;
  100477. /**
  100478. * Reset the camera to its default orientation on the specified axis only.
  100479. * @param axis The axis to reset
  100480. */
  100481. resetToCurrentRotation(axis?: Axis): void;
  100482. }
  100483. }
  100484. declare module BABYLON {
  100485. /**
  100486. * Defines supported buttons for XBox360 compatible gamepads
  100487. */
  100488. export enum Xbox360Button {
  100489. /** A */
  100490. A = 0,
  100491. /** B */
  100492. B = 1,
  100493. /** X */
  100494. X = 2,
  100495. /** Y */
  100496. Y = 3,
  100497. /** Start */
  100498. Start = 4,
  100499. /** Back */
  100500. Back = 5,
  100501. /** Left button */
  100502. LB = 6,
  100503. /** Right button */
  100504. RB = 7,
  100505. /** Left stick */
  100506. LeftStick = 8,
  100507. /** Right stick */
  100508. RightStick = 9
  100509. }
  100510. /** Defines values for XBox360 DPad */
  100511. export enum Xbox360Dpad {
  100512. /** Up */
  100513. Up = 0,
  100514. /** Down */
  100515. Down = 1,
  100516. /** Left */
  100517. Left = 2,
  100518. /** Right */
  100519. Right = 3
  100520. }
  100521. /**
  100522. * Defines a XBox360 gamepad
  100523. */
  100524. export class Xbox360Pad extends Gamepad {
  100525. private _leftTrigger;
  100526. private _rightTrigger;
  100527. private _onlefttriggerchanged;
  100528. private _onrighttriggerchanged;
  100529. private _onbuttondown;
  100530. private _onbuttonup;
  100531. private _ondpaddown;
  100532. private _ondpadup;
  100533. /** Observable raised when a button is pressed */
  100534. onButtonDownObservable: Observable<Xbox360Button>;
  100535. /** Observable raised when a button is released */
  100536. onButtonUpObservable: Observable<Xbox360Button>;
  100537. /** Observable raised when a pad is pressed */
  100538. onPadDownObservable: Observable<Xbox360Dpad>;
  100539. /** Observable raised when a pad is released */
  100540. onPadUpObservable: Observable<Xbox360Dpad>;
  100541. private _buttonA;
  100542. private _buttonB;
  100543. private _buttonX;
  100544. private _buttonY;
  100545. private _buttonBack;
  100546. private _buttonStart;
  100547. private _buttonLB;
  100548. private _buttonRB;
  100549. private _buttonLeftStick;
  100550. private _buttonRightStick;
  100551. private _dPadUp;
  100552. private _dPadDown;
  100553. private _dPadLeft;
  100554. private _dPadRight;
  100555. private _isXboxOnePad;
  100556. /**
  100557. * Creates a new XBox360 gamepad object
  100558. * @param id defines the id of this gamepad
  100559. * @param index defines its index
  100560. * @param gamepad defines the internal HTML gamepad object
  100561. * @param xboxOne defines if it is a XBox One gamepad
  100562. */
  100563. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  100564. /**
  100565. * Defines the callback to call when left trigger is pressed
  100566. * @param callback defines the callback to use
  100567. */
  100568. onlefttriggerchanged(callback: (value: number) => void): void;
  100569. /**
  100570. * Defines the callback to call when right trigger is pressed
  100571. * @param callback defines the callback to use
  100572. */
  100573. onrighttriggerchanged(callback: (value: number) => void): void;
  100574. /**
  100575. * Gets the left trigger value
  100576. */
  100577. /**
  100578. * Sets the left trigger value
  100579. */
  100580. leftTrigger: number;
  100581. /**
  100582. * Gets the right trigger value
  100583. */
  100584. /**
  100585. * Sets the right trigger value
  100586. */
  100587. rightTrigger: number;
  100588. /**
  100589. * Defines the callback to call when a button is pressed
  100590. * @param callback defines the callback to use
  100591. */
  100592. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  100593. /**
  100594. * Defines the callback to call when a button is released
  100595. * @param callback defines the callback to use
  100596. */
  100597. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  100598. /**
  100599. * Defines the callback to call when a pad is pressed
  100600. * @param callback defines the callback to use
  100601. */
  100602. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  100603. /**
  100604. * Defines the callback to call when a pad is released
  100605. * @param callback defines the callback to use
  100606. */
  100607. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  100608. private _setButtonValue;
  100609. private _setDPadValue;
  100610. /**
  100611. * Gets the value of the `A` button
  100612. */
  100613. /**
  100614. * Sets the value of the `A` button
  100615. */
  100616. buttonA: number;
  100617. /**
  100618. * Gets the value of the `B` button
  100619. */
  100620. /**
  100621. * Sets the value of the `B` button
  100622. */
  100623. buttonB: number;
  100624. /**
  100625. * Gets the value of the `X` button
  100626. */
  100627. /**
  100628. * Sets the value of the `X` button
  100629. */
  100630. buttonX: number;
  100631. /**
  100632. * Gets the value of the `Y` button
  100633. */
  100634. /**
  100635. * Sets the value of the `Y` button
  100636. */
  100637. buttonY: number;
  100638. /**
  100639. * Gets the value of the `Start` button
  100640. */
  100641. /**
  100642. * Sets the value of the `Start` button
  100643. */
  100644. buttonStart: number;
  100645. /**
  100646. * Gets the value of the `Back` button
  100647. */
  100648. /**
  100649. * Sets the value of the `Back` button
  100650. */
  100651. buttonBack: number;
  100652. /**
  100653. * Gets the value of the `Left` button
  100654. */
  100655. /**
  100656. * Sets the value of the `Left` button
  100657. */
  100658. buttonLB: number;
  100659. /**
  100660. * Gets the value of the `Right` button
  100661. */
  100662. /**
  100663. * Sets the value of the `Right` button
  100664. */
  100665. buttonRB: number;
  100666. /**
  100667. * Gets the value of the Left joystick
  100668. */
  100669. /**
  100670. * Sets the value of the Left joystick
  100671. */
  100672. buttonLeftStick: number;
  100673. /**
  100674. * Gets the value of the Right joystick
  100675. */
  100676. /**
  100677. * Sets the value of the Right joystick
  100678. */
  100679. buttonRightStick: number;
  100680. /**
  100681. * Gets the value of D-pad up
  100682. */
  100683. /**
  100684. * Sets the value of D-pad up
  100685. */
  100686. dPadUp: number;
  100687. /**
  100688. * Gets the value of D-pad down
  100689. */
  100690. /**
  100691. * Sets the value of D-pad down
  100692. */
  100693. dPadDown: number;
  100694. /**
  100695. * Gets the value of D-pad left
  100696. */
  100697. /**
  100698. * Sets the value of D-pad left
  100699. */
  100700. dPadLeft: number;
  100701. /**
  100702. * Gets the value of D-pad right
  100703. */
  100704. /**
  100705. * Sets the value of D-pad right
  100706. */
  100707. dPadRight: number;
  100708. /**
  100709. * Force the gamepad to synchronize with device values
  100710. */
  100711. update(): void;
  100712. /**
  100713. * Disposes the gamepad
  100714. */
  100715. dispose(): void;
  100716. }
  100717. }
  100718. declare module BABYLON {
  100719. /**
  100720. * Manager for handling gamepads
  100721. */
  100722. export class GamepadManager {
  100723. private _scene?;
  100724. private _babylonGamepads;
  100725. private _oneGamepadConnected;
  100726. /** @hidden */
  100727. _isMonitoring: boolean;
  100728. private _gamepadEventSupported;
  100729. private _gamepadSupport;
  100730. /**
  100731. * observable to be triggered when the gamepad controller has been connected
  100732. */
  100733. onGamepadConnectedObservable: Observable<Gamepad>;
  100734. /**
  100735. * observable to be triggered when the gamepad controller has been disconnected
  100736. */
  100737. onGamepadDisconnectedObservable: Observable<Gamepad>;
  100738. private _onGamepadConnectedEvent;
  100739. private _onGamepadDisconnectedEvent;
  100740. /**
  100741. * Initializes the gamepad manager
  100742. * @param _scene BabylonJS scene
  100743. */
  100744. constructor(_scene?: Scene | undefined);
  100745. /**
  100746. * The gamepads in the game pad manager
  100747. */
  100748. readonly gamepads: Gamepad[];
  100749. /**
  100750. * Get the gamepad controllers based on type
  100751. * @param type The type of gamepad controller
  100752. * @returns Nullable gamepad
  100753. */
  100754. getGamepadByType(type?: number): Nullable<Gamepad>;
  100755. /**
  100756. * Disposes the gamepad manager
  100757. */
  100758. dispose(): void;
  100759. private _addNewGamepad;
  100760. private _startMonitoringGamepads;
  100761. private _stopMonitoringGamepads;
  100762. /** @hidden */
  100763. _checkGamepadsStatus(): void;
  100764. private _updateGamepadObjects;
  100765. }
  100766. }
  100767. declare module BABYLON {
  100768. interface Scene {
  100769. /** @hidden */
  100770. _gamepadManager: Nullable<GamepadManager>;
  100771. /**
  100772. * Gets the gamepad manager associated with the scene
  100773. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  100774. */
  100775. gamepadManager: GamepadManager;
  100776. }
  100777. /**
  100778. * Interface representing a free camera inputs manager
  100779. */
  100780. interface FreeCameraInputsManager {
  100781. /**
  100782. * Adds gamepad input support to the FreeCameraInputsManager.
  100783. * @returns the FreeCameraInputsManager
  100784. */
  100785. addGamepad(): FreeCameraInputsManager;
  100786. }
  100787. /**
  100788. * Interface representing an arc rotate camera inputs manager
  100789. */
  100790. interface ArcRotateCameraInputsManager {
  100791. /**
  100792. * Adds gamepad input support to the ArcRotateCamera InputManager.
  100793. * @returns the camera inputs manager
  100794. */
  100795. addGamepad(): ArcRotateCameraInputsManager;
  100796. }
  100797. /**
  100798. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  100799. */
  100800. export class GamepadSystemSceneComponent implements ISceneComponent {
  100801. /**
  100802. * The component name helpfull to identify the component in the list of scene components.
  100803. */
  100804. readonly name: string;
  100805. /**
  100806. * The scene the component belongs to.
  100807. */
  100808. scene: Scene;
  100809. /**
  100810. * Creates a new instance of the component for the given scene
  100811. * @param scene Defines the scene to register the component in
  100812. */
  100813. constructor(scene: Scene);
  100814. /**
  100815. * Registers the component in a given scene
  100816. */
  100817. register(): void;
  100818. /**
  100819. * Rebuilds the elements related to this component in case of
  100820. * context lost for instance.
  100821. */
  100822. rebuild(): void;
  100823. /**
  100824. * Disposes the component and the associated ressources
  100825. */
  100826. dispose(): void;
  100827. private _beforeCameraUpdate;
  100828. }
  100829. }
  100830. declare module BABYLON {
  100831. /**
  100832. * 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,
  100833. * which still works and will still be found in many Playgrounds.
  100834. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100835. */
  100836. export class UniversalCamera extends TouchCamera {
  100837. /**
  100838. * Defines the gamepad rotation sensiblity.
  100839. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  100840. */
  100841. gamepadAngularSensibility: number;
  100842. /**
  100843. * Defines the gamepad move sensiblity.
  100844. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  100845. */
  100846. gamepadMoveSensibility: number;
  100847. /**
  100848. * 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,
  100849. * which still works and will still be found in many Playgrounds.
  100850. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100851. * @param name Define the name of the camera in the scene
  100852. * @param position Define the start position of the camera in the scene
  100853. * @param scene Define the scene the camera belongs to
  100854. */
  100855. constructor(name: string, position: Vector3, scene: Scene);
  100856. /**
  100857. * Gets the current object class name.
  100858. * @return the class name
  100859. */
  100860. getClassName(): string;
  100861. }
  100862. }
  100863. declare module BABYLON {
  100864. /**
  100865. * This represents a FPS type of camera. This is only here for back compat purpose.
  100866. * Please use the UniversalCamera instead as both are identical.
  100867. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100868. */
  100869. export class GamepadCamera extends UniversalCamera {
  100870. /**
  100871. * Instantiates a new Gamepad Camera
  100872. * This represents a FPS type of camera. This is only here for back compat purpose.
  100873. * Please use the UniversalCamera instead as both are identical.
  100874. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100875. * @param name Define the name of the camera in the scene
  100876. * @param position Define the start position of the camera in the scene
  100877. * @param scene Define the scene the camera belongs to
  100878. */
  100879. constructor(name: string, position: Vector3, scene: Scene);
  100880. /**
  100881. * Gets the current object class name.
  100882. * @return the class name
  100883. */
  100884. getClassName(): string;
  100885. }
  100886. }
  100887. declare module BABYLON {
  100888. /** @hidden */
  100889. export var passPixelShader: {
  100890. name: string;
  100891. shader: string;
  100892. };
  100893. }
  100894. declare module BABYLON {
  100895. /** @hidden */
  100896. export var passCubePixelShader: {
  100897. name: string;
  100898. shader: string;
  100899. };
  100900. }
  100901. declare module BABYLON {
  100902. /**
  100903. * PassPostProcess which produces an output the same as it's input
  100904. */
  100905. export class PassPostProcess extends PostProcess {
  100906. /**
  100907. * Creates the PassPostProcess
  100908. * @param name The name of the effect.
  100909. * @param options The required width/height ratio to downsize to before computing the render pass.
  100910. * @param camera The camera to apply the render pass to.
  100911. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100912. * @param engine The engine which the post process will be applied. (default: current engine)
  100913. * @param reusable If the post process can be reused on the same frame. (default: false)
  100914. * @param textureType The type of texture to be used when performing the post processing.
  100915. * @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)
  100916. */
  100917. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  100918. }
  100919. /**
  100920. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  100921. */
  100922. export class PassCubePostProcess extends PostProcess {
  100923. private _face;
  100924. /**
  100925. * Gets or sets the cube face to display.
  100926. * * 0 is +X
  100927. * * 1 is -X
  100928. * * 2 is +Y
  100929. * * 3 is -Y
  100930. * * 4 is +Z
  100931. * * 5 is -Z
  100932. */
  100933. face: number;
  100934. /**
  100935. * Creates the PassCubePostProcess
  100936. * @param name The name of the effect.
  100937. * @param options The required width/height ratio to downsize to before computing the render pass.
  100938. * @param camera The camera to apply the render pass to.
  100939. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100940. * @param engine The engine which the post process will be applied. (default: current engine)
  100941. * @param reusable If the post process can be reused on the same frame. (default: false)
  100942. * @param textureType The type of texture to be used when performing the post processing.
  100943. * @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)
  100944. */
  100945. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  100946. }
  100947. }
  100948. declare module BABYLON {
  100949. /** @hidden */
  100950. export var anaglyphPixelShader: {
  100951. name: string;
  100952. shader: string;
  100953. };
  100954. }
  100955. declare module BABYLON {
  100956. /**
  100957. * Postprocess used to generate anaglyphic rendering
  100958. */
  100959. export class AnaglyphPostProcess extends PostProcess {
  100960. private _passedProcess;
  100961. /**
  100962. * Creates a new AnaglyphPostProcess
  100963. * @param name defines postprocess name
  100964. * @param options defines creation options or target ratio scale
  100965. * @param rigCameras defines cameras using this postprocess
  100966. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  100967. * @param engine defines hosting engine
  100968. * @param reusable defines if the postprocess will be reused multiple times per frame
  100969. */
  100970. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  100971. }
  100972. }
  100973. declare module BABYLON {
  100974. /**
  100975. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  100976. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  100977. */
  100978. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  100979. /**
  100980. * Creates a new AnaglyphArcRotateCamera
  100981. * @param name defines camera name
  100982. * @param alpha defines alpha angle (in radians)
  100983. * @param beta defines beta angle (in radians)
  100984. * @param radius defines radius
  100985. * @param target defines camera target
  100986. * @param interaxialDistance defines distance between each color axis
  100987. * @param scene defines the hosting scene
  100988. */
  100989. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  100990. /**
  100991. * Gets camera class name
  100992. * @returns AnaglyphArcRotateCamera
  100993. */
  100994. getClassName(): string;
  100995. }
  100996. }
  100997. declare module BABYLON {
  100998. /**
  100999. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  101000. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101001. */
  101002. export class AnaglyphFreeCamera extends FreeCamera {
  101003. /**
  101004. * Creates a new AnaglyphFreeCamera
  101005. * @param name defines camera name
  101006. * @param position defines initial position
  101007. * @param interaxialDistance defines distance between each color axis
  101008. * @param scene defines the hosting scene
  101009. */
  101010. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  101011. /**
  101012. * Gets camera class name
  101013. * @returns AnaglyphFreeCamera
  101014. */
  101015. getClassName(): string;
  101016. }
  101017. }
  101018. declare module BABYLON {
  101019. /**
  101020. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  101021. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101022. */
  101023. export class AnaglyphGamepadCamera extends GamepadCamera {
  101024. /**
  101025. * Creates a new AnaglyphGamepadCamera
  101026. * @param name defines camera name
  101027. * @param position defines initial position
  101028. * @param interaxialDistance defines distance between each color axis
  101029. * @param scene defines the hosting scene
  101030. */
  101031. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  101032. /**
  101033. * Gets camera class name
  101034. * @returns AnaglyphGamepadCamera
  101035. */
  101036. getClassName(): string;
  101037. }
  101038. }
  101039. declare module BABYLON {
  101040. /**
  101041. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  101042. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  101043. */
  101044. export class AnaglyphUniversalCamera extends UniversalCamera {
  101045. /**
  101046. * Creates a new AnaglyphUniversalCamera
  101047. * @param name defines camera name
  101048. * @param position defines initial position
  101049. * @param interaxialDistance defines distance between each color axis
  101050. * @param scene defines the hosting scene
  101051. */
  101052. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  101053. /**
  101054. * Gets camera class name
  101055. * @returns AnaglyphUniversalCamera
  101056. */
  101057. getClassName(): string;
  101058. }
  101059. }
  101060. declare module BABYLON {
  101061. /** @hidden */
  101062. export var stereoscopicInterlacePixelShader: {
  101063. name: string;
  101064. shader: string;
  101065. };
  101066. }
  101067. declare module BABYLON {
  101068. /**
  101069. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  101070. */
  101071. export class StereoscopicInterlacePostProcess extends PostProcess {
  101072. private _stepSize;
  101073. private _passedProcess;
  101074. /**
  101075. * Initializes a StereoscopicInterlacePostProcess
  101076. * @param name The name of the effect.
  101077. * @param rigCameras The rig cameras to be appled to the post process
  101078. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  101079. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101080. * @param engine The engine which the post process will be applied. (default: current engine)
  101081. * @param reusable If the post process can be reused on the same frame. (default: false)
  101082. */
  101083. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  101084. }
  101085. }
  101086. declare module BABYLON {
  101087. /**
  101088. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  101089. * @see http://doc.babylonjs.com/features/cameras
  101090. */
  101091. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  101092. /**
  101093. * Creates a new StereoscopicArcRotateCamera
  101094. * @param name defines camera name
  101095. * @param alpha defines alpha angle (in radians)
  101096. * @param beta defines beta angle (in radians)
  101097. * @param radius defines radius
  101098. * @param target defines camera target
  101099. * @param interaxialDistance defines distance between each color axis
  101100. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101101. * @param scene defines the hosting scene
  101102. */
  101103. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101104. /**
  101105. * Gets camera class name
  101106. * @returns StereoscopicArcRotateCamera
  101107. */
  101108. getClassName(): string;
  101109. }
  101110. }
  101111. declare module BABYLON {
  101112. /**
  101113. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  101114. * @see http://doc.babylonjs.com/features/cameras
  101115. */
  101116. export class StereoscopicFreeCamera extends FreeCamera {
  101117. /**
  101118. * Creates a new StereoscopicFreeCamera
  101119. * @param name defines camera name
  101120. * @param position defines initial position
  101121. * @param interaxialDistance defines distance between each color axis
  101122. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101123. * @param scene defines the hosting scene
  101124. */
  101125. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101126. /**
  101127. * Gets camera class name
  101128. * @returns StereoscopicFreeCamera
  101129. */
  101130. getClassName(): string;
  101131. }
  101132. }
  101133. declare module BABYLON {
  101134. /**
  101135. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  101136. * @see http://doc.babylonjs.com/features/cameras
  101137. */
  101138. export class StereoscopicGamepadCamera extends GamepadCamera {
  101139. /**
  101140. * Creates a new StereoscopicGamepadCamera
  101141. * @param name defines camera name
  101142. * @param position defines initial position
  101143. * @param interaxialDistance defines distance between each color axis
  101144. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101145. * @param scene defines the hosting scene
  101146. */
  101147. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101148. /**
  101149. * Gets camera class name
  101150. * @returns StereoscopicGamepadCamera
  101151. */
  101152. getClassName(): string;
  101153. }
  101154. }
  101155. declare module BABYLON {
  101156. /**
  101157. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  101158. * @see http://doc.babylonjs.com/features/cameras
  101159. */
  101160. export class StereoscopicUniversalCamera extends UniversalCamera {
  101161. /**
  101162. * Creates a new StereoscopicUniversalCamera
  101163. * @param name defines camera name
  101164. * @param position defines initial position
  101165. * @param interaxialDistance defines distance between each color axis
  101166. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  101167. * @param scene defines the hosting scene
  101168. */
  101169. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  101170. /**
  101171. * Gets camera class name
  101172. * @returns StereoscopicUniversalCamera
  101173. */
  101174. getClassName(): string;
  101175. }
  101176. }
  101177. declare module BABYLON {
  101178. /**
  101179. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  101180. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  101181. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  101182. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  101183. */
  101184. export class VirtualJoysticksCamera extends FreeCamera {
  101185. /**
  101186. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  101187. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  101188. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  101189. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  101190. * @param name Define the name of the camera in the scene
  101191. * @param position Define the start position of the camera in the scene
  101192. * @param scene Define the scene the camera belongs to
  101193. */
  101194. constructor(name: string, position: Vector3, scene: Scene);
  101195. /**
  101196. * Gets the current object class name.
  101197. * @return the class name
  101198. */
  101199. getClassName(): string;
  101200. }
  101201. }
  101202. declare module BABYLON {
  101203. /**
  101204. * This represents all the required metrics to create a VR camera.
  101205. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  101206. */
  101207. export class VRCameraMetrics {
  101208. /**
  101209. * Define the horizontal resolution off the screen.
  101210. */
  101211. hResolution: number;
  101212. /**
  101213. * Define the vertical resolution off the screen.
  101214. */
  101215. vResolution: number;
  101216. /**
  101217. * Define the horizontal screen size.
  101218. */
  101219. hScreenSize: number;
  101220. /**
  101221. * Define the vertical screen size.
  101222. */
  101223. vScreenSize: number;
  101224. /**
  101225. * Define the vertical screen center position.
  101226. */
  101227. vScreenCenter: number;
  101228. /**
  101229. * Define the distance of the eyes to the screen.
  101230. */
  101231. eyeToScreenDistance: number;
  101232. /**
  101233. * Define the distance between both lenses
  101234. */
  101235. lensSeparationDistance: number;
  101236. /**
  101237. * Define the distance between both viewer's eyes.
  101238. */
  101239. interpupillaryDistance: number;
  101240. /**
  101241. * Define the distortion factor of the VR postprocess.
  101242. * Please, touch with care.
  101243. */
  101244. distortionK: number[];
  101245. /**
  101246. * Define the chromatic aberration correction factors for the VR post process.
  101247. */
  101248. chromaAbCorrection: number[];
  101249. /**
  101250. * Define the scale factor of the post process.
  101251. * The smaller the better but the slower.
  101252. */
  101253. postProcessScaleFactor: number;
  101254. /**
  101255. * Define an offset for the lens center.
  101256. */
  101257. lensCenterOffset: number;
  101258. /**
  101259. * Define if the current vr camera should compensate the distortion of the lense or not.
  101260. */
  101261. compensateDistortion: boolean;
  101262. /**
  101263. * Defines if multiview should be enabled when rendering (Default: false)
  101264. */
  101265. multiviewEnabled: boolean;
  101266. /**
  101267. * Gets the rendering aspect ratio based on the provided resolutions.
  101268. */
  101269. readonly aspectRatio: number;
  101270. /**
  101271. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  101272. */
  101273. readonly aspectRatioFov: number;
  101274. /**
  101275. * @hidden
  101276. */
  101277. readonly leftHMatrix: Matrix;
  101278. /**
  101279. * @hidden
  101280. */
  101281. readonly rightHMatrix: Matrix;
  101282. /**
  101283. * @hidden
  101284. */
  101285. readonly leftPreViewMatrix: Matrix;
  101286. /**
  101287. * @hidden
  101288. */
  101289. readonly rightPreViewMatrix: Matrix;
  101290. /**
  101291. * Get the default VRMetrics based on the most generic setup.
  101292. * @returns the default vr metrics
  101293. */
  101294. static GetDefault(): VRCameraMetrics;
  101295. }
  101296. }
  101297. declare module BABYLON {
  101298. /** @hidden */
  101299. export var vrDistortionCorrectionPixelShader: {
  101300. name: string;
  101301. shader: string;
  101302. };
  101303. }
  101304. declare module BABYLON {
  101305. /**
  101306. * VRDistortionCorrectionPostProcess used for mobile VR
  101307. */
  101308. export class VRDistortionCorrectionPostProcess extends PostProcess {
  101309. private _isRightEye;
  101310. private _distortionFactors;
  101311. private _postProcessScaleFactor;
  101312. private _lensCenterOffset;
  101313. private _scaleIn;
  101314. private _scaleFactor;
  101315. private _lensCenter;
  101316. /**
  101317. * Initializes the VRDistortionCorrectionPostProcess
  101318. * @param name The name of the effect.
  101319. * @param camera The camera to apply the render pass to.
  101320. * @param isRightEye If this is for the right eye distortion
  101321. * @param vrMetrics All the required metrics for the VR camera
  101322. */
  101323. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  101324. }
  101325. }
  101326. declare module BABYLON {
  101327. /**
  101328. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  101329. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101330. */
  101331. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  101332. /**
  101333. * Creates a new VRDeviceOrientationArcRotateCamera
  101334. * @param name defines camera name
  101335. * @param alpha defines the camera rotation along the logitudinal axis
  101336. * @param beta defines the camera rotation along the latitudinal axis
  101337. * @param radius defines the camera distance from its target
  101338. * @param target defines the camera target
  101339. * @param scene defines the scene the camera belongs to
  101340. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101341. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101342. */
  101343. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101344. /**
  101345. * Gets camera class name
  101346. * @returns VRDeviceOrientationArcRotateCamera
  101347. */
  101348. getClassName(): string;
  101349. }
  101350. }
  101351. declare module BABYLON {
  101352. /**
  101353. * Camera used to simulate VR rendering (based on FreeCamera)
  101354. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101355. */
  101356. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  101357. /**
  101358. * Creates a new VRDeviceOrientationFreeCamera
  101359. * @param name defines camera name
  101360. * @param position defines the start position of the camera
  101361. * @param scene defines the scene the camera belongs to
  101362. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101363. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101364. */
  101365. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101366. /**
  101367. * Gets camera class name
  101368. * @returns VRDeviceOrientationFreeCamera
  101369. */
  101370. getClassName(): string;
  101371. }
  101372. }
  101373. declare module BABYLON {
  101374. /**
  101375. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  101376. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  101377. */
  101378. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  101379. /**
  101380. * Creates a new VRDeviceOrientationGamepadCamera
  101381. * @param name defines camera name
  101382. * @param position defines the start position of the camera
  101383. * @param scene defines the scene the camera belongs to
  101384. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  101385. * @param vrCameraMetrics defines the vr metrics associated to the camera
  101386. */
  101387. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  101388. /**
  101389. * Gets camera class name
  101390. * @returns VRDeviceOrientationGamepadCamera
  101391. */
  101392. getClassName(): string;
  101393. }
  101394. }
  101395. declare module BABYLON {
  101396. /**
  101397. * Base class of materials working in push mode in babylon JS
  101398. * @hidden
  101399. */
  101400. export class PushMaterial extends Material {
  101401. protected _activeEffect: Effect;
  101402. protected _normalMatrix: Matrix;
  101403. /**
  101404. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  101405. * This means that the material can keep using a previous shader while a new one is being compiled.
  101406. * This is mostly used when shader parallel compilation is supported (true by default)
  101407. */
  101408. allowShaderHotSwapping: boolean;
  101409. constructor(name: string, scene: Scene);
  101410. getEffect(): Effect;
  101411. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  101412. /**
  101413. * Binds the given world matrix to the active effect
  101414. *
  101415. * @param world the matrix to bind
  101416. */
  101417. bindOnlyWorldMatrix(world: Matrix): void;
  101418. /**
  101419. * Binds the given normal matrix to the active effect
  101420. *
  101421. * @param normalMatrix the matrix to bind
  101422. */
  101423. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  101424. bind(world: Matrix, mesh?: Mesh): void;
  101425. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  101426. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  101427. }
  101428. }
  101429. declare module BABYLON {
  101430. /**
  101431. * This groups all the flags used to control the materials channel.
  101432. */
  101433. export class MaterialFlags {
  101434. private static _DiffuseTextureEnabled;
  101435. /**
  101436. * Are diffuse textures enabled in the application.
  101437. */
  101438. static DiffuseTextureEnabled: boolean;
  101439. private static _AmbientTextureEnabled;
  101440. /**
  101441. * Are ambient textures enabled in the application.
  101442. */
  101443. static AmbientTextureEnabled: boolean;
  101444. private static _OpacityTextureEnabled;
  101445. /**
  101446. * Are opacity textures enabled in the application.
  101447. */
  101448. static OpacityTextureEnabled: boolean;
  101449. private static _ReflectionTextureEnabled;
  101450. /**
  101451. * Are reflection textures enabled in the application.
  101452. */
  101453. static ReflectionTextureEnabled: boolean;
  101454. private static _EmissiveTextureEnabled;
  101455. /**
  101456. * Are emissive textures enabled in the application.
  101457. */
  101458. static EmissiveTextureEnabled: boolean;
  101459. private static _SpecularTextureEnabled;
  101460. /**
  101461. * Are specular textures enabled in the application.
  101462. */
  101463. static SpecularTextureEnabled: boolean;
  101464. private static _BumpTextureEnabled;
  101465. /**
  101466. * Are bump textures enabled in the application.
  101467. */
  101468. static BumpTextureEnabled: boolean;
  101469. private static _LightmapTextureEnabled;
  101470. /**
  101471. * Are lightmap textures enabled in the application.
  101472. */
  101473. static LightmapTextureEnabled: boolean;
  101474. private static _RefractionTextureEnabled;
  101475. /**
  101476. * Are refraction textures enabled in the application.
  101477. */
  101478. static RefractionTextureEnabled: boolean;
  101479. private static _ColorGradingTextureEnabled;
  101480. /**
  101481. * Are color grading textures enabled in the application.
  101482. */
  101483. static ColorGradingTextureEnabled: boolean;
  101484. private static _FresnelEnabled;
  101485. /**
  101486. * Are fresnels enabled in the application.
  101487. */
  101488. static FresnelEnabled: boolean;
  101489. private static _ClearCoatTextureEnabled;
  101490. /**
  101491. * Are clear coat textures enabled in the application.
  101492. */
  101493. static ClearCoatTextureEnabled: boolean;
  101494. private static _ClearCoatBumpTextureEnabled;
  101495. /**
  101496. * Are clear coat bump textures enabled in the application.
  101497. */
  101498. static ClearCoatBumpTextureEnabled: boolean;
  101499. private static _ClearCoatTintTextureEnabled;
  101500. /**
  101501. * Are clear coat tint textures enabled in the application.
  101502. */
  101503. static ClearCoatTintTextureEnabled: boolean;
  101504. private static _SheenTextureEnabled;
  101505. /**
  101506. * Are sheen textures enabled in the application.
  101507. */
  101508. static SheenTextureEnabled: boolean;
  101509. private static _AnisotropicTextureEnabled;
  101510. /**
  101511. * Are anisotropic textures enabled in the application.
  101512. */
  101513. static AnisotropicTextureEnabled: boolean;
  101514. private static _ThicknessTextureEnabled;
  101515. /**
  101516. * Are thickness textures enabled in the application.
  101517. */
  101518. static ThicknessTextureEnabled: boolean;
  101519. }
  101520. }
  101521. declare module BABYLON {
  101522. /** @hidden */
  101523. export var defaultFragmentDeclaration: {
  101524. name: string;
  101525. shader: string;
  101526. };
  101527. }
  101528. declare module BABYLON {
  101529. /** @hidden */
  101530. export var defaultUboDeclaration: {
  101531. name: string;
  101532. shader: string;
  101533. };
  101534. }
  101535. declare module BABYLON {
  101536. /** @hidden */
  101537. export var lightFragmentDeclaration: {
  101538. name: string;
  101539. shader: string;
  101540. };
  101541. }
  101542. declare module BABYLON {
  101543. /** @hidden */
  101544. export var lightUboDeclaration: {
  101545. name: string;
  101546. shader: string;
  101547. };
  101548. }
  101549. declare module BABYLON {
  101550. /** @hidden */
  101551. export var lightsFragmentFunctions: {
  101552. name: string;
  101553. shader: string;
  101554. };
  101555. }
  101556. declare module BABYLON {
  101557. /** @hidden */
  101558. export var shadowsFragmentFunctions: {
  101559. name: string;
  101560. shader: string;
  101561. };
  101562. }
  101563. declare module BABYLON {
  101564. /** @hidden */
  101565. export var fresnelFunction: {
  101566. name: string;
  101567. shader: string;
  101568. };
  101569. }
  101570. declare module BABYLON {
  101571. /** @hidden */
  101572. export var reflectionFunction: {
  101573. name: string;
  101574. shader: string;
  101575. };
  101576. }
  101577. declare module BABYLON {
  101578. /** @hidden */
  101579. export var bumpFragmentFunctions: {
  101580. name: string;
  101581. shader: string;
  101582. };
  101583. }
  101584. declare module BABYLON {
  101585. /** @hidden */
  101586. export var logDepthDeclaration: {
  101587. name: string;
  101588. shader: string;
  101589. };
  101590. }
  101591. declare module BABYLON {
  101592. /** @hidden */
  101593. export var bumpFragment: {
  101594. name: string;
  101595. shader: string;
  101596. };
  101597. }
  101598. declare module BABYLON {
  101599. /** @hidden */
  101600. export var depthPrePass: {
  101601. name: string;
  101602. shader: string;
  101603. };
  101604. }
  101605. declare module BABYLON {
  101606. /** @hidden */
  101607. export var lightFragment: {
  101608. name: string;
  101609. shader: string;
  101610. };
  101611. }
  101612. declare module BABYLON {
  101613. /** @hidden */
  101614. export var logDepthFragment: {
  101615. name: string;
  101616. shader: string;
  101617. };
  101618. }
  101619. declare module BABYLON {
  101620. /** @hidden */
  101621. export var defaultPixelShader: {
  101622. name: string;
  101623. shader: string;
  101624. };
  101625. }
  101626. declare module BABYLON {
  101627. /** @hidden */
  101628. export var defaultVertexDeclaration: {
  101629. name: string;
  101630. shader: string;
  101631. };
  101632. }
  101633. declare module BABYLON {
  101634. /** @hidden */
  101635. export var bumpVertexDeclaration: {
  101636. name: string;
  101637. shader: string;
  101638. };
  101639. }
  101640. declare module BABYLON {
  101641. /** @hidden */
  101642. export var bumpVertex: {
  101643. name: string;
  101644. shader: string;
  101645. };
  101646. }
  101647. declare module BABYLON {
  101648. /** @hidden */
  101649. export var fogVertex: {
  101650. name: string;
  101651. shader: string;
  101652. };
  101653. }
  101654. declare module BABYLON {
  101655. /** @hidden */
  101656. export var shadowsVertex: {
  101657. name: string;
  101658. shader: string;
  101659. };
  101660. }
  101661. declare module BABYLON {
  101662. /** @hidden */
  101663. export var pointCloudVertex: {
  101664. name: string;
  101665. shader: string;
  101666. };
  101667. }
  101668. declare module BABYLON {
  101669. /** @hidden */
  101670. export var logDepthVertex: {
  101671. name: string;
  101672. shader: string;
  101673. };
  101674. }
  101675. declare module BABYLON {
  101676. /** @hidden */
  101677. export var defaultVertexShader: {
  101678. name: string;
  101679. shader: string;
  101680. };
  101681. }
  101682. declare module BABYLON {
  101683. /** @hidden */
  101684. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  101685. MAINUV1: boolean;
  101686. MAINUV2: boolean;
  101687. DIFFUSE: boolean;
  101688. DIFFUSEDIRECTUV: number;
  101689. AMBIENT: boolean;
  101690. AMBIENTDIRECTUV: number;
  101691. OPACITY: boolean;
  101692. OPACITYDIRECTUV: number;
  101693. OPACITYRGB: boolean;
  101694. REFLECTION: boolean;
  101695. EMISSIVE: boolean;
  101696. EMISSIVEDIRECTUV: number;
  101697. SPECULAR: boolean;
  101698. SPECULARDIRECTUV: number;
  101699. BUMP: boolean;
  101700. BUMPDIRECTUV: number;
  101701. PARALLAX: boolean;
  101702. PARALLAXOCCLUSION: boolean;
  101703. SPECULAROVERALPHA: boolean;
  101704. CLIPPLANE: boolean;
  101705. CLIPPLANE2: boolean;
  101706. CLIPPLANE3: boolean;
  101707. CLIPPLANE4: boolean;
  101708. ALPHATEST: boolean;
  101709. DEPTHPREPASS: boolean;
  101710. ALPHAFROMDIFFUSE: boolean;
  101711. POINTSIZE: boolean;
  101712. FOG: boolean;
  101713. SPECULARTERM: boolean;
  101714. DIFFUSEFRESNEL: boolean;
  101715. OPACITYFRESNEL: boolean;
  101716. REFLECTIONFRESNEL: boolean;
  101717. REFRACTIONFRESNEL: boolean;
  101718. EMISSIVEFRESNEL: boolean;
  101719. FRESNEL: boolean;
  101720. NORMAL: boolean;
  101721. UV1: boolean;
  101722. UV2: boolean;
  101723. VERTEXCOLOR: boolean;
  101724. VERTEXALPHA: boolean;
  101725. NUM_BONE_INFLUENCERS: number;
  101726. BonesPerMesh: number;
  101727. BONETEXTURE: boolean;
  101728. INSTANCES: boolean;
  101729. GLOSSINESS: boolean;
  101730. ROUGHNESS: boolean;
  101731. EMISSIVEASILLUMINATION: boolean;
  101732. LINKEMISSIVEWITHDIFFUSE: boolean;
  101733. REFLECTIONFRESNELFROMSPECULAR: boolean;
  101734. LIGHTMAP: boolean;
  101735. LIGHTMAPDIRECTUV: number;
  101736. OBJECTSPACE_NORMALMAP: boolean;
  101737. USELIGHTMAPASSHADOWMAP: boolean;
  101738. REFLECTIONMAP_3D: boolean;
  101739. REFLECTIONMAP_SPHERICAL: boolean;
  101740. REFLECTIONMAP_PLANAR: boolean;
  101741. REFLECTIONMAP_CUBIC: boolean;
  101742. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  101743. REFLECTIONMAP_PROJECTION: boolean;
  101744. REFLECTIONMAP_SKYBOX: boolean;
  101745. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  101746. REFLECTIONMAP_EXPLICIT: boolean;
  101747. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  101748. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  101749. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  101750. INVERTCUBICMAP: boolean;
  101751. LOGARITHMICDEPTH: boolean;
  101752. REFRACTION: boolean;
  101753. REFRACTIONMAP_3D: boolean;
  101754. REFLECTIONOVERALPHA: boolean;
  101755. TWOSIDEDLIGHTING: boolean;
  101756. SHADOWFLOAT: boolean;
  101757. MORPHTARGETS: boolean;
  101758. MORPHTARGETS_NORMAL: boolean;
  101759. MORPHTARGETS_TANGENT: boolean;
  101760. MORPHTARGETS_UV: boolean;
  101761. NUM_MORPH_INFLUENCERS: number;
  101762. NONUNIFORMSCALING: boolean;
  101763. PREMULTIPLYALPHA: boolean;
  101764. IMAGEPROCESSING: boolean;
  101765. VIGNETTE: boolean;
  101766. VIGNETTEBLENDMODEMULTIPLY: boolean;
  101767. VIGNETTEBLENDMODEOPAQUE: boolean;
  101768. TONEMAPPING: boolean;
  101769. TONEMAPPING_ACES: boolean;
  101770. CONTRAST: boolean;
  101771. COLORCURVES: boolean;
  101772. COLORGRADING: boolean;
  101773. COLORGRADING3D: boolean;
  101774. SAMPLER3DGREENDEPTH: boolean;
  101775. SAMPLER3DBGRMAP: boolean;
  101776. IMAGEPROCESSINGPOSTPROCESS: boolean;
  101777. MULTIVIEW: boolean;
  101778. /**
  101779. * If the reflection texture on this material is in linear color space
  101780. * @hidden
  101781. */
  101782. IS_REFLECTION_LINEAR: boolean;
  101783. /**
  101784. * If the refraction texture on this material is in linear color space
  101785. * @hidden
  101786. */
  101787. IS_REFRACTION_LINEAR: boolean;
  101788. EXPOSURE: boolean;
  101789. constructor();
  101790. setReflectionMode(modeToEnable: string): void;
  101791. }
  101792. /**
  101793. * This is the default material used in Babylon. It is the best trade off between quality
  101794. * and performances.
  101795. * @see http://doc.babylonjs.com/babylon101/materials
  101796. */
  101797. export class StandardMaterial extends PushMaterial {
  101798. private _diffuseTexture;
  101799. /**
  101800. * The basic texture of the material as viewed under a light.
  101801. */
  101802. diffuseTexture: Nullable<BaseTexture>;
  101803. private _ambientTexture;
  101804. /**
  101805. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  101806. */
  101807. ambientTexture: Nullable<BaseTexture>;
  101808. private _opacityTexture;
  101809. /**
  101810. * Define the transparency of the material from a texture.
  101811. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  101812. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  101813. */
  101814. opacityTexture: Nullable<BaseTexture>;
  101815. private _reflectionTexture;
  101816. /**
  101817. * Define the texture used to display the reflection.
  101818. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101819. */
  101820. reflectionTexture: Nullable<BaseTexture>;
  101821. private _emissiveTexture;
  101822. /**
  101823. * Define texture of the material as if self lit.
  101824. * This will be mixed in the final result even in the absence of light.
  101825. */
  101826. emissiveTexture: Nullable<BaseTexture>;
  101827. private _specularTexture;
  101828. /**
  101829. * Define how the color and intensity of the highlight given by the light in the material.
  101830. */
  101831. specularTexture: Nullable<BaseTexture>;
  101832. private _bumpTexture;
  101833. /**
  101834. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  101835. * 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.
  101836. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  101837. */
  101838. bumpTexture: Nullable<BaseTexture>;
  101839. private _lightmapTexture;
  101840. /**
  101841. * Complex lighting can be computationally expensive to compute at runtime.
  101842. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  101843. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  101844. */
  101845. lightmapTexture: Nullable<BaseTexture>;
  101846. private _refractionTexture;
  101847. /**
  101848. * Define the texture used to display the refraction.
  101849. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101850. */
  101851. refractionTexture: Nullable<BaseTexture>;
  101852. /**
  101853. * The color of the material lit by the environmental background lighting.
  101854. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  101855. */
  101856. ambientColor: Color3;
  101857. /**
  101858. * The basic color of the material as viewed under a light.
  101859. */
  101860. diffuseColor: Color3;
  101861. /**
  101862. * Define how the color and intensity of the highlight given by the light in the material.
  101863. */
  101864. specularColor: Color3;
  101865. /**
  101866. * Define the color of the material as if self lit.
  101867. * This will be mixed in the final result even in the absence of light.
  101868. */
  101869. emissiveColor: Color3;
  101870. /**
  101871. * Defines how sharp are the highlights in the material.
  101872. * The bigger the value the sharper giving a more glossy feeling to the result.
  101873. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  101874. */
  101875. specularPower: number;
  101876. private _useAlphaFromDiffuseTexture;
  101877. /**
  101878. * Does the transparency come from the diffuse texture alpha channel.
  101879. */
  101880. useAlphaFromDiffuseTexture: boolean;
  101881. private _useEmissiveAsIllumination;
  101882. /**
  101883. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  101884. */
  101885. useEmissiveAsIllumination: boolean;
  101886. private _linkEmissiveWithDiffuse;
  101887. /**
  101888. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  101889. * the emissive level when the final color is close to one.
  101890. */
  101891. linkEmissiveWithDiffuse: boolean;
  101892. private _useSpecularOverAlpha;
  101893. /**
  101894. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  101895. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  101896. */
  101897. useSpecularOverAlpha: boolean;
  101898. private _useReflectionOverAlpha;
  101899. /**
  101900. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101901. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101902. */
  101903. useReflectionOverAlpha: boolean;
  101904. private _disableLighting;
  101905. /**
  101906. * Does lights from the scene impacts this material.
  101907. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  101908. */
  101909. disableLighting: boolean;
  101910. private _useObjectSpaceNormalMap;
  101911. /**
  101912. * Allows using an object space normal map (instead of tangent space).
  101913. */
  101914. useObjectSpaceNormalMap: boolean;
  101915. private _useParallax;
  101916. /**
  101917. * Is parallax enabled or not.
  101918. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  101919. */
  101920. useParallax: boolean;
  101921. private _useParallaxOcclusion;
  101922. /**
  101923. * Is parallax occlusion enabled or not.
  101924. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  101925. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  101926. */
  101927. useParallaxOcclusion: boolean;
  101928. /**
  101929. * 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.
  101930. */
  101931. parallaxScaleBias: number;
  101932. private _roughness;
  101933. /**
  101934. * Helps to define how blurry the reflections should appears in the material.
  101935. */
  101936. roughness: number;
  101937. /**
  101938. * In case of refraction, define the value of the index of refraction.
  101939. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101940. */
  101941. indexOfRefraction: number;
  101942. /**
  101943. * Invert the refraction texture alongside the y axis.
  101944. * It can be useful with procedural textures or probe for instance.
  101945. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101946. */
  101947. invertRefractionY: boolean;
  101948. /**
  101949. * Defines the alpha limits in alpha test mode.
  101950. */
  101951. alphaCutOff: number;
  101952. private _useLightmapAsShadowmap;
  101953. /**
  101954. * In case of light mapping, define whether the map contains light or shadow informations.
  101955. */
  101956. useLightmapAsShadowmap: boolean;
  101957. private _diffuseFresnelParameters;
  101958. /**
  101959. * Define the diffuse fresnel parameters of the material.
  101960. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101961. */
  101962. diffuseFresnelParameters: FresnelParameters;
  101963. private _opacityFresnelParameters;
  101964. /**
  101965. * Define the opacity fresnel parameters of the material.
  101966. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101967. */
  101968. opacityFresnelParameters: FresnelParameters;
  101969. private _reflectionFresnelParameters;
  101970. /**
  101971. * Define the reflection fresnel parameters of the material.
  101972. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101973. */
  101974. reflectionFresnelParameters: FresnelParameters;
  101975. private _refractionFresnelParameters;
  101976. /**
  101977. * Define the refraction fresnel parameters of the material.
  101978. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101979. */
  101980. refractionFresnelParameters: FresnelParameters;
  101981. private _emissiveFresnelParameters;
  101982. /**
  101983. * Define the emissive fresnel parameters of the material.
  101984. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101985. */
  101986. emissiveFresnelParameters: FresnelParameters;
  101987. private _useReflectionFresnelFromSpecular;
  101988. /**
  101989. * If true automatically deducts the fresnels values from the material specularity.
  101990. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101991. */
  101992. useReflectionFresnelFromSpecular: boolean;
  101993. private _useGlossinessFromSpecularMapAlpha;
  101994. /**
  101995. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  101996. */
  101997. useGlossinessFromSpecularMapAlpha: boolean;
  101998. private _maxSimultaneousLights;
  101999. /**
  102000. * Defines the maximum number of lights that can be used in the material
  102001. */
  102002. maxSimultaneousLights: number;
  102003. private _invertNormalMapX;
  102004. /**
  102005. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  102006. */
  102007. invertNormalMapX: boolean;
  102008. private _invertNormalMapY;
  102009. /**
  102010. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  102011. */
  102012. invertNormalMapY: boolean;
  102013. private _twoSidedLighting;
  102014. /**
  102015. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  102016. */
  102017. twoSidedLighting: boolean;
  102018. /**
  102019. * Default configuration related to image processing available in the standard Material.
  102020. */
  102021. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102022. /**
  102023. * Gets the image processing configuration used either in this material.
  102024. */
  102025. /**
  102026. * Sets the Default image processing configuration used either in the this material.
  102027. *
  102028. * If sets to null, the scene one is in use.
  102029. */
  102030. imageProcessingConfiguration: ImageProcessingConfiguration;
  102031. /**
  102032. * Keep track of the image processing observer to allow dispose and replace.
  102033. */
  102034. private _imageProcessingObserver;
  102035. /**
  102036. * Attaches a new image processing configuration to the Standard Material.
  102037. * @param configuration
  102038. */
  102039. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102040. /**
  102041. * Gets wether the color curves effect is enabled.
  102042. */
  102043. /**
  102044. * Sets wether the color curves effect is enabled.
  102045. */
  102046. cameraColorCurvesEnabled: boolean;
  102047. /**
  102048. * Gets wether the color grading effect is enabled.
  102049. */
  102050. /**
  102051. * Gets wether the color grading effect is enabled.
  102052. */
  102053. cameraColorGradingEnabled: boolean;
  102054. /**
  102055. * Gets wether tonemapping is enabled or not.
  102056. */
  102057. /**
  102058. * Sets wether tonemapping is enabled or not
  102059. */
  102060. cameraToneMappingEnabled: boolean;
  102061. /**
  102062. * The camera exposure used on this material.
  102063. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102064. * This corresponds to a photographic exposure.
  102065. */
  102066. /**
  102067. * The camera exposure used on this material.
  102068. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102069. * This corresponds to a photographic exposure.
  102070. */
  102071. cameraExposure: number;
  102072. /**
  102073. * Gets The camera contrast used on this material.
  102074. */
  102075. /**
  102076. * Sets The camera contrast used on this material.
  102077. */
  102078. cameraContrast: number;
  102079. /**
  102080. * Gets the Color Grading 2D Lookup Texture.
  102081. */
  102082. /**
  102083. * Sets the Color Grading 2D Lookup Texture.
  102084. */
  102085. cameraColorGradingTexture: Nullable<BaseTexture>;
  102086. /**
  102087. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102088. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102089. * 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;
  102090. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102091. */
  102092. /**
  102093. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102094. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102095. * 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;
  102096. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102097. */
  102098. cameraColorCurves: Nullable<ColorCurves>;
  102099. /**
  102100. * Custom callback helping to override the default shader used in the material.
  102101. */
  102102. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  102103. protected _renderTargets: SmartArray<RenderTargetTexture>;
  102104. protected _worldViewProjectionMatrix: Matrix;
  102105. protected _globalAmbientColor: Color3;
  102106. protected _useLogarithmicDepth: boolean;
  102107. /**
  102108. * Instantiates a new standard material.
  102109. * This is the default material used in Babylon. It is the best trade off between quality
  102110. * and performances.
  102111. * @see http://doc.babylonjs.com/babylon101/materials
  102112. * @param name Define the name of the material in the scene
  102113. * @param scene Define the scene the material belong to
  102114. */
  102115. constructor(name: string, scene: Scene);
  102116. /**
  102117. * Gets a boolean indicating that current material needs to register RTT
  102118. */
  102119. readonly hasRenderTargetTextures: boolean;
  102120. /**
  102121. * Gets the current class name of the material e.g. "StandardMaterial"
  102122. * Mainly use in serialization.
  102123. * @returns the class name
  102124. */
  102125. getClassName(): string;
  102126. /**
  102127. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  102128. * You can try switching to logarithmic depth.
  102129. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  102130. */
  102131. useLogarithmicDepth: boolean;
  102132. /**
  102133. * Specifies if the material will require alpha blending
  102134. * @returns a boolean specifying if alpha blending is needed
  102135. */
  102136. needAlphaBlending(): boolean;
  102137. /**
  102138. * Specifies if this material should be rendered in alpha test mode
  102139. * @returns a boolean specifying if an alpha test is needed.
  102140. */
  102141. needAlphaTesting(): boolean;
  102142. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  102143. /**
  102144. * Get the texture used for alpha test purpose.
  102145. * @returns the diffuse texture in case of the standard material.
  102146. */
  102147. getAlphaTestTexture(): Nullable<BaseTexture>;
  102148. /**
  102149. * Get if the submesh is ready to be used and all its information available.
  102150. * Child classes can use it to update shaders
  102151. * @param mesh defines the mesh to check
  102152. * @param subMesh defines which submesh to check
  102153. * @param useInstances specifies that instances should be used
  102154. * @returns a boolean indicating that the submesh is ready or not
  102155. */
  102156. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102157. /**
  102158. * Builds the material UBO layouts.
  102159. * Used internally during the effect preparation.
  102160. */
  102161. buildUniformLayout(): void;
  102162. /**
  102163. * Unbinds the material from the mesh
  102164. */
  102165. unbind(): void;
  102166. /**
  102167. * Binds the submesh to this material by preparing the effect and shader to draw
  102168. * @param world defines the world transformation matrix
  102169. * @param mesh defines the mesh containing the submesh
  102170. * @param subMesh defines the submesh to bind the material to
  102171. */
  102172. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102173. /**
  102174. * Get the list of animatables in the material.
  102175. * @returns the list of animatables object used in the material
  102176. */
  102177. getAnimatables(): IAnimatable[];
  102178. /**
  102179. * Gets the active textures from the material
  102180. * @returns an array of textures
  102181. */
  102182. getActiveTextures(): BaseTexture[];
  102183. /**
  102184. * Specifies if the material uses a texture
  102185. * @param texture defines the texture to check against the material
  102186. * @returns a boolean specifying if the material uses the texture
  102187. */
  102188. hasTexture(texture: BaseTexture): boolean;
  102189. /**
  102190. * Disposes the material
  102191. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102192. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102193. */
  102194. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  102195. /**
  102196. * Makes a duplicate of the material, and gives it a new name
  102197. * @param name defines the new name for the duplicated material
  102198. * @returns the cloned material
  102199. */
  102200. clone(name: string): StandardMaterial;
  102201. /**
  102202. * Serializes this material in a JSON representation
  102203. * @returns the serialized material object
  102204. */
  102205. serialize(): any;
  102206. /**
  102207. * Creates a standard material from parsed material data
  102208. * @param source defines the JSON representation of the material
  102209. * @param scene defines the hosting scene
  102210. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102211. * @returns a new standard material
  102212. */
  102213. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  102214. /**
  102215. * Are diffuse textures enabled in the application.
  102216. */
  102217. static DiffuseTextureEnabled: boolean;
  102218. /**
  102219. * Are ambient textures enabled in the application.
  102220. */
  102221. static AmbientTextureEnabled: boolean;
  102222. /**
  102223. * Are opacity textures enabled in the application.
  102224. */
  102225. static OpacityTextureEnabled: boolean;
  102226. /**
  102227. * Are reflection textures enabled in the application.
  102228. */
  102229. static ReflectionTextureEnabled: boolean;
  102230. /**
  102231. * Are emissive textures enabled in the application.
  102232. */
  102233. static EmissiveTextureEnabled: boolean;
  102234. /**
  102235. * Are specular textures enabled in the application.
  102236. */
  102237. static SpecularTextureEnabled: boolean;
  102238. /**
  102239. * Are bump textures enabled in the application.
  102240. */
  102241. static BumpTextureEnabled: boolean;
  102242. /**
  102243. * Are lightmap textures enabled in the application.
  102244. */
  102245. static LightmapTextureEnabled: boolean;
  102246. /**
  102247. * Are refraction textures enabled in the application.
  102248. */
  102249. static RefractionTextureEnabled: boolean;
  102250. /**
  102251. * Are color grading textures enabled in the application.
  102252. */
  102253. static ColorGradingTextureEnabled: boolean;
  102254. /**
  102255. * Are fresnels enabled in the application.
  102256. */
  102257. static FresnelEnabled: boolean;
  102258. }
  102259. }
  102260. declare module BABYLON {
  102261. /**
  102262. * A class extending Texture allowing drawing on a texture
  102263. * @see http://doc.babylonjs.com/how_to/dynamictexture
  102264. */
  102265. export class DynamicTexture extends Texture {
  102266. private _generateMipMaps;
  102267. private _canvas;
  102268. private _context;
  102269. private _engine;
  102270. /**
  102271. * Creates a DynamicTexture
  102272. * @param name defines the name of the texture
  102273. * @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
  102274. * @param scene defines the scene where you want the texture
  102275. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  102276. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  102277. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  102278. */
  102279. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  102280. /**
  102281. * Get the current class name of the texture useful for serialization or dynamic coding.
  102282. * @returns "DynamicTexture"
  102283. */
  102284. getClassName(): string;
  102285. /**
  102286. * Gets the current state of canRescale
  102287. */
  102288. readonly canRescale: boolean;
  102289. private _recreate;
  102290. /**
  102291. * Scales the texture
  102292. * @param ratio the scale factor to apply to both width and height
  102293. */
  102294. scale(ratio: number): void;
  102295. /**
  102296. * Resizes the texture
  102297. * @param width the new width
  102298. * @param height the new height
  102299. */
  102300. scaleTo(width: number, height: number): void;
  102301. /**
  102302. * Gets the context of the canvas used by the texture
  102303. * @returns the canvas context of the dynamic texture
  102304. */
  102305. getContext(): CanvasRenderingContext2D;
  102306. /**
  102307. * Clears the texture
  102308. */
  102309. clear(): void;
  102310. /**
  102311. * Updates the texture
  102312. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  102313. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  102314. */
  102315. update(invertY?: boolean, premulAlpha?: boolean): void;
  102316. /**
  102317. * Draws text onto the texture
  102318. * @param text defines the text to be drawn
  102319. * @param x defines the placement of the text from the left
  102320. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  102321. * @param font defines the font to be used with font-style, font-size, font-name
  102322. * @param color defines the color used for the text
  102323. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  102324. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  102325. * @param update defines whether texture is immediately update (default is true)
  102326. */
  102327. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  102328. /**
  102329. * Clones the texture
  102330. * @returns the clone of the texture.
  102331. */
  102332. clone(): DynamicTexture;
  102333. /**
  102334. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  102335. * @returns a serialized dynamic texture object
  102336. */
  102337. serialize(): any;
  102338. /** @hidden */
  102339. _rebuild(): void;
  102340. }
  102341. }
  102342. declare module BABYLON {
  102343. /** @hidden */
  102344. export var imageProcessingPixelShader: {
  102345. name: string;
  102346. shader: string;
  102347. };
  102348. }
  102349. declare module BABYLON {
  102350. /**
  102351. * ImageProcessingPostProcess
  102352. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  102353. */
  102354. export class ImageProcessingPostProcess extends PostProcess {
  102355. /**
  102356. * Default configuration related to image processing available in the PBR Material.
  102357. */
  102358. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102359. /**
  102360. * Gets the image processing configuration used either in this material.
  102361. */
  102362. /**
  102363. * Sets the Default image processing configuration used either in the this material.
  102364. *
  102365. * If sets to null, the scene one is in use.
  102366. */
  102367. imageProcessingConfiguration: ImageProcessingConfiguration;
  102368. /**
  102369. * Keep track of the image processing observer to allow dispose and replace.
  102370. */
  102371. private _imageProcessingObserver;
  102372. /**
  102373. * Attaches a new image processing configuration to the PBR Material.
  102374. * @param configuration
  102375. */
  102376. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  102377. /**
  102378. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102379. */
  102380. /**
  102381. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  102382. */
  102383. colorCurves: Nullable<ColorCurves>;
  102384. /**
  102385. * Gets wether the color curves effect is enabled.
  102386. */
  102387. /**
  102388. * Sets wether the color curves effect is enabled.
  102389. */
  102390. colorCurvesEnabled: boolean;
  102391. /**
  102392. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102393. */
  102394. /**
  102395. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  102396. */
  102397. colorGradingTexture: Nullable<BaseTexture>;
  102398. /**
  102399. * Gets wether the color grading effect is enabled.
  102400. */
  102401. /**
  102402. * Gets wether the color grading effect is enabled.
  102403. */
  102404. colorGradingEnabled: boolean;
  102405. /**
  102406. * Gets exposure used in the effect.
  102407. */
  102408. /**
  102409. * Sets exposure used in the effect.
  102410. */
  102411. exposure: number;
  102412. /**
  102413. * Gets wether tonemapping is enabled or not.
  102414. */
  102415. /**
  102416. * Sets wether tonemapping is enabled or not
  102417. */
  102418. toneMappingEnabled: boolean;
  102419. /**
  102420. * Gets the type of tone mapping effect.
  102421. */
  102422. /**
  102423. * Sets the type of tone mapping effect.
  102424. */
  102425. toneMappingType: number;
  102426. /**
  102427. * Gets contrast used in the effect.
  102428. */
  102429. /**
  102430. * Sets contrast used in the effect.
  102431. */
  102432. contrast: number;
  102433. /**
  102434. * Gets Vignette stretch size.
  102435. */
  102436. /**
  102437. * Sets Vignette stretch size.
  102438. */
  102439. vignetteStretch: number;
  102440. /**
  102441. * Gets Vignette centre X Offset.
  102442. */
  102443. /**
  102444. * Sets Vignette centre X Offset.
  102445. */
  102446. vignetteCentreX: number;
  102447. /**
  102448. * Gets Vignette centre Y Offset.
  102449. */
  102450. /**
  102451. * Sets Vignette centre Y Offset.
  102452. */
  102453. vignetteCentreY: number;
  102454. /**
  102455. * Gets Vignette weight or intensity of the vignette effect.
  102456. */
  102457. /**
  102458. * Sets Vignette weight or intensity of the vignette effect.
  102459. */
  102460. vignetteWeight: number;
  102461. /**
  102462. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102463. * if vignetteEnabled is set to true.
  102464. */
  102465. /**
  102466. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  102467. * if vignetteEnabled is set to true.
  102468. */
  102469. vignetteColor: Color4;
  102470. /**
  102471. * Gets Camera field of view used by the Vignette effect.
  102472. */
  102473. /**
  102474. * Sets Camera field of view used by the Vignette effect.
  102475. */
  102476. vignetteCameraFov: number;
  102477. /**
  102478. * Gets the vignette blend mode allowing different kind of effect.
  102479. */
  102480. /**
  102481. * Sets the vignette blend mode allowing different kind of effect.
  102482. */
  102483. vignetteBlendMode: number;
  102484. /**
  102485. * Gets wether the vignette effect is enabled.
  102486. */
  102487. /**
  102488. * Sets wether the vignette effect is enabled.
  102489. */
  102490. vignetteEnabled: boolean;
  102491. private _fromLinearSpace;
  102492. /**
  102493. * Gets wether the input of the processing is in Gamma or Linear Space.
  102494. */
  102495. /**
  102496. * Sets wether the input of the processing is in Gamma or Linear Space.
  102497. */
  102498. fromLinearSpace: boolean;
  102499. /**
  102500. * Defines cache preventing GC.
  102501. */
  102502. private _defines;
  102503. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  102504. /**
  102505. * "ImageProcessingPostProcess"
  102506. * @returns "ImageProcessingPostProcess"
  102507. */
  102508. getClassName(): string;
  102509. protected _updateParameters(): void;
  102510. dispose(camera?: Camera): void;
  102511. }
  102512. }
  102513. declare module BABYLON {
  102514. /**
  102515. * Class containing static functions to help procedurally build meshes
  102516. */
  102517. export class GroundBuilder {
  102518. /**
  102519. * Creates a ground mesh
  102520. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  102521. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  102522. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102523. * @param name defines the name of the mesh
  102524. * @param options defines the options used to create the mesh
  102525. * @param scene defines the hosting scene
  102526. * @returns the ground mesh
  102527. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  102528. */
  102529. static CreateGround(name: string, options: {
  102530. width?: number;
  102531. height?: number;
  102532. subdivisions?: number;
  102533. subdivisionsX?: number;
  102534. subdivisionsY?: number;
  102535. updatable?: boolean;
  102536. }, scene: any): Mesh;
  102537. /**
  102538. * Creates a tiled ground mesh
  102539. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  102540. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  102541. * * 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
  102542. * * 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
  102543. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102544. * @param name defines the name of the mesh
  102545. * @param options defines the options used to create the mesh
  102546. * @param scene defines the hosting scene
  102547. * @returns the tiled ground mesh
  102548. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  102549. */
  102550. static CreateTiledGround(name: string, options: {
  102551. xmin: number;
  102552. zmin: number;
  102553. xmax: number;
  102554. zmax: number;
  102555. subdivisions?: {
  102556. w: number;
  102557. h: number;
  102558. };
  102559. precision?: {
  102560. w: number;
  102561. h: number;
  102562. };
  102563. updatable?: boolean;
  102564. }, scene?: Nullable<Scene>): Mesh;
  102565. /**
  102566. * Creates a ground mesh from a height map
  102567. * * The parameter `url` sets the URL of the height map image resource.
  102568. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  102569. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  102570. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  102571. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  102572. * * 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.
  102573. * * 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).
  102574. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  102575. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102576. * @param name defines the name of the mesh
  102577. * @param url defines the url to the height map
  102578. * @param options defines the options used to create the mesh
  102579. * @param scene defines the hosting scene
  102580. * @returns the ground mesh
  102581. * @see https://doc.babylonjs.com/babylon101/height_map
  102582. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  102583. */
  102584. static CreateGroundFromHeightMap(name: string, url: string, options: {
  102585. width?: number;
  102586. height?: number;
  102587. subdivisions?: number;
  102588. minHeight?: number;
  102589. maxHeight?: number;
  102590. colorFilter?: Color3;
  102591. alphaFilter?: number;
  102592. updatable?: boolean;
  102593. onReady?: (mesh: GroundMesh) => void;
  102594. }, scene?: Nullable<Scene>): GroundMesh;
  102595. }
  102596. }
  102597. declare module BABYLON {
  102598. /**
  102599. * Class containing static functions to help procedurally build meshes
  102600. */
  102601. export class TorusBuilder {
  102602. /**
  102603. * Creates a torus mesh
  102604. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  102605. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  102606. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  102607. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102608. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102609. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102610. * @param name defines the name of the mesh
  102611. * @param options defines the options used to create the mesh
  102612. * @param scene defines the hosting scene
  102613. * @returns the torus mesh
  102614. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  102615. */
  102616. static CreateTorus(name: string, options: {
  102617. diameter?: number;
  102618. thickness?: number;
  102619. tessellation?: number;
  102620. updatable?: boolean;
  102621. sideOrientation?: number;
  102622. frontUVs?: Vector4;
  102623. backUVs?: Vector4;
  102624. }, scene: any): Mesh;
  102625. }
  102626. }
  102627. declare module BABYLON {
  102628. /**
  102629. * Class containing static functions to help procedurally build meshes
  102630. */
  102631. export class CylinderBuilder {
  102632. /**
  102633. * Creates a cylinder or a cone mesh
  102634. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  102635. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  102636. * * 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.
  102637. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  102638. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  102639. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  102640. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  102641. * * 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).
  102642. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  102643. * * 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).
  102644. * * 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
  102645. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  102646. * * 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
  102647. * * 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.
  102648. * * If `enclose` is false, a ring surface is one element.
  102649. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  102650. * * 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
  102651. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102652. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102653. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  102654. * @param name defines the name of the mesh
  102655. * @param options defines the options used to create the mesh
  102656. * @param scene defines the hosting scene
  102657. * @returns the cylinder mesh
  102658. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  102659. */
  102660. static CreateCylinder(name: string, options: {
  102661. height?: number;
  102662. diameterTop?: number;
  102663. diameterBottom?: number;
  102664. diameter?: number;
  102665. tessellation?: number;
  102666. subdivisions?: number;
  102667. arc?: number;
  102668. faceColors?: Color4[];
  102669. faceUV?: Vector4[];
  102670. updatable?: boolean;
  102671. hasRings?: boolean;
  102672. enclose?: boolean;
  102673. cap?: number;
  102674. sideOrientation?: number;
  102675. frontUVs?: Vector4;
  102676. backUVs?: Vector4;
  102677. }, scene: any): Mesh;
  102678. }
  102679. }
  102680. declare module BABYLON {
  102681. /**
  102682. * Options to modify the vr teleportation behavior.
  102683. */
  102684. export interface VRTeleportationOptions {
  102685. /**
  102686. * The name of the mesh which should be used as the teleportation floor. (default: null)
  102687. */
  102688. floorMeshName?: string;
  102689. /**
  102690. * A list of meshes to be used as the teleportation floor. (default: empty)
  102691. */
  102692. floorMeshes?: Mesh[];
  102693. }
  102694. /**
  102695. * Options to modify the vr experience helper's behavior.
  102696. */
  102697. export interface VRExperienceHelperOptions extends WebVROptions {
  102698. /**
  102699. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  102700. */
  102701. createDeviceOrientationCamera?: boolean;
  102702. /**
  102703. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  102704. */
  102705. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  102706. /**
  102707. * Uses the main button on the controller to toggle the laser casted. (default: true)
  102708. */
  102709. laserToggle?: boolean;
  102710. /**
  102711. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  102712. */
  102713. floorMeshes?: Mesh[];
  102714. /**
  102715. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  102716. */
  102717. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  102718. }
  102719. /**
  102720. * Event containing information after VR has been entered
  102721. */
  102722. export class OnAfterEnteringVRObservableEvent {
  102723. /**
  102724. * If entering vr was successful
  102725. */
  102726. success: boolean;
  102727. }
  102728. /**
  102729. * Helps to quickly add VR support to an existing scene.
  102730. * See http://doc.babylonjs.com/how_to/webvr_helper
  102731. */
  102732. export class VRExperienceHelper {
  102733. /** Options to modify the vr experience helper's behavior. */
  102734. webVROptions: VRExperienceHelperOptions;
  102735. private _scene;
  102736. private _position;
  102737. private _btnVR;
  102738. private _btnVRDisplayed;
  102739. private _webVRsupported;
  102740. private _webVRready;
  102741. private _webVRrequesting;
  102742. private _webVRpresenting;
  102743. private _hasEnteredVR;
  102744. private _fullscreenVRpresenting;
  102745. private _canvas;
  102746. private _webVRCamera;
  102747. private _vrDeviceOrientationCamera;
  102748. private _deviceOrientationCamera;
  102749. private _existingCamera;
  102750. private _onKeyDown;
  102751. private _onVrDisplayPresentChange;
  102752. private _onVRDisplayChanged;
  102753. private _onVRRequestPresentStart;
  102754. private _onVRRequestPresentComplete;
  102755. /**
  102756. * Observable raised right before entering VR.
  102757. */
  102758. onEnteringVRObservable: Observable<VRExperienceHelper>;
  102759. /**
  102760. * Observable raised when entering VR has completed.
  102761. */
  102762. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  102763. /**
  102764. * Observable raised when exiting VR.
  102765. */
  102766. onExitingVRObservable: Observable<VRExperienceHelper>;
  102767. /**
  102768. * Observable raised when controller mesh is loaded.
  102769. */
  102770. onControllerMeshLoadedObservable: Observable<WebVRController>;
  102771. /** Return this.onEnteringVRObservable
  102772. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  102773. */
  102774. readonly onEnteringVR: Observable<VRExperienceHelper>;
  102775. /** Return this.onExitingVRObservable
  102776. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  102777. */
  102778. readonly onExitingVR: Observable<VRExperienceHelper>;
  102779. /** Return this.onControllerMeshLoadedObservable
  102780. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  102781. */
  102782. readonly onControllerMeshLoaded: Observable<WebVRController>;
  102783. private _rayLength;
  102784. private _useCustomVRButton;
  102785. private _teleportationRequested;
  102786. private _teleportActive;
  102787. private _floorMeshName;
  102788. private _floorMeshesCollection;
  102789. private _rotationAllowed;
  102790. private _teleportBackwardsVector;
  102791. private _teleportationTarget;
  102792. private _isDefaultTeleportationTarget;
  102793. private _postProcessMove;
  102794. private _teleportationFillColor;
  102795. private _teleportationBorderColor;
  102796. private _rotationAngle;
  102797. private _haloCenter;
  102798. private _cameraGazer;
  102799. private _padSensibilityUp;
  102800. private _padSensibilityDown;
  102801. private _leftController;
  102802. private _rightController;
  102803. /**
  102804. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  102805. */
  102806. onNewMeshSelected: Observable<AbstractMesh>;
  102807. /**
  102808. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  102809. */
  102810. onNewMeshPicked: Observable<PickingInfo>;
  102811. private _circleEase;
  102812. /**
  102813. * Observable raised before camera teleportation
  102814. */
  102815. onBeforeCameraTeleport: Observable<Vector3>;
  102816. /**
  102817. * Observable raised after camera teleportation
  102818. */
  102819. onAfterCameraTeleport: Observable<Vector3>;
  102820. /**
  102821. * Observable raised when current selected mesh gets unselected
  102822. */
  102823. onSelectedMeshUnselected: Observable<AbstractMesh>;
  102824. private _raySelectionPredicate;
  102825. /**
  102826. * To be optionaly changed by user to define custom ray selection
  102827. */
  102828. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  102829. /**
  102830. * To be optionaly changed by user to define custom selection logic (after ray selection)
  102831. */
  102832. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  102833. /**
  102834. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  102835. */
  102836. teleportationEnabled: boolean;
  102837. private _defaultHeight;
  102838. private _teleportationInitialized;
  102839. private _interactionsEnabled;
  102840. private _interactionsRequested;
  102841. private _displayGaze;
  102842. private _displayLaserPointer;
  102843. /**
  102844. * The mesh used to display where the user is going to teleport.
  102845. */
  102846. /**
  102847. * Sets the mesh to be used to display where the user is going to teleport.
  102848. */
  102849. teleportationTarget: Mesh;
  102850. /**
  102851. * 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
  102852. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  102853. * See http://doc.babylonjs.com/resources/baking_transformations
  102854. */
  102855. gazeTrackerMesh: Mesh;
  102856. /**
  102857. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  102858. */
  102859. updateGazeTrackerScale: boolean;
  102860. /**
  102861. * If the gaze trackers color should be updated when selecting meshes
  102862. */
  102863. updateGazeTrackerColor: boolean;
  102864. /**
  102865. * The gaze tracking mesh corresponding to the left controller
  102866. */
  102867. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  102868. /**
  102869. * The gaze tracking mesh corresponding to the right controller
  102870. */
  102871. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  102872. /**
  102873. * If the ray of the gaze should be displayed.
  102874. */
  102875. /**
  102876. * Sets if the ray of the gaze should be displayed.
  102877. */
  102878. displayGaze: boolean;
  102879. /**
  102880. * If the ray of the LaserPointer should be displayed.
  102881. */
  102882. /**
  102883. * Sets if the ray of the LaserPointer should be displayed.
  102884. */
  102885. displayLaserPointer: boolean;
  102886. /**
  102887. * The deviceOrientationCamera used as the camera when not in VR.
  102888. */
  102889. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  102890. /**
  102891. * Based on the current WebVR support, returns the current VR camera used.
  102892. */
  102893. readonly currentVRCamera: Nullable<Camera>;
  102894. /**
  102895. * The webVRCamera which is used when in VR.
  102896. */
  102897. readonly webVRCamera: WebVRFreeCamera;
  102898. /**
  102899. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  102900. */
  102901. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  102902. private readonly _teleportationRequestInitiated;
  102903. /**
  102904. * Defines wether or not Pointer lock should be requested when switching to
  102905. * full screen.
  102906. */
  102907. requestPointerLockOnFullScreen: boolean;
  102908. /**
  102909. * Instantiates a VRExperienceHelper.
  102910. * Helps to quickly add VR support to an existing scene.
  102911. * @param scene The scene the VRExperienceHelper belongs to.
  102912. * @param webVROptions Options to modify the vr experience helper's behavior.
  102913. */
  102914. constructor(scene: Scene,
  102915. /** Options to modify the vr experience helper's behavior. */
  102916. webVROptions?: VRExperienceHelperOptions);
  102917. private _onDefaultMeshLoaded;
  102918. private _onResize;
  102919. private _onFullscreenChange;
  102920. /**
  102921. * Gets a value indicating if we are currently in VR mode.
  102922. */
  102923. readonly isInVRMode: boolean;
  102924. private onVrDisplayPresentChange;
  102925. private onVRDisplayChanged;
  102926. private moveButtonToBottomRight;
  102927. private displayVRButton;
  102928. private updateButtonVisibility;
  102929. private _cachedAngularSensibility;
  102930. /**
  102931. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  102932. * Otherwise, will use the fullscreen API.
  102933. */
  102934. enterVR(): void;
  102935. /**
  102936. * Attempt to exit VR, or fullscreen.
  102937. */
  102938. exitVR(): void;
  102939. /**
  102940. * The position of the vr experience helper.
  102941. */
  102942. /**
  102943. * Sets the position of the vr experience helper.
  102944. */
  102945. position: Vector3;
  102946. /**
  102947. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  102948. */
  102949. enableInteractions(): void;
  102950. private readonly _noControllerIsActive;
  102951. private beforeRender;
  102952. private _isTeleportationFloor;
  102953. /**
  102954. * Adds a floor mesh to be used for teleportation.
  102955. * @param floorMesh the mesh to be used for teleportation.
  102956. */
  102957. addFloorMesh(floorMesh: Mesh): void;
  102958. /**
  102959. * Removes a floor mesh from being used for teleportation.
  102960. * @param floorMesh the mesh to be removed.
  102961. */
  102962. removeFloorMesh(floorMesh: Mesh): void;
  102963. /**
  102964. * Enables interactions and teleportation using the VR controllers and gaze.
  102965. * @param vrTeleportationOptions options to modify teleportation behavior.
  102966. */
  102967. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  102968. private _onNewGamepadConnected;
  102969. private _tryEnableInteractionOnController;
  102970. private _onNewGamepadDisconnected;
  102971. private _enableInteractionOnController;
  102972. private _checkTeleportWithRay;
  102973. private _checkRotate;
  102974. private _checkTeleportBackwards;
  102975. private _enableTeleportationOnController;
  102976. private _createTeleportationCircles;
  102977. private _displayTeleportationTarget;
  102978. private _hideTeleportationTarget;
  102979. private _rotateCamera;
  102980. private _moveTeleportationSelectorTo;
  102981. private _workingVector;
  102982. private _workingQuaternion;
  102983. private _workingMatrix;
  102984. /**
  102985. * Teleports the users feet to the desired location
  102986. * @param location The location where the user's feet should be placed
  102987. */
  102988. teleportCamera(location: Vector3): void;
  102989. private _convertNormalToDirectionOfRay;
  102990. private _castRayAndSelectObject;
  102991. private _notifySelectedMeshUnselected;
  102992. /**
  102993. * Sets the color of the laser ray from the vr controllers.
  102994. * @param color new color for the ray.
  102995. */
  102996. changeLaserColor(color: Color3): void;
  102997. /**
  102998. * Sets the color of the ray from the vr headsets gaze.
  102999. * @param color new color for the ray.
  103000. */
  103001. changeGazeColor(color: Color3): void;
  103002. /**
  103003. * Exits VR and disposes of the vr experience helper
  103004. */
  103005. dispose(): void;
  103006. /**
  103007. * Gets the name of the VRExperienceHelper class
  103008. * @returns "VRExperienceHelper"
  103009. */
  103010. getClassName(): string;
  103011. }
  103012. }
  103013. declare module BABYLON {
  103014. /**
  103015. * Manages an XRSession
  103016. * @see https://doc.babylonjs.com/how_to/webxr
  103017. */
  103018. export class WebXRSessionManager implements IDisposable {
  103019. private scene;
  103020. /**
  103021. * Fires every time a new xrFrame arrives which can be used to update the camera
  103022. */
  103023. onXRFrameObservable: Observable<any>;
  103024. /**
  103025. * Fires when the xr session is ended either by the device or manually done
  103026. */
  103027. onXRSessionEnded: Observable<any>;
  103028. /** @hidden */
  103029. _xrSession: XRSession;
  103030. /** @hidden */
  103031. _frameOfReference: XRFrameOfReference;
  103032. /** @hidden */
  103033. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  103034. /** @hidden */
  103035. _currentXRFrame: Nullable<XRFrame>;
  103036. private _xrNavigator;
  103037. private _xrDevice;
  103038. private _tmpMatrix;
  103039. /**
  103040. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  103041. * @param scene The scene which the session should be created for
  103042. */
  103043. constructor(scene: Scene);
  103044. /**
  103045. * Initializes the manager
  103046. * After initialization enterXR can be called to start an XR session
  103047. * @returns Promise which resolves after it is initialized
  103048. */
  103049. initializeAsync(): Promise<void>;
  103050. /**
  103051. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  103052. * @param sessionCreationOptions xr options to create the session with
  103053. * @param frameOfReferenceType option to configure how the xr pose is expressed
  103054. * @returns Promise which resolves after it enters XR
  103055. */
  103056. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  103057. /**
  103058. * Stops the xrSession and restores the renderloop
  103059. * @returns Promise which resolves after it exits XR
  103060. */
  103061. exitXRAsync(): Promise<void>;
  103062. /**
  103063. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  103064. * @param ray ray to cast into the environment
  103065. * @returns Promise which resolves with a collision point in the environment if it exists
  103066. */
  103067. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  103068. /**
  103069. * Checks if a session would be supported for the creation options specified
  103070. * @param options creation options to check if they are supported
  103071. * @returns true if supported
  103072. */
  103073. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  103074. /**
  103075. * @hidden
  103076. * Converts the render layer of xrSession to a render target
  103077. * @param session session to create render target for
  103078. * @param scene scene the new render target should be created for
  103079. */
  103080. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  103081. /**
  103082. * Disposes of the session manager
  103083. */
  103084. dispose(): void;
  103085. }
  103086. }
  103087. declare module BABYLON {
  103088. /**
  103089. * WebXR Camera which holds the views for the xrSession
  103090. * @see https://doc.babylonjs.com/how_to/webxr
  103091. */
  103092. export class WebXRCamera extends FreeCamera {
  103093. private static _TmpMatrix;
  103094. /**
  103095. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  103096. * @param name the name of the camera
  103097. * @param scene the scene to add the camera to
  103098. */
  103099. constructor(name: string, scene: Scene);
  103100. private _updateNumberOfRigCameras;
  103101. /** @hidden */
  103102. _updateForDualEyeDebugging(pupilDistance?: number): void;
  103103. /**
  103104. * Updates the cameras position from the current pose information of the XR session
  103105. * @param xrSessionManager the session containing pose information
  103106. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  103107. */
  103108. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  103109. }
  103110. }
  103111. declare module BABYLON {
  103112. /**
  103113. * States of the webXR experience
  103114. */
  103115. export enum WebXRState {
  103116. /**
  103117. * Transitioning to being in XR mode
  103118. */
  103119. ENTERING_XR = 0,
  103120. /**
  103121. * Transitioning to non XR mode
  103122. */
  103123. EXITING_XR = 1,
  103124. /**
  103125. * In XR mode and presenting
  103126. */
  103127. IN_XR = 2,
  103128. /**
  103129. * Not entered XR mode
  103130. */
  103131. NOT_IN_XR = 3
  103132. }
  103133. /**
  103134. * Helper class used to enable XR
  103135. * @see https://doc.babylonjs.com/how_to/webxr
  103136. */
  103137. export class WebXRExperienceHelper implements IDisposable {
  103138. private scene;
  103139. /**
  103140. * 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
  103141. */
  103142. container: AbstractMesh;
  103143. /**
  103144. * Camera used to render xr content
  103145. */
  103146. camera: WebXRCamera;
  103147. /**
  103148. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  103149. */
  103150. state: WebXRState;
  103151. private _setState;
  103152. private static _TmpVector;
  103153. /**
  103154. * Fires when the state of the experience helper has changed
  103155. */
  103156. onStateChangedObservable: Observable<WebXRState>;
  103157. /** @hidden */
  103158. _sessionManager: WebXRSessionManager;
  103159. private _nonVRCamera;
  103160. private _originalSceneAutoClear;
  103161. private _supported;
  103162. /**
  103163. * Creates the experience helper
  103164. * @param scene the scene to attach the experience helper to
  103165. * @returns a promise for the experience helper
  103166. */
  103167. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  103168. /**
  103169. * Creates a WebXRExperienceHelper
  103170. * @param scene The scene the helper should be created in
  103171. */
  103172. private constructor();
  103173. /**
  103174. * Exits XR mode and returns the scene to its original state
  103175. * @returns promise that resolves after xr mode has exited
  103176. */
  103177. exitXRAsync(): Promise<void>;
  103178. /**
  103179. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  103180. * @param sessionCreationOptions options for the XR session
  103181. * @param frameOfReference frame of reference of the XR session
  103182. * @returns promise that resolves after xr mode has entered
  103183. */
  103184. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  103185. /**
  103186. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  103187. * @param ray ray to cast into the environment
  103188. * @returns Promise which resolves with a collision point in the environment if it exists
  103189. */
  103190. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  103191. /**
  103192. * Updates the global position of the camera by moving the camera's container
  103193. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  103194. * @param position The desired global position of the camera
  103195. */
  103196. setPositionOfCameraUsingContainer(position: Vector3): void;
  103197. /**
  103198. * Rotates the xr camera by rotating the camera's container around the camera's position
  103199. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  103200. * @param rotation the desired quaternion rotation to apply to the camera
  103201. */
  103202. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  103203. /**
  103204. * Checks if the creation options are supported by the xr session
  103205. * @param options creation options
  103206. * @returns true if supported
  103207. */
  103208. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  103209. /**
  103210. * Disposes of the experience helper
  103211. */
  103212. dispose(): void;
  103213. }
  103214. }
  103215. declare module BABYLON {
  103216. /**
  103217. * Button which can be used to enter a different mode of XR
  103218. */
  103219. export class WebXREnterExitUIButton {
  103220. /** button element */
  103221. element: HTMLElement;
  103222. /** XR initialization options for the button */
  103223. initializationOptions: XRSessionCreationOptions;
  103224. /**
  103225. * Creates a WebXREnterExitUIButton
  103226. * @param element button element
  103227. * @param initializationOptions XR initialization options for the button
  103228. */
  103229. constructor(
  103230. /** button element */
  103231. element: HTMLElement,
  103232. /** XR initialization options for the button */
  103233. initializationOptions: XRSessionCreationOptions);
  103234. /**
  103235. * Overwritable function which can be used to update the button's visuals when the state changes
  103236. * @param activeButton the current active button in the UI
  103237. */
  103238. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  103239. }
  103240. /**
  103241. * Options to create the webXR UI
  103242. */
  103243. export class WebXREnterExitUIOptions {
  103244. /**
  103245. * Context to enter xr with
  103246. */
  103247. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  103248. /**
  103249. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  103250. */
  103251. customButtons?: Array<WebXREnterExitUIButton>;
  103252. }
  103253. /**
  103254. * UI to allow the user to enter/exit XR mode
  103255. */
  103256. export class WebXREnterExitUI implements IDisposable {
  103257. private scene;
  103258. private _overlay;
  103259. private _buttons;
  103260. private _activeButton;
  103261. /**
  103262. * Fired every time the active button is changed.
  103263. *
  103264. * When xr is entered via a button that launches xr that button will be the callback parameter
  103265. *
  103266. * When exiting xr the callback parameter will be null)
  103267. */
  103268. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  103269. /**
  103270. * Creates UI to allow the user to enter/exit XR mode
  103271. * @param scene the scene to add the ui to
  103272. * @param helper the xr experience helper to enter/exit xr with
  103273. * @param options options to configure the UI
  103274. * @returns the created ui
  103275. */
  103276. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  103277. private constructor();
  103278. private _updateButtons;
  103279. /**
  103280. * Disposes of the object
  103281. */
  103282. dispose(): void;
  103283. }
  103284. }
  103285. declare module BABYLON {
  103286. /**
  103287. * Represents an XR input
  103288. */
  103289. export class WebXRController {
  103290. /**
  103291. * 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
  103292. */
  103293. grip?: AbstractMesh;
  103294. /**
  103295. * Pointer which can be used to select objects or attach a visible laser to
  103296. */
  103297. pointer: AbstractMesh;
  103298. /**
  103299. * Creates the controller
  103300. * @see https://doc.babylonjs.com/how_to/webxr
  103301. * @param scene the scene which the controller should be associated to
  103302. */
  103303. constructor(scene: Scene);
  103304. /**
  103305. * Disposes of the object
  103306. */
  103307. dispose(): void;
  103308. }
  103309. /**
  103310. * XR input used to track XR inputs such as controllers/rays
  103311. */
  103312. export class WebXRInput implements IDisposable {
  103313. private helper;
  103314. /**
  103315. * XR controllers being tracked
  103316. */
  103317. controllers: Array<WebXRController>;
  103318. private _tmpMatrix;
  103319. private _frameObserver;
  103320. /**
  103321. * Initializes the WebXRInput
  103322. * @param helper experience helper which the input should be created for
  103323. */
  103324. constructor(helper: WebXRExperienceHelper);
  103325. /**
  103326. * Disposes of the object
  103327. */
  103328. dispose(): void;
  103329. }
  103330. }
  103331. declare module BABYLON {
  103332. /**
  103333. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  103334. */
  103335. export class WebXRManagedOutputCanvas implements IDisposable {
  103336. private _canvas;
  103337. /**
  103338. * xrpresent context of the canvas which can be used to display/mirror xr content
  103339. */
  103340. canvasContext: Nullable<WebGLRenderingContext>;
  103341. /**
  103342. * Initializes the canvas to be added/removed upon entering/exiting xr
  103343. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  103344. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  103345. */
  103346. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  103347. /**
  103348. * Disposes of the object
  103349. */
  103350. dispose(): void;
  103351. private _setManagedOutputCanvas;
  103352. private _addCanvas;
  103353. private _removeCanvas;
  103354. }
  103355. }
  103356. declare module BABYLON {
  103357. /**
  103358. * Contains an array of blocks representing the octree
  103359. */
  103360. export interface IOctreeContainer<T> {
  103361. /**
  103362. * Blocks within the octree
  103363. */
  103364. blocks: Array<OctreeBlock<T>>;
  103365. }
  103366. /**
  103367. * Class used to store a cell in an octree
  103368. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103369. */
  103370. export class OctreeBlock<T> {
  103371. /**
  103372. * Gets the content of the current block
  103373. */
  103374. entries: T[];
  103375. /**
  103376. * Gets the list of block children
  103377. */
  103378. blocks: Array<OctreeBlock<T>>;
  103379. private _depth;
  103380. private _maxDepth;
  103381. private _capacity;
  103382. private _minPoint;
  103383. private _maxPoint;
  103384. private _boundingVectors;
  103385. private _creationFunc;
  103386. /**
  103387. * Creates a new block
  103388. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  103389. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  103390. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  103391. * @param depth defines the current depth of this block in the octree
  103392. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  103393. * @param creationFunc defines a callback to call when an element is added to the block
  103394. */
  103395. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  103396. /**
  103397. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  103398. */
  103399. readonly capacity: number;
  103400. /**
  103401. * Gets the minimum vector (in world space) of the block's bounding box
  103402. */
  103403. readonly minPoint: Vector3;
  103404. /**
  103405. * Gets the maximum vector (in world space) of the block's bounding box
  103406. */
  103407. readonly maxPoint: Vector3;
  103408. /**
  103409. * Add a new element to this block
  103410. * @param entry defines the element to add
  103411. */
  103412. addEntry(entry: T): void;
  103413. /**
  103414. * Remove an element from this block
  103415. * @param entry defines the element to remove
  103416. */
  103417. removeEntry(entry: T): void;
  103418. /**
  103419. * Add an array of elements to this block
  103420. * @param entries defines the array of elements to add
  103421. */
  103422. addEntries(entries: T[]): void;
  103423. /**
  103424. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  103425. * @param frustumPlanes defines the frustum planes to test
  103426. * @param selection defines the array to store current content if selection is positive
  103427. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103428. */
  103429. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  103430. /**
  103431. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  103432. * @param sphereCenter defines the bounding sphere center
  103433. * @param sphereRadius defines the bounding sphere radius
  103434. * @param selection defines the array to store current content if selection is positive
  103435. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103436. */
  103437. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  103438. /**
  103439. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  103440. * @param ray defines the ray to test with
  103441. * @param selection defines the array to store current content if selection is positive
  103442. */
  103443. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  103444. /**
  103445. * Subdivide the content into child blocks (this block will then be empty)
  103446. */
  103447. createInnerBlocks(): void;
  103448. /**
  103449. * @hidden
  103450. */
  103451. 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;
  103452. }
  103453. }
  103454. declare module BABYLON {
  103455. /**
  103456. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  103457. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103458. */
  103459. export class Octree<T> {
  103460. /** 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.) */
  103461. maxDepth: number;
  103462. /**
  103463. * Blocks within the octree containing objects
  103464. */
  103465. blocks: Array<OctreeBlock<T>>;
  103466. /**
  103467. * Content stored in the octree
  103468. */
  103469. dynamicContent: T[];
  103470. private _maxBlockCapacity;
  103471. private _selectionContent;
  103472. private _creationFunc;
  103473. /**
  103474. * Creates a octree
  103475. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103476. * @param creationFunc function to be used to instatiate the octree
  103477. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  103478. * @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.)
  103479. */
  103480. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  103481. /** 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.) */
  103482. maxDepth?: number);
  103483. /**
  103484. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  103485. * @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);
  103486. * @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);
  103487. * @param entries meshes to be added to the octree blocks
  103488. */
  103489. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  103490. /**
  103491. * Adds a mesh to the octree
  103492. * @param entry Mesh to add to the octree
  103493. */
  103494. addMesh(entry: T): void;
  103495. /**
  103496. * Remove an element from the octree
  103497. * @param entry defines the element to remove
  103498. */
  103499. removeMesh(entry: T): void;
  103500. /**
  103501. * Selects an array of meshes within the frustum
  103502. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  103503. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  103504. * @returns array of meshes within the frustum
  103505. */
  103506. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  103507. /**
  103508. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  103509. * @param sphereCenter defines the bounding sphere center
  103510. * @param sphereRadius defines the bounding sphere radius
  103511. * @param allowDuplicate defines if the selection array can contains duplicated entries
  103512. * @returns an array of objects that intersect the sphere
  103513. */
  103514. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  103515. /**
  103516. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  103517. * @param ray defines the ray to test with
  103518. * @returns array of intersected objects
  103519. */
  103520. intersectsRay(ray: Ray): SmartArray<T>;
  103521. /**
  103522. * Adds a mesh into the octree block if it intersects the block
  103523. */
  103524. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  103525. /**
  103526. * Adds a submesh into the octree block if it intersects the block
  103527. */
  103528. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  103529. }
  103530. }
  103531. declare module BABYLON {
  103532. interface Scene {
  103533. /**
  103534. * @hidden
  103535. * Backing Filed
  103536. */
  103537. _selectionOctree: Octree<AbstractMesh>;
  103538. /**
  103539. * Gets the octree used to boost mesh selection (picking)
  103540. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103541. */
  103542. selectionOctree: Octree<AbstractMesh>;
  103543. /**
  103544. * Creates or updates the octree used to boost selection (picking)
  103545. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103546. * @param maxCapacity defines the maximum capacity per leaf
  103547. * @param maxDepth defines the maximum depth of the octree
  103548. * @returns an octree of AbstractMesh
  103549. */
  103550. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  103551. }
  103552. interface AbstractMesh {
  103553. /**
  103554. * @hidden
  103555. * Backing Field
  103556. */
  103557. _submeshesOctree: Octree<SubMesh>;
  103558. /**
  103559. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  103560. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  103561. * @param maxCapacity defines the maximum size of each block (64 by default)
  103562. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  103563. * @returns the new octree
  103564. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  103565. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  103566. */
  103567. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  103568. }
  103569. /**
  103570. * Defines the octree scene component responsible to manage any octrees
  103571. * in a given scene.
  103572. */
  103573. export class OctreeSceneComponent {
  103574. /**
  103575. * The component name help to identify the component in the list of scene components.
  103576. */
  103577. readonly name: string;
  103578. /**
  103579. * The scene the component belongs to.
  103580. */
  103581. scene: Scene;
  103582. /**
  103583. * Indicates if the meshes have been checked to make sure they are isEnabled()
  103584. */
  103585. readonly checksIsEnabled: boolean;
  103586. /**
  103587. * Creates a new instance of the component for the given scene
  103588. * @param scene Defines the scene to register the component in
  103589. */
  103590. constructor(scene: Scene);
  103591. /**
  103592. * Registers the component in a given scene
  103593. */
  103594. register(): void;
  103595. /**
  103596. * Return the list of active meshes
  103597. * @returns the list of active meshes
  103598. */
  103599. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  103600. /**
  103601. * Return the list of active sub meshes
  103602. * @param mesh The mesh to get the candidates sub meshes from
  103603. * @returns the list of active sub meshes
  103604. */
  103605. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  103606. private _tempRay;
  103607. /**
  103608. * Return the list of sub meshes intersecting with a given local ray
  103609. * @param mesh defines the mesh to find the submesh for
  103610. * @param localRay defines the ray in local space
  103611. * @returns the list of intersecting sub meshes
  103612. */
  103613. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  103614. /**
  103615. * Return the list of sub meshes colliding with a collider
  103616. * @param mesh defines the mesh to find the submesh for
  103617. * @param collider defines the collider to evaluate the collision against
  103618. * @returns the list of colliding sub meshes
  103619. */
  103620. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  103621. /**
  103622. * Rebuilds the elements related to this component in case of
  103623. * context lost for instance.
  103624. */
  103625. rebuild(): void;
  103626. /**
  103627. * Disposes the component and the associated ressources.
  103628. */
  103629. dispose(): void;
  103630. }
  103631. }
  103632. declare module BABYLON {
  103633. /**
  103634. * Renders a layer on top of an existing scene
  103635. */
  103636. export class UtilityLayerRenderer implements IDisposable {
  103637. /** the original scene that will be rendered on top of */
  103638. originalScene: Scene;
  103639. private _pointerCaptures;
  103640. private _lastPointerEvents;
  103641. private static _DefaultUtilityLayer;
  103642. private static _DefaultKeepDepthUtilityLayer;
  103643. private _sharedGizmoLight;
  103644. private _renderCamera;
  103645. /**
  103646. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  103647. * @returns the camera that is used when rendering the utility layer
  103648. */
  103649. getRenderCamera(): Nullable<Camera>;
  103650. /**
  103651. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  103652. * @param cam the camera that should be used when rendering the utility layer
  103653. */
  103654. setRenderCamera(cam: Nullable<Camera>): void;
  103655. /**
  103656. * @hidden
  103657. * Light which used by gizmos to get light shading
  103658. */
  103659. _getSharedGizmoLight(): HemisphericLight;
  103660. /**
  103661. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  103662. */
  103663. pickUtilitySceneFirst: boolean;
  103664. /**
  103665. * 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)
  103666. */
  103667. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  103668. /**
  103669. * 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)
  103670. */
  103671. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  103672. /**
  103673. * The scene that is rendered on top of the original scene
  103674. */
  103675. utilityLayerScene: Scene;
  103676. /**
  103677. * If the utility layer should automatically be rendered on top of existing scene
  103678. */
  103679. shouldRender: boolean;
  103680. /**
  103681. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  103682. */
  103683. onlyCheckPointerDownEvents: boolean;
  103684. /**
  103685. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  103686. */
  103687. processAllEvents: boolean;
  103688. /**
  103689. * Observable raised when the pointer move from the utility layer scene to the main scene
  103690. */
  103691. onPointerOutObservable: Observable<number>;
  103692. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  103693. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  103694. private _afterRenderObserver;
  103695. private _sceneDisposeObserver;
  103696. private _originalPointerObserver;
  103697. /**
  103698. * Instantiates a UtilityLayerRenderer
  103699. * @param originalScene the original scene that will be rendered on top of
  103700. * @param handleEvents boolean indicating if the utility layer should handle events
  103701. */
  103702. constructor(
  103703. /** the original scene that will be rendered on top of */
  103704. originalScene: Scene, handleEvents?: boolean);
  103705. private _notifyObservers;
  103706. /**
  103707. * Renders the utility layers scene on top of the original scene
  103708. */
  103709. render(): void;
  103710. /**
  103711. * Disposes of the renderer
  103712. */
  103713. dispose(): void;
  103714. private _updateCamera;
  103715. }
  103716. }
  103717. declare module BABYLON {
  103718. /**
  103719. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  103720. */
  103721. export class Gizmo implements IDisposable {
  103722. /** The utility layer the gizmo will be added to */
  103723. gizmoLayer: UtilityLayerRenderer;
  103724. /**
  103725. * The root mesh of the gizmo
  103726. */
  103727. _rootMesh: Mesh;
  103728. private _attachedMesh;
  103729. /**
  103730. * Ratio for the scale of the gizmo (Default: 1)
  103731. */
  103732. scaleRatio: number;
  103733. /**
  103734. * If a custom mesh has been set (Default: false)
  103735. */
  103736. protected _customMeshSet: boolean;
  103737. /**
  103738. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  103739. * * When set, interactions will be enabled
  103740. */
  103741. attachedMesh: Nullable<AbstractMesh>;
  103742. /**
  103743. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  103744. * @param mesh The mesh to replace the default mesh of the gizmo
  103745. */
  103746. setCustomMesh(mesh: Mesh): void;
  103747. /**
  103748. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  103749. */
  103750. updateGizmoRotationToMatchAttachedMesh: boolean;
  103751. /**
  103752. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  103753. */
  103754. updateGizmoPositionToMatchAttachedMesh: boolean;
  103755. /**
  103756. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  103757. */
  103758. protected _updateScale: boolean;
  103759. protected _interactionsEnabled: boolean;
  103760. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  103761. private _beforeRenderObserver;
  103762. private _tempVector;
  103763. /**
  103764. * Creates a gizmo
  103765. * @param gizmoLayer The utility layer the gizmo will be added to
  103766. */
  103767. constructor(
  103768. /** The utility layer the gizmo will be added to */
  103769. gizmoLayer?: UtilityLayerRenderer);
  103770. /**
  103771. * Updates the gizmo to match the attached mesh's position/rotation
  103772. */
  103773. protected _update(): void;
  103774. /**
  103775. * Disposes of the gizmo
  103776. */
  103777. dispose(): void;
  103778. }
  103779. }
  103780. declare module BABYLON {
  103781. /**
  103782. * Single plane drag gizmo
  103783. */
  103784. export class PlaneDragGizmo extends Gizmo {
  103785. /**
  103786. * Drag behavior responsible for the gizmos dragging interactions
  103787. */
  103788. dragBehavior: PointerDragBehavior;
  103789. private _pointerObserver;
  103790. /**
  103791. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  103792. */
  103793. snapDistance: number;
  103794. /**
  103795. * Event that fires each time the gizmo snaps to a new location.
  103796. * * snapDistance is the the change in distance
  103797. */
  103798. onSnapObservable: Observable<{
  103799. snapDistance: number;
  103800. }>;
  103801. private _plane;
  103802. private _coloredMaterial;
  103803. private _hoverMaterial;
  103804. private _isEnabled;
  103805. private _parent;
  103806. /** @hidden */
  103807. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  103808. /** @hidden */
  103809. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  103810. /**
  103811. * Creates a PlaneDragGizmo
  103812. * @param gizmoLayer The utility layer the gizmo will be added to
  103813. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  103814. * @param color The color of the gizmo
  103815. */
  103816. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  103817. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  103818. /**
  103819. * If the gizmo is enabled
  103820. */
  103821. isEnabled: boolean;
  103822. /**
  103823. * Disposes of the gizmo
  103824. */
  103825. dispose(): void;
  103826. }
  103827. }
  103828. declare module BABYLON {
  103829. /**
  103830. * Gizmo that enables dragging a mesh along 3 axis
  103831. */
  103832. export class PositionGizmo extends Gizmo {
  103833. /**
  103834. * Internal gizmo used for interactions on the x axis
  103835. */
  103836. xGizmo: AxisDragGizmo;
  103837. /**
  103838. * Internal gizmo used for interactions on the y axis
  103839. */
  103840. yGizmo: AxisDragGizmo;
  103841. /**
  103842. * Internal gizmo used for interactions on the z axis
  103843. */
  103844. zGizmo: AxisDragGizmo;
  103845. /**
  103846. * Internal gizmo used for interactions on the yz plane
  103847. */
  103848. xPlaneGizmo: PlaneDragGizmo;
  103849. /**
  103850. * Internal gizmo used for interactions on the xz plane
  103851. */
  103852. yPlaneGizmo: PlaneDragGizmo;
  103853. /**
  103854. * Internal gizmo used for interactions on the xy plane
  103855. */
  103856. zPlaneGizmo: PlaneDragGizmo;
  103857. /**
  103858. * private variables
  103859. */
  103860. private _meshAttached;
  103861. private _updateGizmoRotationToMatchAttachedMesh;
  103862. private _snapDistance;
  103863. private _scaleRatio;
  103864. /** Fires an event when any of it's sub gizmos are dragged */
  103865. onDragStartObservable: Observable<unknown>;
  103866. /** Fires an event when any of it's sub gizmos are released from dragging */
  103867. onDragEndObservable: Observable<unknown>;
  103868. /**
  103869. * If set to true, planar drag is enabled
  103870. */
  103871. private _planarGizmoEnabled;
  103872. attachedMesh: Nullable<AbstractMesh>;
  103873. /**
  103874. * Creates a PositionGizmo
  103875. * @param gizmoLayer The utility layer the gizmo will be added to
  103876. */
  103877. constructor(gizmoLayer?: UtilityLayerRenderer);
  103878. /**
  103879. * If the planar drag gizmo is enabled
  103880. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  103881. */
  103882. planarGizmoEnabled: boolean;
  103883. updateGizmoRotationToMatchAttachedMesh: boolean;
  103884. /**
  103885. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  103886. */
  103887. snapDistance: number;
  103888. /**
  103889. * Ratio for the scale of the gizmo (Default: 1)
  103890. */
  103891. scaleRatio: number;
  103892. /**
  103893. * Disposes of the gizmo
  103894. */
  103895. dispose(): void;
  103896. /**
  103897. * CustomMeshes are not supported by this gizmo
  103898. * @param mesh The mesh to replace the default mesh of the gizmo
  103899. */
  103900. setCustomMesh(mesh: Mesh): void;
  103901. }
  103902. }
  103903. declare module BABYLON {
  103904. /**
  103905. * Single axis drag gizmo
  103906. */
  103907. export class AxisDragGizmo extends Gizmo {
  103908. /**
  103909. * Drag behavior responsible for the gizmos dragging interactions
  103910. */
  103911. dragBehavior: PointerDragBehavior;
  103912. private _pointerObserver;
  103913. /**
  103914. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  103915. */
  103916. snapDistance: number;
  103917. /**
  103918. * Event that fires each time the gizmo snaps to a new location.
  103919. * * snapDistance is the the change in distance
  103920. */
  103921. onSnapObservable: Observable<{
  103922. snapDistance: number;
  103923. }>;
  103924. private _isEnabled;
  103925. private _parent;
  103926. private _arrow;
  103927. private _coloredMaterial;
  103928. private _hoverMaterial;
  103929. /** @hidden */
  103930. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  103931. /** @hidden */
  103932. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  103933. /**
  103934. * Creates an AxisDragGizmo
  103935. * @param gizmoLayer The utility layer the gizmo will be added to
  103936. * @param dragAxis The axis which the gizmo will be able to drag on
  103937. * @param color The color of the gizmo
  103938. */
  103939. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  103940. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  103941. /**
  103942. * If the gizmo is enabled
  103943. */
  103944. isEnabled: boolean;
  103945. /**
  103946. * Disposes of the gizmo
  103947. */
  103948. dispose(): void;
  103949. }
  103950. }
  103951. declare module BABYLON.Debug {
  103952. /**
  103953. * The Axes viewer will show 3 axes in a specific point in space
  103954. */
  103955. export class AxesViewer {
  103956. private _xAxis;
  103957. private _yAxis;
  103958. private _zAxis;
  103959. private _scaleLinesFactor;
  103960. private _instanced;
  103961. /**
  103962. * Gets the hosting scene
  103963. */
  103964. scene: Scene;
  103965. /**
  103966. * Gets or sets a number used to scale line length
  103967. */
  103968. scaleLines: number;
  103969. /** Gets the node hierarchy used to render x-axis */
  103970. readonly xAxis: TransformNode;
  103971. /** Gets the node hierarchy used to render y-axis */
  103972. readonly yAxis: TransformNode;
  103973. /** Gets the node hierarchy used to render z-axis */
  103974. readonly zAxis: TransformNode;
  103975. /**
  103976. * Creates a new AxesViewer
  103977. * @param scene defines the hosting scene
  103978. * @param scaleLines defines a number used to scale line length (1 by default)
  103979. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  103980. * @param xAxis defines the node hierarchy used to render the x-axis
  103981. * @param yAxis defines the node hierarchy used to render the y-axis
  103982. * @param zAxis defines the node hierarchy used to render the z-axis
  103983. */
  103984. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  103985. /**
  103986. * Force the viewer to update
  103987. * @param position defines the position of the viewer
  103988. * @param xaxis defines the x axis of the viewer
  103989. * @param yaxis defines the y axis of the viewer
  103990. * @param zaxis defines the z axis of the viewer
  103991. */
  103992. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  103993. /**
  103994. * Creates an instance of this axes viewer.
  103995. * @returns a new axes viewer with instanced meshes
  103996. */
  103997. createInstance(): AxesViewer;
  103998. /** Releases resources */
  103999. dispose(): void;
  104000. private static _SetRenderingGroupId;
  104001. }
  104002. }
  104003. declare module BABYLON.Debug {
  104004. /**
  104005. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  104006. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  104007. */
  104008. export class BoneAxesViewer extends AxesViewer {
  104009. /**
  104010. * Gets or sets the target mesh where to display the axes viewer
  104011. */
  104012. mesh: Nullable<Mesh>;
  104013. /**
  104014. * Gets or sets the target bone where to display the axes viewer
  104015. */
  104016. bone: Nullable<Bone>;
  104017. /** Gets current position */
  104018. pos: Vector3;
  104019. /** Gets direction of X axis */
  104020. xaxis: Vector3;
  104021. /** Gets direction of Y axis */
  104022. yaxis: Vector3;
  104023. /** Gets direction of Z axis */
  104024. zaxis: Vector3;
  104025. /**
  104026. * Creates a new BoneAxesViewer
  104027. * @param scene defines the hosting scene
  104028. * @param bone defines the target bone
  104029. * @param mesh defines the target mesh
  104030. * @param scaleLines defines a scaling factor for line length (1 by default)
  104031. */
  104032. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  104033. /**
  104034. * Force the viewer to update
  104035. */
  104036. update(): void;
  104037. /** Releases resources */
  104038. dispose(): void;
  104039. }
  104040. }
  104041. declare module BABYLON {
  104042. /**
  104043. * Interface used to define scene explorer extensibility option
  104044. */
  104045. export interface IExplorerExtensibilityOption {
  104046. /**
  104047. * Define the option label
  104048. */
  104049. label: string;
  104050. /**
  104051. * Defines the action to execute on click
  104052. */
  104053. action: (entity: any) => void;
  104054. }
  104055. /**
  104056. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  104057. */
  104058. export interface IExplorerExtensibilityGroup {
  104059. /**
  104060. * Defines a predicate to test if a given type mut be extended
  104061. */
  104062. predicate: (entity: any) => boolean;
  104063. /**
  104064. * Gets the list of options added to a type
  104065. */
  104066. entries: IExplorerExtensibilityOption[];
  104067. }
  104068. /**
  104069. * Interface used to define the options to use to create the Inspector
  104070. */
  104071. export interface IInspectorOptions {
  104072. /**
  104073. * Display in overlay mode (default: false)
  104074. */
  104075. overlay?: boolean;
  104076. /**
  104077. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  104078. */
  104079. globalRoot?: HTMLElement;
  104080. /**
  104081. * Display the Scene explorer
  104082. */
  104083. showExplorer?: boolean;
  104084. /**
  104085. * Display the property inspector
  104086. */
  104087. showInspector?: boolean;
  104088. /**
  104089. * Display in embed mode (both panes on the right)
  104090. */
  104091. embedMode?: boolean;
  104092. /**
  104093. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  104094. */
  104095. handleResize?: boolean;
  104096. /**
  104097. * Allow the panes to popup (default: true)
  104098. */
  104099. enablePopup?: boolean;
  104100. /**
  104101. * Allow the panes to be closed by users (default: true)
  104102. */
  104103. enableClose?: boolean;
  104104. /**
  104105. * Optional list of extensibility entries
  104106. */
  104107. explorerExtensibility?: IExplorerExtensibilityGroup[];
  104108. /**
  104109. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  104110. */
  104111. inspectorURL?: string;
  104112. }
  104113. interface Scene {
  104114. /**
  104115. * @hidden
  104116. * Backing field
  104117. */
  104118. _debugLayer: DebugLayer;
  104119. /**
  104120. * Gets the debug layer (aka Inspector) associated with the scene
  104121. * @see http://doc.babylonjs.com/features/playground_debuglayer
  104122. */
  104123. debugLayer: DebugLayer;
  104124. }
  104125. /**
  104126. * The debug layer (aka Inspector) is the go to tool in order to better understand
  104127. * what is happening in your scene
  104128. * @see http://doc.babylonjs.com/features/playground_debuglayer
  104129. */
  104130. export class DebugLayer {
  104131. /**
  104132. * Define the url to get the inspector script from.
  104133. * By default it uses the babylonjs CDN.
  104134. * @ignoreNaming
  104135. */
  104136. static InspectorURL: string;
  104137. private _scene;
  104138. private BJSINSPECTOR;
  104139. private _onPropertyChangedObservable?;
  104140. /**
  104141. * Observable triggered when a property is changed through the inspector.
  104142. */
  104143. readonly onPropertyChangedObservable: any;
  104144. /**
  104145. * Instantiates a new debug layer.
  104146. * The debug layer (aka Inspector) is the go to tool in order to better understand
  104147. * what is happening in your scene
  104148. * @see http://doc.babylonjs.com/features/playground_debuglayer
  104149. * @param scene Defines the scene to inspect
  104150. */
  104151. constructor(scene: Scene);
  104152. /** Creates the inspector window. */
  104153. private _createInspector;
  104154. /**
  104155. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  104156. * @param entity defines the entity to select
  104157. * @param lineContainerTitle defines the specific block to highlight
  104158. */
  104159. select(entity: any, lineContainerTitle?: string): void;
  104160. /** Get the inspector from bundle or global */
  104161. private _getGlobalInspector;
  104162. /**
  104163. * Get if the inspector is visible or not.
  104164. * @returns true if visible otherwise, false
  104165. */
  104166. isVisible(): boolean;
  104167. /**
  104168. * Hide the inspector and close its window.
  104169. */
  104170. hide(): void;
  104171. /**
  104172. * Launch the debugLayer.
  104173. * @param config Define the configuration of the inspector
  104174. * @return a promise fulfilled when the debug layer is visible
  104175. */
  104176. show(config?: IInspectorOptions): Promise<DebugLayer>;
  104177. }
  104178. }
  104179. declare module BABYLON {
  104180. /**
  104181. * Class containing static functions to help procedurally build meshes
  104182. */
  104183. export class BoxBuilder {
  104184. /**
  104185. * Creates a box mesh
  104186. * * The parameter `size` sets the size (float) of each box side (default 1)
  104187. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  104188. * * 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)
  104189. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  104190. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104191. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104192. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104193. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  104194. * @param name defines the name of the mesh
  104195. * @param options defines the options used to create the mesh
  104196. * @param scene defines the hosting scene
  104197. * @returns the box mesh
  104198. */
  104199. static CreateBox(name: string, options: {
  104200. size?: number;
  104201. width?: number;
  104202. height?: number;
  104203. depth?: number;
  104204. faceUV?: Vector4[];
  104205. faceColors?: Color4[];
  104206. sideOrientation?: number;
  104207. frontUVs?: Vector4;
  104208. backUVs?: Vector4;
  104209. wrap?: boolean;
  104210. topBaseAt?: number;
  104211. bottomBaseAt?: number;
  104212. updatable?: boolean;
  104213. }, scene?: Nullable<Scene>): Mesh;
  104214. }
  104215. }
  104216. declare module BABYLON {
  104217. /**
  104218. * Class containing static functions to help procedurally build meshes
  104219. */
  104220. export class SphereBuilder {
  104221. /**
  104222. * Creates a sphere mesh
  104223. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  104224. * * 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`)
  104225. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  104226. * * 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
  104227. * * 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)
  104228. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104229. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104230. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104231. * @param name defines the name of the mesh
  104232. * @param options defines the options used to create the mesh
  104233. * @param scene defines the hosting scene
  104234. * @returns the sphere mesh
  104235. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  104236. */
  104237. static CreateSphere(name: string, options: {
  104238. segments?: number;
  104239. diameter?: number;
  104240. diameterX?: number;
  104241. diameterY?: number;
  104242. diameterZ?: number;
  104243. arc?: number;
  104244. slice?: number;
  104245. sideOrientation?: number;
  104246. frontUVs?: Vector4;
  104247. backUVs?: Vector4;
  104248. updatable?: boolean;
  104249. }, scene: any): Mesh;
  104250. }
  104251. }
  104252. declare module BABYLON.Debug {
  104253. /**
  104254. * Used to show the physics impostor around the specific mesh
  104255. */
  104256. export class PhysicsViewer {
  104257. /** @hidden */
  104258. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  104259. /** @hidden */
  104260. protected _meshes: Array<Nullable<AbstractMesh>>;
  104261. /** @hidden */
  104262. protected _scene: Nullable<Scene>;
  104263. /** @hidden */
  104264. protected _numMeshes: number;
  104265. /** @hidden */
  104266. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  104267. private _renderFunction;
  104268. private _utilityLayer;
  104269. private _debugBoxMesh;
  104270. private _debugSphereMesh;
  104271. private _debugCylinderMesh;
  104272. private _debugMaterial;
  104273. private _debugMeshMeshes;
  104274. /**
  104275. * Creates a new PhysicsViewer
  104276. * @param scene defines the hosting scene
  104277. */
  104278. constructor(scene: Scene);
  104279. /** @hidden */
  104280. protected _updateDebugMeshes(): void;
  104281. /**
  104282. * Renders a specified physic impostor
  104283. * @param impostor defines the impostor to render
  104284. * @param targetMesh defines the mesh represented by the impostor
  104285. * @returns the new debug mesh used to render the impostor
  104286. */
  104287. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  104288. /**
  104289. * Hides a specified physic impostor
  104290. * @param impostor defines the impostor to hide
  104291. */
  104292. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  104293. private _getDebugMaterial;
  104294. private _getDebugBoxMesh;
  104295. private _getDebugSphereMesh;
  104296. private _getDebugCylinderMesh;
  104297. private _getDebugMeshMesh;
  104298. private _getDebugMesh;
  104299. /** Releases all resources */
  104300. dispose(): void;
  104301. }
  104302. }
  104303. declare module BABYLON {
  104304. /**
  104305. * Class containing static functions to help procedurally build meshes
  104306. */
  104307. export class LinesBuilder {
  104308. /**
  104309. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  104310. * * 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
  104311. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  104312. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  104313. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  104314. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  104315. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  104316. * * 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
  104317. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  104318. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104319. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  104320. * @param name defines the name of the new line system
  104321. * @param options defines the options used to create the line system
  104322. * @param scene defines the hosting scene
  104323. * @returns a new line system mesh
  104324. */
  104325. static CreateLineSystem(name: string, options: {
  104326. lines: Vector3[][];
  104327. updatable?: boolean;
  104328. instance?: Nullable<LinesMesh>;
  104329. colors?: Nullable<Color4[][]>;
  104330. useVertexAlpha?: boolean;
  104331. }, scene: Nullable<Scene>): LinesMesh;
  104332. /**
  104333. * Creates a line mesh
  104334. * 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
  104335. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  104336. * * The parameter `points` is an array successive Vector3
  104337. * * 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
  104338. * * The optional parameter `colors` is an array of successive Color4, one per line point
  104339. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  104340. * * When updating an instance, remember that only point positions can change, not the number of points
  104341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104342. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  104343. * @param name defines the name of the new line system
  104344. * @param options defines the options used to create the line system
  104345. * @param scene defines the hosting scene
  104346. * @returns a new line mesh
  104347. */
  104348. static CreateLines(name: string, options: {
  104349. points: Vector3[];
  104350. updatable?: boolean;
  104351. instance?: Nullable<LinesMesh>;
  104352. colors?: Color4[];
  104353. useVertexAlpha?: boolean;
  104354. }, scene?: Nullable<Scene>): LinesMesh;
  104355. /**
  104356. * Creates a dashed line mesh
  104357. * * 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
  104358. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  104359. * * The parameter `points` is an array successive Vector3
  104360. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  104361. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  104362. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  104363. * * 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
  104364. * * When updating an instance, remember that only point positions can change, not the number of points
  104365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104366. * @param name defines the name of the mesh
  104367. * @param options defines the options used to create the mesh
  104368. * @param scene defines the hosting scene
  104369. * @returns the dashed line mesh
  104370. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  104371. */
  104372. static CreateDashedLines(name: string, options: {
  104373. points: Vector3[];
  104374. dashSize?: number;
  104375. gapSize?: number;
  104376. dashNb?: number;
  104377. updatable?: boolean;
  104378. instance?: LinesMesh;
  104379. }, scene?: Nullable<Scene>): LinesMesh;
  104380. }
  104381. }
  104382. declare module BABYLON {
  104383. /**
  104384. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  104385. * in order to better appreciate the issue one might have.
  104386. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  104387. */
  104388. export class RayHelper {
  104389. /**
  104390. * Defines the ray we are currently tryin to visualize.
  104391. */
  104392. ray: Nullable<Ray>;
  104393. private _renderPoints;
  104394. private _renderLine;
  104395. private _renderFunction;
  104396. private _scene;
  104397. private _updateToMeshFunction;
  104398. private _attachedToMesh;
  104399. private _meshSpaceDirection;
  104400. private _meshSpaceOrigin;
  104401. /**
  104402. * Helper function to create a colored helper in a scene in one line.
  104403. * @param ray Defines the ray we are currently tryin to visualize
  104404. * @param scene Defines the scene the ray is used in
  104405. * @param color Defines the color we want to see the ray in
  104406. * @returns The newly created ray helper.
  104407. */
  104408. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  104409. /**
  104410. * Instantiate a new ray helper.
  104411. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  104412. * in order to better appreciate the issue one might have.
  104413. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  104414. * @param ray Defines the ray we are currently tryin to visualize
  104415. */
  104416. constructor(ray: Ray);
  104417. /**
  104418. * Shows the ray we are willing to debug.
  104419. * @param scene Defines the scene the ray needs to be rendered in
  104420. * @param color Defines the color the ray needs to be rendered in
  104421. */
  104422. show(scene: Scene, color?: Color3): void;
  104423. /**
  104424. * Hides the ray we are debugging.
  104425. */
  104426. hide(): void;
  104427. private _render;
  104428. /**
  104429. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  104430. * @param mesh Defines the mesh we want the helper attached to
  104431. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  104432. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  104433. * @param length Defines the length of the ray
  104434. */
  104435. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  104436. /**
  104437. * Detach the ray helper from the mesh it has previously been attached to.
  104438. */
  104439. detachFromMesh(): void;
  104440. private _updateToMesh;
  104441. /**
  104442. * Dispose the helper and release its associated resources.
  104443. */
  104444. dispose(): void;
  104445. }
  104446. }
  104447. declare module BABYLON.Debug {
  104448. /**
  104449. * Class used to render a debug view of a given skeleton
  104450. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  104451. */
  104452. export class SkeletonViewer {
  104453. /** defines the skeleton to render */
  104454. skeleton: Skeleton;
  104455. /** defines the mesh attached to the skeleton */
  104456. mesh: AbstractMesh;
  104457. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  104458. autoUpdateBonesMatrices: boolean;
  104459. /** defines the rendering group id to use with the viewer */
  104460. renderingGroupId: number;
  104461. /** Gets or sets the color used to render the skeleton */
  104462. color: Color3;
  104463. private _scene;
  104464. private _debugLines;
  104465. private _debugMesh;
  104466. private _isEnabled;
  104467. private _renderFunction;
  104468. private _utilityLayer;
  104469. /**
  104470. * Returns the mesh used to render the bones
  104471. */
  104472. readonly debugMesh: Nullable<LinesMesh>;
  104473. /**
  104474. * Creates a new SkeletonViewer
  104475. * @param skeleton defines the skeleton to render
  104476. * @param mesh defines the mesh attached to the skeleton
  104477. * @param scene defines the hosting scene
  104478. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  104479. * @param renderingGroupId defines the rendering group id to use with the viewer
  104480. */
  104481. constructor(
  104482. /** defines the skeleton to render */
  104483. skeleton: Skeleton,
  104484. /** defines the mesh attached to the skeleton */
  104485. mesh: AbstractMesh, scene: Scene,
  104486. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  104487. autoUpdateBonesMatrices?: boolean,
  104488. /** defines the rendering group id to use with the viewer */
  104489. renderingGroupId?: number);
  104490. /** Gets or sets a boolean indicating if the viewer is enabled */
  104491. isEnabled: boolean;
  104492. private _getBonePosition;
  104493. private _getLinesForBonesWithLength;
  104494. private _getLinesForBonesNoLength;
  104495. /** Update the viewer to sync with current skeleton state */
  104496. update(): void;
  104497. /** Release associated resources */
  104498. dispose(): void;
  104499. }
  104500. }
  104501. declare module BABYLON {
  104502. /**
  104503. * Options to create the null engine
  104504. */
  104505. export class NullEngineOptions {
  104506. /**
  104507. * Render width (Default: 512)
  104508. */
  104509. renderWidth: number;
  104510. /**
  104511. * Render height (Default: 256)
  104512. */
  104513. renderHeight: number;
  104514. /**
  104515. * Texture size (Default: 512)
  104516. */
  104517. textureSize: number;
  104518. /**
  104519. * If delta time between frames should be constant
  104520. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104521. */
  104522. deterministicLockstep: boolean;
  104523. /**
  104524. * Maximum about of steps between frames (Default: 4)
  104525. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104526. */
  104527. lockstepMaxSteps: number;
  104528. }
  104529. /**
  104530. * The null engine class provides support for headless version of babylon.js.
  104531. * This can be used in server side scenario or for testing purposes
  104532. */
  104533. export class NullEngine extends Engine {
  104534. private _options;
  104535. /**
  104536. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104537. */
  104538. isDeterministicLockStep(): boolean;
  104539. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  104540. getLockstepMaxSteps(): number;
  104541. /**
  104542. * Sets hardware scaling, used to save performance if needed
  104543. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  104544. */
  104545. getHardwareScalingLevel(): number;
  104546. constructor(options?: NullEngineOptions);
  104547. createVertexBuffer(vertices: FloatArray): DataBuffer;
  104548. createIndexBuffer(indices: IndicesArray): DataBuffer;
  104549. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  104550. getRenderWidth(useScreen?: boolean): number;
  104551. getRenderHeight(useScreen?: boolean): number;
  104552. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  104553. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  104554. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  104555. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  104556. bindSamplers(effect: Effect): void;
  104557. enableEffect(effect: Effect): void;
  104558. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  104559. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  104560. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  104561. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  104562. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  104563. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  104564. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  104565. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  104566. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  104567. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  104568. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  104569. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  104570. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  104571. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  104572. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  104573. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  104574. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  104575. setFloat(uniform: WebGLUniformLocation, value: number): void;
  104576. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  104577. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  104578. setBool(uniform: WebGLUniformLocation, bool: number): void;
  104579. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  104580. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  104581. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  104582. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  104583. bindBuffers(vertexBuffers: {
  104584. [key: string]: VertexBuffer;
  104585. }, indexBuffer: DataBuffer, effect: Effect): void;
  104586. wipeCaches(bruteForce?: boolean): void;
  104587. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  104588. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  104589. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104590. /** @hidden */
  104591. _createTexture(): WebGLTexture;
  104592. /** @hidden */
  104593. _releaseTexture(texture: InternalTexture): void;
  104594. 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;
  104595. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  104596. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  104597. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  104598. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  104599. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  104600. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  104601. areAllEffectsReady(): boolean;
  104602. /**
  104603. * @hidden
  104604. * Get the current error code of the webGL context
  104605. * @returns the error code
  104606. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  104607. */
  104608. getError(): number;
  104609. /** @hidden */
  104610. _getUnpackAlignement(): number;
  104611. /** @hidden */
  104612. _unpackFlipY(value: boolean): void;
  104613. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  104614. /**
  104615. * Updates a dynamic vertex buffer.
  104616. * @param vertexBuffer the vertex buffer to update
  104617. * @param data the data used to update the vertex buffer
  104618. * @param byteOffset the byte offset of the data (optional)
  104619. * @param byteLength the byte length of the data (optional)
  104620. */
  104621. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  104622. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  104623. /** @hidden */
  104624. _bindTexture(channel: number, texture: InternalTexture): void;
  104625. /** @hidden */
  104626. _releaseBuffer(buffer: DataBuffer): boolean;
  104627. releaseEffects(): void;
  104628. displayLoadingUI(): void;
  104629. hideLoadingUI(): void;
  104630. /** @hidden */
  104631. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104632. /** @hidden */
  104633. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104634. /** @hidden */
  104635. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  104636. /** @hidden */
  104637. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  104638. }
  104639. }
  104640. declare module BABYLON {
  104641. /** @hidden */
  104642. export class _OcclusionDataStorage {
  104643. /** @hidden */
  104644. occlusionInternalRetryCounter: number;
  104645. /** @hidden */
  104646. isOcclusionQueryInProgress: boolean;
  104647. /** @hidden */
  104648. isOccluded: boolean;
  104649. /** @hidden */
  104650. occlusionRetryCount: number;
  104651. /** @hidden */
  104652. occlusionType: number;
  104653. /** @hidden */
  104654. occlusionQueryAlgorithmType: number;
  104655. }
  104656. interface Engine {
  104657. /**
  104658. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  104659. * @return the new query
  104660. */
  104661. createQuery(): WebGLQuery;
  104662. /**
  104663. * Delete and release a webGL query
  104664. * @param query defines the query to delete
  104665. * @return the current engine
  104666. */
  104667. deleteQuery(query: WebGLQuery): Engine;
  104668. /**
  104669. * Check if a given query has resolved and got its value
  104670. * @param query defines the query to check
  104671. * @returns true if the query got its value
  104672. */
  104673. isQueryResultAvailable(query: WebGLQuery): boolean;
  104674. /**
  104675. * Gets the value of a given query
  104676. * @param query defines the query to check
  104677. * @returns the value of the query
  104678. */
  104679. getQueryResult(query: WebGLQuery): number;
  104680. /**
  104681. * Initiates an occlusion query
  104682. * @param algorithmType defines the algorithm to use
  104683. * @param query defines the query to use
  104684. * @returns the current engine
  104685. * @see http://doc.babylonjs.com/features/occlusionquery
  104686. */
  104687. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  104688. /**
  104689. * Ends an occlusion query
  104690. * @see http://doc.babylonjs.com/features/occlusionquery
  104691. * @param algorithmType defines the algorithm to use
  104692. * @returns the current engine
  104693. */
  104694. endOcclusionQuery(algorithmType: number): Engine;
  104695. /**
  104696. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  104697. * Please note that only one query can be issued at a time
  104698. * @returns a time token used to track the time span
  104699. */
  104700. startTimeQuery(): Nullable<_TimeToken>;
  104701. /**
  104702. * Ends a time query
  104703. * @param token defines the token used to measure the time span
  104704. * @returns the time spent (in ns)
  104705. */
  104706. endTimeQuery(token: _TimeToken): int;
  104707. /** @hidden */
  104708. _currentNonTimestampToken: Nullable<_TimeToken>;
  104709. /** @hidden */
  104710. _createTimeQuery(): WebGLQuery;
  104711. /** @hidden */
  104712. _deleteTimeQuery(query: WebGLQuery): void;
  104713. /** @hidden */
  104714. _getGlAlgorithmType(algorithmType: number): number;
  104715. /** @hidden */
  104716. _getTimeQueryResult(query: WebGLQuery): any;
  104717. /** @hidden */
  104718. _getTimeQueryAvailability(query: WebGLQuery): any;
  104719. }
  104720. interface AbstractMesh {
  104721. /**
  104722. * Backing filed
  104723. * @hidden
  104724. */
  104725. __occlusionDataStorage: _OcclusionDataStorage;
  104726. /**
  104727. * Access property
  104728. * @hidden
  104729. */
  104730. _occlusionDataStorage: _OcclusionDataStorage;
  104731. /**
  104732. * 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.
  104733. * The default value is -1 which means don't break the query and wait till the result
  104734. * @see http://doc.babylonjs.com/features/occlusionquery
  104735. */
  104736. occlusionRetryCount: number;
  104737. /**
  104738. * 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:
  104739. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  104740. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  104741. * * 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.
  104742. * @see http://doc.babylonjs.com/features/occlusionquery
  104743. */
  104744. occlusionType: number;
  104745. /**
  104746. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  104747. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  104748. * * 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.
  104749. * @see http://doc.babylonjs.com/features/occlusionquery
  104750. */
  104751. occlusionQueryAlgorithmType: number;
  104752. /**
  104753. * 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
  104754. * @see http://doc.babylonjs.com/features/occlusionquery
  104755. */
  104756. isOccluded: boolean;
  104757. /**
  104758. * Flag to check the progress status of the query
  104759. * @see http://doc.babylonjs.com/features/occlusionquery
  104760. */
  104761. isOcclusionQueryInProgress: boolean;
  104762. }
  104763. }
  104764. declare module BABYLON {
  104765. /** @hidden */
  104766. export var _forceTransformFeedbackToBundle: boolean;
  104767. interface Engine {
  104768. /**
  104769. * Creates a webGL transform feedback object
  104770. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  104771. * @returns the webGL transform feedback object
  104772. */
  104773. createTransformFeedback(): WebGLTransformFeedback;
  104774. /**
  104775. * Delete a webGL transform feedback object
  104776. * @param value defines the webGL transform feedback object to delete
  104777. */
  104778. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  104779. /**
  104780. * Bind a webGL transform feedback object to the webgl context
  104781. * @param value defines the webGL transform feedback object to bind
  104782. */
  104783. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  104784. /**
  104785. * Begins a transform feedback operation
  104786. * @param usePoints defines if points or triangles must be used
  104787. */
  104788. beginTransformFeedback(usePoints: boolean): void;
  104789. /**
  104790. * Ends a transform feedback operation
  104791. */
  104792. endTransformFeedback(): void;
  104793. /**
  104794. * Specify the varyings to use with transform feedback
  104795. * @param program defines the associated webGL program
  104796. * @param value defines the list of strings representing the varying names
  104797. */
  104798. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  104799. /**
  104800. * Bind a webGL buffer for a transform feedback operation
  104801. * @param value defines the webGL buffer to bind
  104802. */
  104803. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  104804. }
  104805. }
  104806. declare module BABYLON {
  104807. /**
  104808. * Creation options of the multi render target texture.
  104809. */
  104810. export interface IMultiRenderTargetOptions {
  104811. /**
  104812. * Define if the texture needs to create mip maps after render.
  104813. */
  104814. generateMipMaps?: boolean;
  104815. /**
  104816. * Define the types of all the draw buffers we want to create
  104817. */
  104818. types?: number[];
  104819. /**
  104820. * Define the sampling modes of all the draw buffers we want to create
  104821. */
  104822. samplingModes?: number[];
  104823. /**
  104824. * Define if a depth buffer is required
  104825. */
  104826. generateDepthBuffer?: boolean;
  104827. /**
  104828. * Define if a stencil buffer is required
  104829. */
  104830. generateStencilBuffer?: boolean;
  104831. /**
  104832. * Define if a depth texture is required instead of a depth buffer
  104833. */
  104834. generateDepthTexture?: boolean;
  104835. /**
  104836. * Define the number of desired draw buffers
  104837. */
  104838. textureCount?: number;
  104839. /**
  104840. * Define if aspect ratio should be adapted to the texture or stay the scene one
  104841. */
  104842. doNotChangeAspectRatio?: boolean;
  104843. /**
  104844. * Define the default type of the buffers we are creating
  104845. */
  104846. defaultType?: number;
  104847. }
  104848. /**
  104849. * A multi render target, like a render target provides the ability to render to a texture.
  104850. * Unlike the render target, it can render to several draw buffers in one draw.
  104851. * This is specially interesting in deferred rendering or for any effects requiring more than
  104852. * just one color from a single pass.
  104853. */
  104854. export class MultiRenderTarget extends RenderTargetTexture {
  104855. private _internalTextures;
  104856. private _textures;
  104857. private _multiRenderTargetOptions;
  104858. /**
  104859. * Get if draw buffers are currently supported by the used hardware and browser.
  104860. */
  104861. readonly isSupported: boolean;
  104862. /**
  104863. * Get the list of textures generated by the multi render target.
  104864. */
  104865. readonly textures: Texture[];
  104866. /**
  104867. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  104868. */
  104869. readonly depthTexture: Texture;
  104870. /**
  104871. * Set the wrapping mode on U of all the textures we are rendering to.
  104872. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104873. */
  104874. wrapU: number;
  104875. /**
  104876. * Set the wrapping mode on V of all the textures we are rendering to.
  104877. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104878. */
  104879. wrapV: number;
  104880. /**
  104881. * Instantiate a new multi render target texture.
  104882. * A multi render target, like a render target provides the ability to render to a texture.
  104883. * Unlike the render target, it can render to several draw buffers in one draw.
  104884. * This is specially interesting in deferred rendering or for any effects requiring more than
  104885. * just one color from a single pass.
  104886. * @param name Define the name of the texture
  104887. * @param size Define the size of the buffers to render to
  104888. * @param count Define the number of target we are rendering into
  104889. * @param scene Define the scene the texture belongs to
  104890. * @param options Define the options used to create the multi render target
  104891. */
  104892. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  104893. /** @hidden */
  104894. _rebuild(): void;
  104895. private _createInternalTextures;
  104896. private _createTextures;
  104897. /**
  104898. * Define the number of samples used if MSAA is enabled.
  104899. */
  104900. samples: number;
  104901. /**
  104902. * Resize all the textures in the multi render target.
  104903. * Be carrefull as it will recreate all the data in the new texture.
  104904. * @param size Define the new size
  104905. */
  104906. resize(size: any): void;
  104907. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  104908. /**
  104909. * Dispose the render targets and their associated resources
  104910. */
  104911. dispose(): void;
  104912. /**
  104913. * Release all the underlying texture used as draw buffers.
  104914. */
  104915. releaseInternalTextures(): void;
  104916. }
  104917. }
  104918. declare module BABYLON {
  104919. interface Engine {
  104920. /**
  104921. * Unbind a list of render target textures from the webGL context
  104922. * This is used only when drawBuffer extension or webGL2 are active
  104923. * @param textures defines the render target textures to unbind
  104924. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  104925. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  104926. */
  104927. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  104928. /**
  104929. * Create a multi render target texture
  104930. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  104931. * @param size defines the size of the texture
  104932. * @param options defines the creation options
  104933. * @returns the cube texture as an InternalTexture
  104934. */
  104935. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  104936. /**
  104937. * Update the sample count for a given multiple render target texture
  104938. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  104939. * @param textures defines the textures to update
  104940. * @param samples defines the sample count to set
  104941. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  104942. */
  104943. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  104944. }
  104945. }
  104946. declare module BABYLON {
  104947. /**
  104948. * Gather the list of clipboard event types as constants.
  104949. */
  104950. export class ClipboardEventTypes {
  104951. /**
  104952. * The clipboard event is fired when a copy command is active (pressed).
  104953. */
  104954. static readonly COPY: number;
  104955. /**
  104956. * The clipboard event is fired when a cut command is active (pressed).
  104957. */
  104958. static readonly CUT: number;
  104959. /**
  104960. * The clipboard event is fired when a paste command is active (pressed).
  104961. */
  104962. static readonly PASTE: number;
  104963. }
  104964. /**
  104965. * This class is used to store clipboard related info for the onClipboardObservable event.
  104966. */
  104967. export class ClipboardInfo {
  104968. /**
  104969. * Defines the type of event (BABYLON.ClipboardEventTypes)
  104970. */
  104971. type: number;
  104972. /**
  104973. * Defines the related dom event
  104974. */
  104975. event: ClipboardEvent;
  104976. /**
  104977. *Creates an instance of ClipboardInfo.
  104978. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  104979. * @param event Defines the related dom event
  104980. */
  104981. constructor(
  104982. /**
  104983. * Defines the type of event (BABYLON.ClipboardEventTypes)
  104984. */
  104985. type: number,
  104986. /**
  104987. * Defines the related dom event
  104988. */
  104989. event: ClipboardEvent);
  104990. /**
  104991. * Get the clipboard event's type from the keycode.
  104992. * @param keyCode Defines the keyCode for the current keyboard event.
  104993. * @return {number}
  104994. */
  104995. static GetTypeFromCharacter(keyCode: number): number;
  104996. }
  104997. }
  104998. declare module BABYLON {
  104999. /**
  105000. * Class used to represent data loading progression
  105001. */
  105002. export class SceneLoaderProgressEvent {
  105003. /** defines if data length to load can be evaluated */
  105004. readonly lengthComputable: boolean;
  105005. /** defines the loaded data length */
  105006. readonly loaded: number;
  105007. /** defines the data length to load */
  105008. readonly total: number;
  105009. /**
  105010. * Create a new progress event
  105011. * @param lengthComputable defines if data length to load can be evaluated
  105012. * @param loaded defines the loaded data length
  105013. * @param total defines the data length to load
  105014. */
  105015. constructor(
  105016. /** defines if data length to load can be evaluated */
  105017. lengthComputable: boolean,
  105018. /** defines the loaded data length */
  105019. loaded: number,
  105020. /** defines the data length to load */
  105021. total: number);
  105022. /**
  105023. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  105024. * @param event defines the source event
  105025. * @returns a new SceneLoaderProgressEvent
  105026. */
  105027. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  105028. }
  105029. /**
  105030. * Interface used by SceneLoader plugins to define supported file extensions
  105031. */
  105032. export interface ISceneLoaderPluginExtensions {
  105033. /**
  105034. * Defines the list of supported extensions
  105035. */
  105036. [extension: string]: {
  105037. isBinary: boolean;
  105038. };
  105039. }
  105040. /**
  105041. * Interface used by SceneLoader plugin factory
  105042. */
  105043. export interface ISceneLoaderPluginFactory {
  105044. /**
  105045. * Defines the name of the factory
  105046. */
  105047. name: string;
  105048. /**
  105049. * Function called to create a new plugin
  105050. * @return the new plugin
  105051. */
  105052. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  105053. /**
  105054. * Boolean indicating if the plugin can direct load specific data
  105055. */
  105056. canDirectLoad?: (data: string) => boolean;
  105057. }
  105058. /**
  105059. * Interface used to define a SceneLoader plugin
  105060. */
  105061. export interface ISceneLoaderPlugin {
  105062. /**
  105063. * The friendly name of this plugin.
  105064. */
  105065. name: string;
  105066. /**
  105067. * The file extensions supported by this plugin.
  105068. */
  105069. extensions: string | ISceneLoaderPluginExtensions;
  105070. /**
  105071. * Import meshes into a scene.
  105072. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105073. * @param scene The scene to import into
  105074. * @param data The data to import
  105075. * @param rootUrl The root url for scene and resources
  105076. * @param meshes The meshes array to import into
  105077. * @param particleSystems The particle systems array to import into
  105078. * @param skeletons The skeletons array to import into
  105079. * @param onError The callback when import fails
  105080. * @returns True if successful or false otherwise
  105081. */
  105082. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  105083. /**
  105084. * Load into a scene.
  105085. * @param scene The scene to load into
  105086. * @param data The data to import
  105087. * @param rootUrl The root url for scene and resources
  105088. * @param onError The callback when import fails
  105089. * @returns true if successful or false otherwise
  105090. */
  105091. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  105092. /**
  105093. * The callback that returns true if the data can be directly loaded.
  105094. */
  105095. canDirectLoad?: (data: string) => boolean;
  105096. /**
  105097. * The callback that allows custom handling of the root url based on the response url.
  105098. */
  105099. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  105100. /**
  105101. * Load into an asset container.
  105102. * @param scene The scene to load into
  105103. * @param data The data to import
  105104. * @param rootUrl The root url for scene and resources
  105105. * @param onError The callback when import fails
  105106. * @returns The loaded asset container
  105107. */
  105108. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  105109. }
  105110. /**
  105111. * Interface used to define an async SceneLoader plugin
  105112. */
  105113. export interface ISceneLoaderPluginAsync {
  105114. /**
  105115. * The friendly name of this plugin.
  105116. */
  105117. name: string;
  105118. /**
  105119. * The file extensions supported by this plugin.
  105120. */
  105121. extensions: string | ISceneLoaderPluginExtensions;
  105122. /**
  105123. * Import meshes into a scene.
  105124. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105125. * @param scene The scene to import into
  105126. * @param data The data to import
  105127. * @param rootUrl The root url for scene and resources
  105128. * @param onProgress The callback when the load progresses
  105129. * @param fileName Defines the name of the file to load
  105130. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  105131. */
  105132. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  105133. meshes: AbstractMesh[];
  105134. particleSystems: IParticleSystem[];
  105135. skeletons: Skeleton[];
  105136. animationGroups: AnimationGroup[];
  105137. }>;
  105138. /**
  105139. * Load into a scene.
  105140. * @param scene The scene to load into
  105141. * @param data The data to import
  105142. * @param rootUrl The root url for scene and resources
  105143. * @param onProgress The callback when the load progresses
  105144. * @param fileName Defines the name of the file to load
  105145. * @returns Nothing
  105146. */
  105147. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  105148. /**
  105149. * The callback that returns true if the data can be directly loaded.
  105150. */
  105151. canDirectLoad?: (data: string) => boolean;
  105152. /**
  105153. * The callback that allows custom handling of the root url based on the response url.
  105154. */
  105155. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  105156. /**
  105157. * Load into an asset container.
  105158. * @param scene The scene to load into
  105159. * @param data The data to import
  105160. * @param rootUrl The root url for scene and resources
  105161. * @param onProgress The callback when the load progresses
  105162. * @param fileName Defines the name of the file to load
  105163. * @returns The loaded asset container
  105164. */
  105165. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  105166. }
  105167. /**
  105168. * Class used to load scene from various file formats using registered plugins
  105169. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  105170. */
  105171. export class SceneLoader {
  105172. /**
  105173. * No logging while loading
  105174. */
  105175. static readonly NO_LOGGING: number;
  105176. /**
  105177. * Minimal logging while loading
  105178. */
  105179. static readonly MINIMAL_LOGGING: number;
  105180. /**
  105181. * Summary logging while loading
  105182. */
  105183. static readonly SUMMARY_LOGGING: number;
  105184. /**
  105185. * Detailled logging while loading
  105186. */
  105187. static readonly DETAILED_LOGGING: number;
  105188. /**
  105189. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  105190. */
  105191. static ForceFullSceneLoadingForIncremental: boolean;
  105192. /**
  105193. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  105194. */
  105195. static ShowLoadingScreen: boolean;
  105196. /**
  105197. * Defines the current logging level (while loading the scene)
  105198. * @ignorenaming
  105199. */
  105200. static loggingLevel: number;
  105201. /**
  105202. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  105203. */
  105204. static CleanBoneMatrixWeights: boolean;
  105205. /**
  105206. * Event raised when a plugin is used to load a scene
  105207. */
  105208. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  105209. private static _registeredPlugins;
  105210. private static _getDefaultPlugin;
  105211. private static _getPluginForExtension;
  105212. private static _getPluginForDirectLoad;
  105213. private static _getPluginForFilename;
  105214. private static _getDirectLoad;
  105215. private static _loadData;
  105216. private static _getFileInfo;
  105217. /**
  105218. * Gets a plugin that can load the given extension
  105219. * @param extension defines the extension to load
  105220. * @returns a plugin or null if none works
  105221. */
  105222. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  105223. /**
  105224. * Gets a boolean indicating that the given extension can be loaded
  105225. * @param extension defines the extension to load
  105226. * @returns true if the extension is supported
  105227. */
  105228. static IsPluginForExtensionAvailable(extension: string): boolean;
  105229. /**
  105230. * Adds a new plugin to the list of registered plugins
  105231. * @param plugin defines the plugin to add
  105232. */
  105233. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  105234. /**
  105235. * Import meshes into a scene
  105236. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105237. * @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)
  105238. * @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)
  105239. * @param scene the instance of BABYLON.Scene to append to
  105240. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  105241. * @param onProgress a callback with a progress event for each file being loaded
  105242. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105243. * @param pluginExtension the extension used to determine the plugin
  105244. * @returns The loaded plugin
  105245. */
  105246. 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>;
  105247. /**
  105248. * Import meshes into a scene
  105249. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  105250. * @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)
  105251. * @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)
  105252. * @param scene the instance of BABYLON.Scene to append to
  105253. * @param onProgress a callback with a progress event for each file being loaded
  105254. * @param pluginExtension the extension used to determine the plugin
  105255. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  105256. */
  105257. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  105258. meshes: AbstractMesh[];
  105259. particleSystems: IParticleSystem[];
  105260. skeletons: Skeleton[];
  105261. animationGroups: AnimationGroup[];
  105262. }>;
  105263. /**
  105264. * Load a scene
  105265. * @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)
  105266. * @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)
  105267. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105268. * @param onSuccess a callback with the scene when import succeeds
  105269. * @param onProgress a callback with a progress event for each file being loaded
  105270. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105271. * @param pluginExtension the extension used to determine the plugin
  105272. * @returns The loaded plugin
  105273. */
  105274. 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>;
  105275. /**
  105276. * Load a scene
  105277. * @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)
  105278. * @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)
  105279. * @param engine is the instance of BABYLON.Engine to use to create the scene
  105280. * @param onProgress a callback with a progress event for each file being loaded
  105281. * @param pluginExtension the extension used to determine the plugin
  105282. * @returns The loaded scene
  105283. */
  105284. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  105285. /**
  105286. * Append a scene
  105287. * @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)
  105288. * @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)
  105289. * @param scene is the instance of BABYLON.Scene to append to
  105290. * @param onSuccess a callback with the scene when import succeeds
  105291. * @param onProgress a callback with a progress event for each file being loaded
  105292. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105293. * @param pluginExtension the extension used to determine the plugin
  105294. * @returns The loaded plugin
  105295. */
  105296. 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>;
  105297. /**
  105298. * Append a scene
  105299. * @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)
  105300. * @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)
  105301. * @param scene is the instance of BABYLON.Scene to append to
  105302. * @param onProgress a callback with a progress event for each file being loaded
  105303. * @param pluginExtension the extension used to determine the plugin
  105304. * @returns The given scene
  105305. */
  105306. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  105307. /**
  105308. * Load a scene into an asset container
  105309. * @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)
  105310. * @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)
  105311. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  105312. * @param onSuccess a callback with the scene when import succeeds
  105313. * @param onProgress a callback with a progress event for each file being loaded
  105314. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  105315. * @param pluginExtension the extension used to determine the plugin
  105316. * @returns The loaded plugin
  105317. */
  105318. 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>;
  105319. /**
  105320. * Load a scene into an asset container
  105321. * @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)
  105322. * @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)
  105323. * @param scene is the instance of Scene to append to
  105324. * @param onProgress a callback with a progress event for each file being loaded
  105325. * @param pluginExtension the extension used to determine the plugin
  105326. * @returns The loaded asset container
  105327. */
  105328. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  105329. }
  105330. }
  105331. declare module BABYLON {
  105332. /**
  105333. * Google Daydream controller
  105334. */
  105335. export class DaydreamController extends WebVRController {
  105336. /**
  105337. * Base Url for the controller model.
  105338. */
  105339. static MODEL_BASE_URL: string;
  105340. /**
  105341. * File name for the controller model.
  105342. */
  105343. static MODEL_FILENAME: string;
  105344. /**
  105345. * Gamepad Id prefix used to identify Daydream Controller.
  105346. */
  105347. static readonly GAMEPAD_ID_PREFIX: string;
  105348. /**
  105349. * Creates a new DaydreamController from a gamepad
  105350. * @param vrGamepad the gamepad that the controller should be created from
  105351. */
  105352. constructor(vrGamepad: any);
  105353. /**
  105354. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105355. * @param scene scene in which to add meshes
  105356. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105357. */
  105358. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105359. /**
  105360. * Called once for each button that changed state since the last frame
  105361. * @param buttonIdx Which button index changed
  105362. * @param state New state of the button
  105363. * @param changes Which properties on the state changed since last frame
  105364. */
  105365. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105366. }
  105367. }
  105368. declare module BABYLON {
  105369. /**
  105370. * Gear VR Controller
  105371. */
  105372. export class GearVRController extends WebVRController {
  105373. /**
  105374. * Base Url for the controller model.
  105375. */
  105376. static MODEL_BASE_URL: string;
  105377. /**
  105378. * File name for the controller model.
  105379. */
  105380. static MODEL_FILENAME: string;
  105381. /**
  105382. * Gamepad Id prefix used to identify this controller.
  105383. */
  105384. static readonly GAMEPAD_ID_PREFIX: string;
  105385. private readonly _buttonIndexToObservableNameMap;
  105386. /**
  105387. * Creates a new GearVRController from a gamepad
  105388. * @param vrGamepad the gamepad that the controller should be created from
  105389. */
  105390. constructor(vrGamepad: any);
  105391. /**
  105392. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105393. * @param scene scene in which to add meshes
  105394. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105395. */
  105396. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105397. /**
  105398. * Called once for each button that changed state since the last frame
  105399. * @param buttonIdx Which button index changed
  105400. * @param state New state of the button
  105401. * @param changes Which properties on the state changed since last frame
  105402. */
  105403. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105404. }
  105405. }
  105406. declare module BABYLON {
  105407. /**
  105408. * Generic Controller
  105409. */
  105410. export class GenericController extends WebVRController {
  105411. /**
  105412. * Base Url for the controller model.
  105413. */
  105414. static readonly MODEL_BASE_URL: string;
  105415. /**
  105416. * File name for the controller model.
  105417. */
  105418. static readonly MODEL_FILENAME: string;
  105419. /**
  105420. * Creates a new GenericController from a gamepad
  105421. * @param vrGamepad the gamepad that the controller should be created from
  105422. */
  105423. constructor(vrGamepad: any);
  105424. /**
  105425. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105426. * @param scene scene in which to add meshes
  105427. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105428. */
  105429. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105430. /**
  105431. * Called once for each button that changed state since the last frame
  105432. * @param buttonIdx Which button index changed
  105433. * @param state New state of the button
  105434. * @param changes Which properties on the state changed since last frame
  105435. */
  105436. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105437. }
  105438. }
  105439. declare module BABYLON {
  105440. /**
  105441. * Oculus Touch Controller
  105442. */
  105443. export class OculusTouchController extends WebVRController {
  105444. /**
  105445. * Base Url for the controller model.
  105446. */
  105447. static MODEL_BASE_URL: string;
  105448. /**
  105449. * File name for the left controller model.
  105450. */
  105451. static MODEL_LEFT_FILENAME: string;
  105452. /**
  105453. * File name for the right controller model.
  105454. */
  105455. static MODEL_RIGHT_FILENAME: string;
  105456. /**
  105457. * Base Url for the Quest controller model.
  105458. */
  105459. static QUEST_MODEL_BASE_URL: string;
  105460. /**
  105461. * @hidden
  105462. * If the controllers are running on a device that needs the updated Quest controller models
  105463. */
  105464. static _IsQuest: boolean;
  105465. /**
  105466. * Fired when the secondary trigger on this controller is modified
  105467. */
  105468. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  105469. /**
  105470. * Fired when the thumb rest on this controller is modified
  105471. */
  105472. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  105473. /**
  105474. * Creates a new OculusTouchController from a gamepad
  105475. * @param vrGamepad the gamepad that the controller should be created from
  105476. */
  105477. constructor(vrGamepad: any);
  105478. /**
  105479. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105480. * @param scene scene in which to add meshes
  105481. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105482. */
  105483. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105484. /**
  105485. * Fired when the A button on this controller is modified
  105486. */
  105487. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105488. /**
  105489. * Fired when the B button on this controller is modified
  105490. */
  105491. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105492. /**
  105493. * Fired when the X button on this controller is modified
  105494. */
  105495. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105496. /**
  105497. * Fired when the Y button on this controller is modified
  105498. */
  105499. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105500. /**
  105501. * Called once for each button that changed state since the last frame
  105502. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  105503. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  105504. * 2) secondary trigger (same)
  105505. * 3) A (right) X (left), touch, pressed = value
  105506. * 4) B / Y
  105507. * 5) thumb rest
  105508. * @param buttonIdx Which button index changed
  105509. * @param state New state of the button
  105510. * @param changes Which properties on the state changed since last frame
  105511. */
  105512. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105513. }
  105514. }
  105515. declare module BABYLON {
  105516. /**
  105517. * Vive Controller
  105518. */
  105519. export class ViveController extends WebVRController {
  105520. /**
  105521. * Base Url for the controller model.
  105522. */
  105523. static MODEL_BASE_URL: string;
  105524. /**
  105525. * File name for the controller model.
  105526. */
  105527. static MODEL_FILENAME: string;
  105528. /**
  105529. * Creates a new ViveController from a gamepad
  105530. * @param vrGamepad the gamepad that the controller should be created from
  105531. */
  105532. constructor(vrGamepad: any);
  105533. /**
  105534. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105535. * @param scene scene in which to add meshes
  105536. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105537. */
  105538. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  105539. /**
  105540. * Fired when the left button on this controller is modified
  105541. */
  105542. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105543. /**
  105544. * Fired when the right button on this controller is modified
  105545. */
  105546. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105547. /**
  105548. * Fired when the menu button on this controller is modified
  105549. */
  105550. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105551. /**
  105552. * Called once for each button that changed state since the last frame
  105553. * Vive mapping:
  105554. * 0: touchpad
  105555. * 1: trigger
  105556. * 2: left AND right buttons
  105557. * 3: menu button
  105558. * @param buttonIdx Which button index changed
  105559. * @param state New state of the button
  105560. * @param changes Which properties on the state changed since last frame
  105561. */
  105562. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105563. }
  105564. }
  105565. declare module BABYLON {
  105566. /**
  105567. * Defines the WindowsMotionController object that the state of the windows motion controller
  105568. */
  105569. export class WindowsMotionController extends WebVRController {
  105570. /**
  105571. * The base url used to load the left and right controller models
  105572. */
  105573. static MODEL_BASE_URL: string;
  105574. /**
  105575. * The name of the left controller model file
  105576. */
  105577. static MODEL_LEFT_FILENAME: string;
  105578. /**
  105579. * The name of the right controller model file
  105580. */
  105581. static MODEL_RIGHT_FILENAME: string;
  105582. /**
  105583. * The controller name prefix for this controller type
  105584. */
  105585. static readonly GAMEPAD_ID_PREFIX: string;
  105586. /**
  105587. * The controller id pattern for this controller type
  105588. */
  105589. private static readonly GAMEPAD_ID_PATTERN;
  105590. private _loadedMeshInfo;
  105591. private readonly _mapping;
  105592. /**
  105593. * Fired when the trackpad on this controller is clicked
  105594. */
  105595. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  105596. /**
  105597. * Fired when the trackpad on this controller is modified
  105598. */
  105599. onTrackpadValuesChangedObservable: Observable<StickValues>;
  105600. /**
  105601. * The current x and y values of this controller's trackpad
  105602. */
  105603. trackpad: StickValues;
  105604. /**
  105605. * Creates a new WindowsMotionController from a gamepad
  105606. * @param vrGamepad the gamepad that the controller should be created from
  105607. */
  105608. constructor(vrGamepad: any);
  105609. /**
  105610. * Fired when the trigger on this controller is modified
  105611. */
  105612. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105613. /**
  105614. * Fired when the menu button on this controller is modified
  105615. */
  105616. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105617. /**
  105618. * Fired when the grip button on this controller is modified
  105619. */
  105620. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105621. /**
  105622. * Fired when the thumbstick button on this controller is modified
  105623. */
  105624. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105625. /**
  105626. * Fired when the touchpad button on this controller is modified
  105627. */
  105628. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  105629. /**
  105630. * Fired when the touchpad values on this controller are modified
  105631. */
  105632. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  105633. private _updateTrackpad;
  105634. /**
  105635. * Called once per frame by the engine.
  105636. */
  105637. update(): void;
  105638. /**
  105639. * Called once for each button that changed state since the last frame
  105640. * @param buttonIdx Which button index changed
  105641. * @param state New state of the button
  105642. * @param changes Which properties on the state changed since last frame
  105643. */
  105644. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  105645. /**
  105646. * Moves the buttons on the controller mesh based on their current state
  105647. * @param buttonName the name of the button to move
  105648. * @param buttonValue the value of the button which determines the buttons new position
  105649. */
  105650. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  105651. /**
  105652. * Moves the axis on the controller mesh based on its current state
  105653. * @param axis the index of the axis
  105654. * @param axisValue the value of the axis which determines the meshes new position
  105655. * @hidden
  105656. */
  105657. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  105658. /**
  105659. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  105660. * @param scene scene in which to add meshes
  105661. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  105662. */
  105663. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  105664. /**
  105665. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  105666. * can be transformed by button presses and axes values, based on this._mapping.
  105667. *
  105668. * @param scene scene in which the meshes exist
  105669. * @param meshes list of meshes that make up the controller model to process
  105670. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  105671. */
  105672. private processModel;
  105673. private createMeshInfo;
  105674. /**
  105675. * Gets the ray of the controller in the direction the controller is pointing
  105676. * @param length the length the resulting ray should be
  105677. * @returns a ray in the direction the controller is pointing
  105678. */
  105679. getForwardRay(length?: number): Ray;
  105680. /**
  105681. * Disposes of the controller
  105682. */
  105683. dispose(): void;
  105684. }
  105685. }
  105686. declare module BABYLON {
  105687. /**
  105688. * Class containing static functions to help procedurally build meshes
  105689. */
  105690. export class PolyhedronBuilder {
  105691. /**
  105692. * Creates a polyhedron mesh
  105693. * * 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
  105694. * * The parameter `size` (positive float, default 1) sets the polygon size
  105695. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  105696. * * 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`
  105697. * * 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
  105698. * * 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)`)
  105699. * * 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
  105700. * * 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
  105701. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  105702. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  105703. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  105704. * @param name defines the name of the mesh
  105705. * @param options defines the options used to create the mesh
  105706. * @param scene defines the hosting scene
  105707. * @returns the polyhedron mesh
  105708. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  105709. */
  105710. static CreatePolyhedron(name: string, options: {
  105711. type?: number;
  105712. size?: number;
  105713. sizeX?: number;
  105714. sizeY?: number;
  105715. sizeZ?: number;
  105716. custom?: any;
  105717. faceUV?: Vector4[];
  105718. faceColors?: Color4[];
  105719. flat?: boolean;
  105720. updatable?: boolean;
  105721. sideOrientation?: number;
  105722. frontUVs?: Vector4;
  105723. backUVs?: Vector4;
  105724. }, scene?: Nullable<Scene>): Mesh;
  105725. }
  105726. }
  105727. declare module BABYLON {
  105728. /**
  105729. * Gizmo that enables scaling a mesh along 3 axis
  105730. */
  105731. export class ScaleGizmo extends Gizmo {
  105732. /**
  105733. * Internal gizmo used for interactions on the x axis
  105734. */
  105735. xGizmo: AxisScaleGizmo;
  105736. /**
  105737. * Internal gizmo used for interactions on the y axis
  105738. */
  105739. yGizmo: AxisScaleGizmo;
  105740. /**
  105741. * Internal gizmo used for interactions on the z axis
  105742. */
  105743. zGizmo: AxisScaleGizmo;
  105744. /**
  105745. * Internal gizmo used to scale all axis equally
  105746. */
  105747. uniformScaleGizmo: AxisScaleGizmo;
  105748. private _meshAttached;
  105749. private _updateGizmoRotationToMatchAttachedMesh;
  105750. private _snapDistance;
  105751. private _scaleRatio;
  105752. private _uniformScalingMesh;
  105753. private _octahedron;
  105754. /** Fires an event when any of it's sub gizmos are dragged */
  105755. onDragStartObservable: Observable<unknown>;
  105756. /** Fires an event when any of it's sub gizmos are released from dragging */
  105757. onDragEndObservable: Observable<unknown>;
  105758. attachedMesh: Nullable<AbstractMesh>;
  105759. /**
  105760. * Creates a ScaleGizmo
  105761. * @param gizmoLayer The utility layer the gizmo will be added to
  105762. */
  105763. constructor(gizmoLayer?: UtilityLayerRenderer);
  105764. updateGizmoRotationToMatchAttachedMesh: boolean;
  105765. /**
  105766. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  105767. */
  105768. snapDistance: number;
  105769. /**
  105770. * Ratio for the scale of the gizmo (Default: 1)
  105771. */
  105772. scaleRatio: number;
  105773. /**
  105774. * Disposes of the gizmo
  105775. */
  105776. dispose(): void;
  105777. }
  105778. }
  105779. declare module BABYLON {
  105780. /**
  105781. * Single axis scale gizmo
  105782. */
  105783. export class AxisScaleGizmo extends Gizmo {
  105784. /**
  105785. * Drag behavior responsible for the gizmos dragging interactions
  105786. */
  105787. dragBehavior: PointerDragBehavior;
  105788. private _pointerObserver;
  105789. /**
  105790. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  105791. */
  105792. snapDistance: number;
  105793. /**
  105794. * Event that fires each time the gizmo snaps to a new location.
  105795. * * snapDistance is the the change in distance
  105796. */
  105797. onSnapObservable: Observable<{
  105798. snapDistance: number;
  105799. }>;
  105800. /**
  105801. * If the scaling operation should be done on all axis (default: false)
  105802. */
  105803. uniformScaling: boolean;
  105804. private _isEnabled;
  105805. private _parent;
  105806. private _arrow;
  105807. private _coloredMaterial;
  105808. private _hoverMaterial;
  105809. /**
  105810. * Creates an AxisScaleGizmo
  105811. * @param gizmoLayer The utility layer the gizmo will be added to
  105812. * @param dragAxis The axis which the gizmo will be able to scale on
  105813. * @param color The color of the gizmo
  105814. */
  105815. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  105816. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  105817. /**
  105818. * If the gizmo is enabled
  105819. */
  105820. isEnabled: boolean;
  105821. /**
  105822. * Disposes of the gizmo
  105823. */
  105824. dispose(): void;
  105825. /**
  105826. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  105827. * @param mesh The mesh to replace the default mesh of the gizmo
  105828. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  105829. */
  105830. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  105831. }
  105832. }
  105833. declare module BABYLON {
  105834. /**
  105835. * Bounding box gizmo
  105836. */
  105837. export class BoundingBoxGizmo extends Gizmo {
  105838. private _lineBoundingBox;
  105839. private _rotateSpheresParent;
  105840. private _scaleBoxesParent;
  105841. private _boundingDimensions;
  105842. private _renderObserver;
  105843. private _pointerObserver;
  105844. private _scaleDragSpeed;
  105845. private _tmpQuaternion;
  105846. private _tmpVector;
  105847. private _tmpRotationMatrix;
  105848. /**
  105849. * 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)
  105850. */
  105851. ignoreChildren: boolean;
  105852. /**
  105853. * 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)
  105854. */
  105855. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  105856. /**
  105857. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  105858. */
  105859. rotationSphereSize: number;
  105860. /**
  105861. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  105862. */
  105863. scaleBoxSize: number;
  105864. /**
  105865. * 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)
  105866. */
  105867. fixedDragMeshScreenSize: boolean;
  105868. /**
  105869. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  105870. */
  105871. fixedDragMeshScreenSizeDistanceFactor: number;
  105872. /**
  105873. * Fired when a rotation sphere or scale box is dragged
  105874. */
  105875. onDragStartObservable: Observable<{}>;
  105876. /**
  105877. * Fired when a scale box is dragged
  105878. */
  105879. onScaleBoxDragObservable: Observable<{}>;
  105880. /**
  105881. * Fired when a scale box drag is ended
  105882. */
  105883. onScaleBoxDragEndObservable: Observable<{}>;
  105884. /**
  105885. * Fired when a rotation sphere is dragged
  105886. */
  105887. onRotationSphereDragObservable: Observable<{}>;
  105888. /**
  105889. * Fired when a rotation sphere drag is ended
  105890. */
  105891. onRotationSphereDragEndObservable: Observable<{}>;
  105892. /**
  105893. * 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)
  105894. */
  105895. scalePivot: Nullable<Vector3>;
  105896. /**
  105897. * Mesh used as a pivot to rotate the attached mesh
  105898. */
  105899. private _anchorMesh;
  105900. private _existingMeshScale;
  105901. private _dragMesh;
  105902. private pointerDragBehavior;
  105903. private coloredMaterial;
  105904. private hoverColoredMaterial;
  105905. /**
  105906. * Sets the color of the bounding box gizmo
  105907. * @param color the color to set
  105908. */
  105909. setColor(color: Color3): void;
  105910. /**
  105911. * Creates an BoundingBoxGizmo
  105912. * @param gizmoLayer The utility layer the gizmo will be added to
  105913. * @param color The color of the gizmo
  105914. */
  105915. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  105916. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  105917. private _selectNode;
  105918. /**
  105919. * Updates the bounding box information for the Gizmo
  105920. */
  105921. updateBoundingBox(): void;
  105922. private _updateRotationSpheres;
  105923. private _updateScaleBoxes;
  105924. /**
  105925. * Enables rotation on the specified axis and disables rotation on the others
  105926. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  105927. */
  105928. setEnabledRotationAxis(axis: string): void;
  105929. /**
  105930. * Enables/disables scaling
  105931. * @param enable if scaling should be enabled
  105932. */
  105933. setEnabledScaling(enable: boolean): void;
  105934. private _updateDummy;
  105935. /**
  105936. * Enables a pointer drag behavior on the bounding box of the gizmo
  105937. */
  105938. enableDragBehavior(): void;
  105939. /**
  105940. * Disposes of the gizmo
  105941. */
  105942. dispose(): void;
  105943. /**
  105944. * 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)
  105945. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  105946. * @returns the bounding box mesh with the passed in mesh as a child
  105947. */
  105948. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  105949. /**
  105950. * CustomMeshes are not supported by this gizmo
  105951. * @param mesh The mesh to replace the default mesh of the gizmo
  105952. */
  105953. setCustomMesh(mesh: Mesh): void;
  105954. }
  105955. }
  105956. declare module BABYLON {
  105957. /**
  105958. * Single plane rotation gizmo
  105959. */
  105960. export class PlaneRotationGizmo extends Gizmo {
  105961. /**
  105962. * Drag behavior responsible for the gizmos dragging interactions
  105963. */
  105964. dragBehavior: PointerDragBehavior;
  105965. private _pointerObserver;
  105966. /**
  105967. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  105968. */
  105969. snapDistance: number;
  105970. /**
  105971. * Event that fires each time the gizmo snaps to a new location.
  105972. * * snapDistance is the the change in distance
  105973. */
  105974. onSnapObservable: Observable<{
  105975. snapDistance: number;
  105976. }>;
  105977. private _isEnabled;
  105978. private _parent;
  105979. /**
  105980. * Creates a PlaneRotationGizmo
  105981. * @param gizmoLayer The utility layer the gizmo will be added to
  105982. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  105983. * @param color The color of the gizmo
  105984. * @param tessellation Amount of tessellation to be used when creating rotation circles
  105985. */
  105986. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  105987. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  105988. /**
  105989. * If the gizmo is enabled
  105990. */
  105991. isEnabled: boolean;
  105992. /**
  105993. * Disposes of the gizmo
  105994. */
  105995. dispose(): void;
  105996. }
  105997. }
  105998. declare module BABYLON {
  105999. /**
  106000. * Gizmo that enables rotating a mesh along 3 axis
  106001. */
  106002. export class RotationGizmo extends Gizmo {
  106003. /**
  106004. * Internal gizmo used for interactions on the x axis
  106005. */
  106006. xGizmo: PlaneRotationGizmo;
  106007. /**
  106008. * Internal gizmo used for interactions on the y axis
  106009. */
  106010. yGizmo: PlaneRotationGizmo;
  106011. /**
  106012. * Internal gizmo used for interactions on the z axis
  106013. */
  106014. zGizmo: PlaneRotationGizmo;
  106015. /** Fires an event when any of it's sub gizmos are dragged */
  106016. onDragStartObservable: Observable<unknown>;
  106017. /** Fires an event when any of it's sub gizmos are released from dragging */
  106018. onDragEndObservable: Observable<unknown>;
  106019. private _meshAttached;
  106020. attachedMesh: Nullable<AbstractMesh>;
  106021. /**
  106022. * Creates a RotationGizmo
  106023. * @param gizmoLayer The utility layer the gizmo will be added to
  106024. * @param tessellation Amount of tessellation to be used when creating rotation circles
  106025. */
  106026. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  106027. updateGizmoRotationToMatchAttachedMesh: boolean;
  106028. /**
  106029. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  106030. */
  106031. snapDistance: number;
  106032. /**
  106033. * Ratio for the scale of the gizmo (Default: 1)
  106034. */
  106035. scaleRatio: number;
  106036. /**
  106037. * Disposes of the gizmo
  106038. */
  106039. dispose(): void;
  106040. /**
  106041. * CustomMeshes are not supported by this gizmo
  106042. * @param mesh The mesh to replace the default mesh of the gizmo
  106043. */
  106044. setCustomMesh(mesh: Mesh): void;
  106045. }
  106046. }
  106047. declare module BABYLON {
  106048. /**
  106049. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  106050. */
  106051. export class GizmoManager implements IDisposable {
  106052. private scene;
  106053. /**
  106054. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  106055. */
  106056. gizmos: {
  106057. positionGizmo: Nullable<PositionGizmo>;
  106058. rotationGizmo: Nullable<RotationGizmo>;
  106059. scaleGizmo: Nullable<ScaleGizmo>;
  106060. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  106061. };
  106062. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  106063. clearGizmoOnEmptyPointerEvent: boolean;
  106064. /** Fires an event when the manager is attached to a mesh */
  106065. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  106066. private _gizmosEnabled;
  106067. private _pointerObserver;
  106068. private _attachedMesh;
  106069. private _boundingBoxColor;
  106070. private _defaultUtilityLayer;
  106071. private _defaultKeepDepthUtilityLayer;
  106072. /**
  106073. * When bounding box gizmo is enabled, this can be used to track drag/end events
  106074. */
  106075. boundingBoxDragBehavior: SixDofDragBehavior;
  106076. /**
  106077. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  106078. */
  106079. attachableMeshes: Nullable<Array<AbstractMesh>>;
  106080. /**
  106081. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  106082. */
  106083. usePointerToAttachGizmos: boolean;
  106084. /**
  106085. * Utility layer that the bounding box gizmo belongs to
  106086. */
  106087. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  106088. /**
  106089. * Utility layer that all gizmos besides bounding box belong to
  106090. */
  106091. readonly utilityLayer: UtilityLayerRenderer;
  106092. /**
  106093. * Instatiates a gizmo manager
  106094. * @param scene the scene to overlay the gizmos on top of
  106095. */
  106096. constructor(scene: Scene);
  106097. /**
  106098. * Attaches a set of gizmos to the specified mesh
  106099. * @param mesh The mesh the gizmo's should be attached to
  106100. */
  106101. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  106102. /**
  106103. * If the position gizmo is enabled
  106104. */
  106105. positionGizmoEnabled: boolean;
  106106. /**
  106107. * If the rotation gizmo is enabled
  106108. */
  106109. rotationGizmoEnabled: boolean;
  106110. /**
  106111. * If the scale gizmo is enabled
  106112. */
  106113. scaleGizmoEnabled: boolean;
  106114. /**
  106115. * If the boundingBox gizmo is enabled
  106116. */
  106117. boundingBoxGizmoEnabled: boolean;
  106118. /**
  106119. * Disposes of the gizmo manager
  106120. */
  106121. dispose(): void;
  106122. }
  106123. }
  106124. declare module BABYLON {
  106125. /**
  106126. * A directional light is defined by a direction (what a surprise!).
  106127. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  106128. * 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.
  106129. * Documentation: https://doc.babylonjs.com/babylon101/lights
  106130. */
  106131. export class DirectionalLight extends ShadowLight {
  106132. private _shadowFrustumSize;
  106133. /**
  106134. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  106135. */
  106136. /**
  106137. * Specifies a fix frustum size for the shadow generation.
  106138. */
  106139. shadowFrustumSize: number;
  106140. private _shadowOrthoScale;
  106141. /**
  106142. * Gets the shadow projection scale against the optimal computed one.
  106143. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  106144. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  106145. */
  106146. /**
  106147. * Sets the shadow projection scale against the optimal computed one.
  106148. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  106149. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  106150. */
  106151. shadowOrthoScale: number;
  106152. /**
  106153. * Automatically compute the projection matrix to best fit (including all the casters)
  106154. * on each frame.
  106155. */
  106156. autoUpdateExtends: boolean;
  106157. private _orthoLeft;
  106158. private _orthoRight;
  106159. private _orthoTop;
  106160. private _orthoBottom;
  106161. /**
  106162. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  106163. * The directional light is emitted from everywhere in the given direction.
  106164. * It can cast shadows.
  106165. * Documentation : https://doc.babylonjs.com/babylon101/lights
  106166. * @param name The friendly name of the light
  106167. * @param direction The direction of the light
  106168. * @param scene The scene the light belongs to
  106169. */
  106170. constructor(name: string, direction: Vector3, scene: Scene);
  106171. /**
  106172. * Returns the string "DirectionalLight".
  106173. * @return The class name
  106174. */
  106175. getClassName(): string;
  106176. /**
  106177. * Returns the integer 1.
  106178. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  106179. */
  106180. getTypeID(): number;
  106181. /**
  106182. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  106183. * Returns the DirectionalLight Shadow projection matrix.
  106184. */
  106185. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106186. /**
  106187. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  106188. * Returns the DirectionalLight Shadow projection matrix.
  106189. */
  106190. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  106191. /**
  106192. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  106193. * Returns the DirectionalLight Shadow projection matrix.
  106194. */
  106195. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106196. protected _buildUniformLayout(): void;
  106197. /**
  106198. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  106199. * @param effect The effect to update
  106200. * @param lightIndex The index of the light in the effect to update
  106201. * @returns The directional light
  106202. */
  106203. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  106204. /**
  106205. * Gets the minZ used for shadow according to both the scene and the light.
  106206. *
  106207. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  106208. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  106209. * @param activeCamera The camera we are returning the min for
  106210. * @returns the depth min z
  106211. */
  106212. getDepthMinZ(activeCamera: Camera): number;
  106213. /**
  106214. * Gets the maxZ used for shadow according to both the scene and the light.
  106215. *
  106216. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  106217. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  106218. * @param activeCamera The camera we are returning the max for
  106219. * @returns the depth max z
  106220. */
  106221. getDepthMaxZ(activeCamera: Camera): number;
  106222. /**
  106223. * Prepares the list of defines specific to the light type.
  106224. * @param defines the list of defines
  106225. * @param lightIndex defines the index of the light for the effect
  106226. */
  106227. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  106228. }
  106229. }
  106230. declare module BABYLON {
  106231. /**
  106232. * Class containing static functions to help procedurally build meshes
  106233. */
  106234. export class HemisphereBuilder {
  106235. /**
  106236. * Creates a hemisphere mesh
  106237. * @param name defines the name of the mesh
  106238. * @param options defines the options used to create the mesh
  106239. * @param scene defines the hosting scene
  106240. * @returns the hemisphere mesh
  106241. */
  106242. static CreateHemisphere(name: string, options: {
  106243. segments?: number;
  106244. diameter?: number;
  106245. sideOrientation?: number;
  106246. }, scene: any): Mesh;
  106247. }
  106248. }
  106249. declare module BABYLON {
  106250. /**
  106251. * A spot light is defined by a position, a direction, an angle, and an exponent.
  106252. * These values define a cone of light starting from the position, emitting toward the direction.
  106253. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  106254. * and the exponent defines the speed of the decay of the light with distance (reach).
  106255. * Documentation: https://doc.babylonjs.com/babylon101/lights
  106256. */
  106257. export class SpotLight extends ShadowLight {
  106258. private _angle;
  106259. private _innerAngle;
  106260. private _cosHalfAngle;
  106261. private _lightAngleScale;
  106262. private _lightAngleOffset;
  106263. /**
  106264. * Gets the cone angle of the spot light in Radians.
  106265. */
  106266. /**
  106267. * Sets the cone angle of the spot light in Radians.
  106268. */
  106269. angle: number;
  106270. /**
  106271. * Only used in gltf falloff mode, this defines the angle where
  106272. * the directional falloff will start before cutting at angle which could be seen
  106273. * as outer angle.
  106274. */
  106275. /**
  106276. * Only used in gltf falloff mode, this defines the angle where
  106277. * the directional falloff will start before cutting at angle which could be seen
  106278. * as outer angle.
  106279. */
  106280. innerAngle: number;
  106281. private _shadowAngleScale;
  106282. /**
  106283. * Allows scaling the angle of the light for shadow generation only.
  106284. */
  106285. /**
  106286. * Allows scaling the angle of the light for shadow generation only.
  106287. */
  106288. shadowAngleScale: number;
  106289. /**
  106290. * The light decay speed with the distance from the emission spot.
  106291. */
  106292. exponent: number;
  106293. private _projectionTextureMatrix;
  106294. /**
  106295. * Allows reading the projecton texture
  106296. */
  106297. readonly projectionTextureMatrix: Matrix;
  106298. protected _projectionTextureLightNear: number;
  106299. /**
  106300. * Gets the near clip of the Spotlight for texture projection.
  106301. */
  106302. /**
  106303. * Sets the near clip of the Spotlight for texture projection.
  106304. */
  106305. projectionTextureLightNear: number;
  106306. protected _projectionTextureLightFar: number;
  106307. /**
  106308. * Gets the far clip of the Spotlight for texture projection.
  106309. */
  106310. /**
  106311. * Sets the far clip of the Spotlight for texture projection.
  106312. */
  106313. projectionTextureLightFar: number;
  106314. protected _projectionTextureUpDirection: Vector3;
  106315. /**
  106316. * Gets the Up vector of the Spotlight for texture projection.
  106317. */
  106318. /**
  106319. * Sets the Up vector of the Spotlight for texture projection.
  106320. */
  106321. projectionTextureUpDirection: Vector3;
  106322. private _projectionTexture;
  106323. /**
  106324. * Gets the projection texture of the light.
  106325. */
  106326. /**
  106327. * Sets the projection texture of the light.
  106328. */
  106329. projectionTexture: Nullable<BaseTexture>;
  106330. private _projectionTextureViewLightDirty;
  106331. private _projectionTextureProjectionLightDirty;
  106332. private _projectionTextureDirty;
  106333. private _projectionTextureViewTargetVector;
  106334. private _projectionTextureViewLightMatrix;
  106335. private _projectionTextureProjectionLightMatrix;
  106336. private _projectionTextureScalingMatrix;
  106337. /**
  106338. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  106339. * It can cast shadows.
  106340. * Documentation : https://doc.babylonjs.com/babylon101/lights
  106341. * @param name The light friendly name
  106342. * @param position The position of the spot light in the scene
  106343. * @param direction The direction of the light in the scene
  106344. * @param angle The cone angle of the light in Radians
  106345. * @param exponent The light decay speed with the distance from the emission spot
  106346. * @param scene The scene the lights belongs to
  106347. */
  106348. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  106349. /**
  106350. * Returns the string "SpotLight".
  106351. * @returns the class name
  106352. */
  106353. getClassName(): string;
  106354. /**
  106355. * Returns the integer 2.
  106356. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  106357. */
  106358. getTypeID(): number;
  106359. /**
  106360. * Overrides the direction setter to recompute the projection texture view light Matrix.
  106361. */
  106362. protected _setDirection(value: Vector3): void;
  106363. /**
  106364. * Overrides the position setter to recompute the projection texture view light Matrix.
  106365. */
  106366. protected _setPosition(value: Vector3): void;
  106367. /**
  106368. * 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.
  106369. * Returns the SpotLight.
  106370. */
  106371. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  106372. protected _computeProjectionTextureViewLightMatrix(): void;
  106373. protected _computeProjectionTextureProjectionLightMatrix(): void;
  106374. /**
  106375. * Main function for light texture projection matrix computing.
  106376. */
  106377. protected _computeProjectionTextureMatrix(): void;
  106378. protected _buildUniformLayout(): void;
  106379. private _computeAngleValues;
  106380. /**
  106381. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  106382. * @param effect The effect to update
  106383. * @param lightIndex The index of the light in the effect to update
  106384. * @returns The spot light
  106385. */
  106386. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  106387. /**
  106388. * Disposes the light and the associated resources.
  106389. */
  106390. dispose(): void;
  106391. /**
  106392. * Prepares the list of defines specific to the light type.
  106393. * @param defines the list of defines
  106394. * @param lightIndex defines the index of the light for the effect
  106395. */
  106396. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  106397. }
  106398. }
  106399. declare module BABYLON {
  106400. /**
  106401. * Gizmo that enables viewing a light
  106402. */
  106403. export class LightGizmo extends Gizmo {
  106404. private _lightMesh;
  106405. private _material;
  106406. private cachedPosition;
  106407. private cachedForward;
  106408. /**
  106409. * Creates a LightGizmo
  106410. * @param gizmoLayer The utility layer the gizmo will be added to
  106411. */
  106412. constructor(gizmoLayer?: UtilityLayerRenderer);
  106413. private _light;
  106414. /**
  106415. * The light that the gizmo is attached to
  106416. */
  106417. light: Nullable<Light>;
  106418. /**
  106419. * @hidden
  106420. * Updates the gizmo to match the attached mesh's position/rotation
  106421. */
  106422. protected _update(): void;
  106423. private static _Scale;
  106424. /**
  106425. * Creates the lines for a light mesh
  106426. */
  106427. private static _createLightLines;
  106428. /**
  106429. * Disposes of the light gizmo
  106430. */
  106431. dispose(): void;
  106432. private static _CreateHemisphericLightMesh;
  106433. private static _CreatePointLightMesh;
  106434. private static _CreateSpotLightMesh;
  106435. private static _CreateDirectionalLightMesh;
  106436. }
  106437. }
  106438. declare module BABYLON {
  106439. /** @hidden */
  106440. export var backgroundFragmentDeclaration: {
  106441. name: string;
  106442. shader: string;
  106443. };
  106444. }
  106445. declare module BABYLON {
  106446. /** @hidden */
  106447. export var backgroundUboDeclaration: {
  106448. name: string;
  106449. shader: string;
  106450. };
  106451. }
  106452. declare module BABYLON {
  106453. /** @hidden */
  106454. export var backgroundPixelShader: {
  106455. name: string;
  106456. shader: string;
  106457. };
  106458. }
  106459. declare module BABYLON {
  106460. /** @hidden */
  106461. export var backgroundVertexDeclaration: {
  106462. name: string;
  106463. shader: string;
  106464. };
  106465. }
  106466. declare module BABYLON {
  106467. /** @hidden */
  106468. export var backgroundVertexShader: {
  106469. name: string;
  106470. shader: string;
  106471. };
  106472. }
  106473. declare module BABYLON {
  106474. /**
  106475. * Background material used to create an efficient environement around your scene.
  106476. */
  106477. export class BackgroundMaterial extends PushMaterial {
  106478. /**
  106479. * Standard reflectance value at parallel view angle.
  106480. */
  106481. static StandardReflectance0: number;
  106482. /**
  106483. * Standard reflectance value at grazing angle.
  106484. */
  106485. static StandardReflectance90: number;
  106486. protected _primaryColor: Color3;
  106487. /**
  106488. * Key light Color (multiply against the environement texture)
  106489. */
  106490. primaryColor: Color3;
  106491. protected __perceptualColor: Nullable<Color3>;
  106492. /**
  106493. * Experimental Internal Use Only.
  106494. *
  106495. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  106496. * This acts as a helper to set the primary color to a more "human friendly" value.
  106497. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  106498. * output color as close as possible from the chosen value.
  106499. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  106500. * part of lighting setup.)
  106501. */
  106502. _perceptualColor: Nullable<Color3>;
  106503. protected _primaryColorShadowLevel: float;
  106504. /**
  106505. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  106506. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  106507. */
  106508. primaryColorShadowLevel: float;
  106509. protected _primaryColorHighlightLevel: float;
  106510. /**
  106511. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  106512. * The primary color is used at the level chosen to define what the white area would look.
  106513. */
  106514. primaryColorHighlightLevel: float;
  106515. protected _reflectionTexture: Nullable<BaseTexture>;
  106516. /**
  106517. * Reflection Texture used in the material.
  106518. * Should be author in a specific way for the best result (refer to the documentation).
  106519. */
  106520. reflectionTexture: Nullable<BaseTexture>;
  106521. protected _reflectionBlur: float;
  106522. /**
  106523. * Reflection Texture level of blur.
  106524. *
  106525. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  106526. * texture twice.
  106527. */
  106528. reflectionBlur: float;
  106529. protected _diffuseTexture: Nullable<BaseTexture>;
  106530. /**
  106531. * Diffuse Texture used in the material.
  106532. * Should be author in a specific way for the best result (refer to the documentation).
  106533. */
  106534. diffuseTexture: Nullable<BaseTexture>;
  106535. protected _shadowLights: Nullable<IShadowLight[]>;
  106536. /**
  106537. * Specify the list of lights casting shadow on the material.
  106538. * All scene shadow lights will be included if null.
  106539. */
  106540. shadowLights: Nullable<IShadowLight[]>;
  106541. protected _shadowLevel: float;
  106542. /**
  106543. * Helps adjusting the shadow to a softer level if required.
  106544. * 0 means black shadows and 1 means no shadows.
  106545. */
  106546. shadowLevel: float;
  106547. protected _sceneCenter: Vector3;
  106548. /**
  106549. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  106550. * It is usually zero but might be interesting to modify according to your setup.
  106551. */
  106552. sceneCenter: Vector3;
  106553. protected _opacityFresnel: boolean;
  106554. /**
  106555. * This helps specifying that the material is falling off to the sky box at grazing angle.
  106556. * This helps ensuring a nice transition when the camera goes under the ground.
  106557. */
  106558. opacityFresnel: boolean;
  106559. protected _reflectionFresnel: boolean;
  106560. /**
  106561. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  106562. * This helps adding a mirror texture on the ground.
  106563. */
  106564. reflectionFresnel: boolean;
  106565. protected _reflectionFalloffDistance: number;
  106566. /**
  106567. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  106568. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  106569. */
  106570. reflectionFalloffDistance: number;
  106571. protected _reflectionAmount: number;
  106572. /**
  106573. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  106574. */
  106575. reflectionAmount: number;
  106576. protected _reflectionReflectance0: number;
  106577. /**
  106578. * This specifies the weight of the reflection at grazing angle.
  106579. */
  106580. reflectionReflectance0: number;
  106581. protected _reflectionReflectance90: number;
  106582. /**
  106583. * This specifies the weight of the reflection at a perpendicular point of view.
  106584. */
  106585. reflectionReflectance90: number;
  106586. /**
  106587. * Sets the reflection reflectance fresnel values according to the default standard
  106588. * empirically know to work well :-)
  106589. */
  106590. reflectionStandardFresnelWeight: number;
  106591. protected _useRGBColor: boolean;
  106592. /**
  106593. * Helps to directly use the maps channels instead of their level.
  106594. */
  106595. useRGBColor: boolean;
  106596. protected _enableNoise: boolean;
  106597. /**
  106598. * This helps reducing the banding effect that could occur on the background.
  106599. */
  106600. enableNoise: boolean;
  106601. /**
  106602. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  106603. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  106604. * Recommended to be keep at 1.0 except for special cases.
  106605. */
  106606. fovMultiplier: number;
  106607. private _fovMultiplier;
  106608. /**
  106609. * Enable the FOV adjustment feature controlled by fovMultiplier.
  106610. */
  106611. useEquirectangularFOV: boolean;
  106612. private _maxSimultaneousLights;
  106613. /**
  106614. * Number of Simultaneous lights allowed on the material.
  106615. */
  106616. maxSimultaneousLights: int;
  106617. /**
  106618. * Default configuration related to image processing available in the Background Material.
  106619. */
  106620. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  106621. /**
  106622. * Keep track of the image processing observer to allow dispose and replace.
  106623. */
  106624. private _imageProcessingObserver;
  106625. /**
  106626. * Attaches a new image processing configuration to the PBR Material.
  106627. * @param configuration (if null the scene configuration will be use)
  106628. */
  106629. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  106630. /**
  106631. * Gets the image processing configuration used either in this material.
  106632. */
  106633. /**
  106634. * Sets the Default image processing configuration used either in the this material.
  106635. *
  106636. * If sets to null, the scene one is in use.
  106637. */
  106638. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  106639. /**
  106640. * Gets wether the color curves effect is enabled.
  106641. */
  106642. /**
  106643. * Sets wether the color curves effect is enabled.
  106644. */
  106645. cameraColorCurvesEnabled: boolean;
  106646. /**
  106647. * Gets wether the color grading effect is enabled.
  106648. */
  106649. /**
  106650. * Gets wether the color grading effect is enabled.
  106651. */
  106652. cameraColorGradingEnabled: boolean;
  106653. /**
  106654. * Gets wether tonemapping is enabled or not.
  106655. */
  106656. /**
  106657. * Sets wether tonemapping is enabled or not
  106658. */
  106659. cameraToneMappingEnabled: boolean;
  106660. /**
  106661. * The camera exposure used on this material.
  106662. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106663. * This corresponds to a photographic exposure.
  106664. */
  106665. /**
  106666. * The camera exposure used on this material.
  106667. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  106668. * This corresponds to a photographic exposure.
  106669. */
  106670. cameraExposure: float;
  106671. /**
  106672. * Gets The camera contrast used on this material.
  106673. */
  106674. /**
  106675. * Sets The camera contrast used on this material.
  106676. */
  106677. cameraContrast: float;
  106678. /**
  106679. * Gets the Color Grading 2D Lookup Texture.
  106680. */
  106681. /**
  106682. * Sets the Color Grading 2D Lookup Texture.
  106683. */
  106684. cameraColorGradingTexture: Nullable<BaseTexture>;
  106685. /**
  106686. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106687. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106688. * 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;
  106689. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106690. */
  106691. /**
  106692. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  106693. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  106694. * 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;
  106695. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  106696. */
  106697. cameraColorCurves: Nullable<ColorCurves>;
  106698. /**
  106699. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  106700. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  106701. */
  106702. switchToBGR: boolean;
  106703. private _renderTargets;
  106704. private _reflectionControls;
  106705. private _white;
  106706. private _primaryShadowColor;
  106707. private _primaryHighlightColor;
  106708. /**
  106709. * Instantiates a Background Material in the given scene
  106710. * @param name The friendly name of the material
  106711. * @param scene The scene to add the material to
  106712. */
  106713. constructor(name: string, scene: Scene);
  106714. /**
  106715. * Gets a boolean indicating that current material needs to register RTT
  106716. */
  106717. readonly hasRenderTargetTextures: boolean;
  106718. /**
  106719. * The entire material has been created in order to prevent overdraw.
  106720. * @returns false
  106721. */
  106722. needAlphaTesting(): boolean;
  106723. /**
  106724. * The entire material has been created in order to prevent overdraw.
  106725. * @returns true if blending is enable
  106726. */
  106727. needAlphaBlending(): boolean;
  106728. /**
  106729. * Checks wether the material is ready to be rendered for a given mesh.
  106730. * @param mesh The mesh to render
  106731. * @param subMesh The submesh to check against
  106732. * @param useInstances Specify wether or not the material is used with instances
  106733. * @returns true if all the dependencies are ready (Textures, Effects...)
  106734. */
  106735. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  106736. /**
  106737. * Compute the primary color according to the chosen perceptual color.
  106738. */
  106739. private _computePrimaryColorFromPerceptualColor;
  106740. /**
  106741. * Compute the highlights and shadow colors according to their chosen levels.
  106742. */
  106743. private _computePrimaryColors;
  106744. /**
  106745. * Build the uniform buffer used in the material.
  106746. */
  106747. buildUniformLayout(): void;
  106748. /**
  106749. * Unbind the material.
  106750. */
  106751. unbind(): void;
  106752. /**
  106753. * Bind only the world matrix to the material.
  106754. * @param world The world matrix to bind.
  106755. */
  106756. bindOnlyWorldMatrix(world: Matrix): void;
  106757. /**
  106758. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  106759. * @param world The world matrix to bind.
  106760. * @param subMesh The submesh to bind for.
  106761. */
  106762. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  106763. /**
  106764. * Dispose the material.
  106765. * @param forceDisposeEffect Force disposal of the associated effect.
  106766. * @param forceDisposeTextures Force disposal of the associated textures.
  106767. */
  106768. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  106769. /**
  106770. * Clones the material.
  106771. * @param name The cloned name.
  106772. * @returns The cloned material.
  106773. */
  106774. clone(name: string): BackgroundMaterial;
  106775. /**
  106776. * Serializes the current material to its JSON representation.
  106777. * @returns The JSON representation.
  106778. */
  106779. serialize(): any;
  106780. /**
  106781. * Gets the class name of the material
  106782. * @returns "BackgroundMaterial"
  106783. */
  106784. getClassName(): string;
  106785. /**
  106786. * Parse a JSON input to create back a background material.
  106787. * @param source The JSON data to parse
  106788. * @param scene The scene to create the parsed material in
  106789. * @param rootUrl The root url of the assets the material depends upon
  106790. * @returns the instantiated BackgroundMaterial.
  106791. */
  106792. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  106793. }
  106794. }
  106795. declare module BABYLON {
  106796. /**
  106797. * Represents the different options available during the creation of
  106798. * a Environment helper.
  106799. *
  106800. * This can control the default ground, skybox and image processing setup of your scene.
  106801. */
  106802. export interface IEnvironmentHelperOptions {
  106803. /**
  106804. * Specifies wether or not to create a ground.
  106805. * True by default.
  106806. */
  106807. createGround: boolean;
  106808. /**
  106809. * Specifies the ground size.
  106810. * 15 by default.
  106811. */
  106812. groundSize: number;
  106813. /**
  106814. * The texture used on the ground for the main color.
  106815. * Comes from the BabylonJS CDN by default.
  106816. *
  106817. * Remarks: Can be either a texture or a url.
  106818. */
  106819. groundTexture: string | BaseTexture;
  106820. /**
  106821. * The color mixed in the ground texture by default.
  106822. * BabylonJS clearColor by default.
  106823. */
  106824. groundColor: Color3;
  106825. /**
  106826. * Specifies the ground opacity.
  106827. * 1 by default.
  106828. */
  106829. groundOpacity: number;
  106830. /**
  106831. * Enables the ground to receive shadows.
  106832. * True by default.
  106833. */
  106834. enableGroundShadow: boolean;
  106835. /**
  106836. * Helps preventing the shadow to be fully black on the ground.
  106837. * 0.5 by default.
  106838. */
  106839. groundShadowLevel: number;
  106840. /**
  106841. * Creates a mirror texture attach to the ground.
  106842. * false by default.
  106843. */
  106844. enableGroundMirror: boolean;
  106845. /**
  106846. * Specifies the ground mirror size ratio.
  106847. * 0.3 by default as the default kernel is 64.
  106848. */
  106849. groundMirrorSizeRatio: number;
  106850. /**
  106851. * Specifies the ground mirror blur kernel size.
  106852. * 64 by default.
  106853. */
  106854. groundMirrorBlurKernel: number;
  106855. /**
  106856. * Specifies the ground mirror visibility amount.
  106857. * 1 by default
  106858. */
  106859. groundMirrorAmount: number;
  106860. /**
  106861. * Specifies the ground mirror reflectance weight.
  106862. * This uses the standard weight of the background material to setup the fresnel effect
  106863. * of the mirror.
  106864. * 1 by default.
  106865. */
  106866. groundMirrorFresnelWeight: number;
  106867. /**
  106868. * Specifies the ground mirror Falloff distance.
  106869. * This can helps reducing the size of the reflection.
  106870. * 0 by Default.
  106871. */
  106872. groundMirrorFallOffDistance: number;
  106873. /**
  106874. * Specifies the ground mirror texture type.
  106875. * Unsigned Int by Default.
  106876. */
  106877. groundMirrorTextureType: number;
  106878. /**
  106879. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  106880. * the shown objects.
  106881. */
  106882. groundYBias: number;
  106883. /**
  106884. * Specifies wether or not to create a skybox.
  106885. * True by default.
  106886. */
  106887. createSkybox: boolean;
  106888. /**
  106889. * Specifies the skybox size.
  106890. * 20 by default.
  106891. */
  106892. skyboxSize: number;
  106893. /**
  106894. * The texture used on the skybox for the main color.
  106895. * Comes from the BabylonJS CDN by default.
  106896. *
  106897. * Remarks: Can be either a texture or a url.
  106898. */
  106899. skyboxTexture: string | BaseTexture;
  106900. /**
  106901. * The color mixed in the skybox texture by default.
  106902. * BabylonJS clearColor by default.
  106903. */
  106904. skyboxColor: Color3;
  106905. /**
  106906. * The background rotation around the Y axis of the scene.
  106907. * This helps aligning the key lights of your scene with the background.
  106908. * 0 by default.
  106909. */
  106910. backgroundYRotation: number;
  106911. /**
  106912. * Compute automatically the size of the elements to best fit with the scene.
  106913. */
  106914. sizeAuto: boolean;
  106915. /**
  106916. * Default position of the rootMesh if autoSize is not true.
  106917. */
  106918. rootPosition: Vector3;
  106919. /**
  106920. * Sets up the image processing in the scene.
  106921. * true by default.
  106922. */
  106923. setupImageProcessing: boolean;
  106924. /**
  106925. * The texture used as your environment texture in the scene.
  106926. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  106927. *
  106928. * Remarks: Can be either a texture or a url.
  106929. */
  106930. environmentTexture: string | BaseTexture;
  106931. /**
  106932. * The value of the exposure to apply to the scene.
  106933. * 0.6 by default if setupImageProcessing is true.
  106934. */
  106935. cameraExposure: number;
  106936. /**
  106937. * The value of the contrast to apply to the scene.
  106938. * 1.6 by default if setupImageProcessing is true.
  106939. */
  106940. cameraContrast: number;
  106941. /**
  106942. * Specifies wether or not tonemapping should be enabled in the scene.
  106943. * true by default if setupImageProcessing is true.
  106944. */
  106945. toneMappingEnabled: boolean;
  106946. }
  106947. /**
  106948. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  106949. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  106950. * It also helps with the default setup of your imageProcessing configuration.
  106951. */
  106952. export class EnvironmentHelper {
  106953. /**
  106954. * Default ground texture URL.
  106955. */
  106956. private static _groundTextureCDNUrl;
  106957. /**
  106958. * Default skybox texture URL.
  106959. */
  106960. private static _skyboxTextureCDNUrl;
  106961. /**
  106962. * Default environment texture URL.
  106963. */
  106964. private static _environmentTextureCDNUrl;
  106965. /**
  106966. * Creates the default options for the helper.
  106967. */
  106968. private static _getDefaultOptions;
  106969. private _rootMesh;
  106970. /**
  106971. * Gets the root mesh created by the helper.
  106972. */
  106973. readonly rootMesh: Mesh;
  106974. private _skybox;
  106975. /**
  106976. * Gets the skybox created by the helper.
  106977. */
  106978. readonly skybox: Nullable<Mesh>;
  106979. private _skyboxTexture;
  106980. /**
  106981. * Gets the skybox texture created by the helper.
  106982. */
  106983. readonly skyboxTexture: Nullable<BaseTexture>;
  106984. private _skyboxMaterial;
  106985. /**
  106986. * Gets the skybox material created by the helper.
  106987. */
  106988. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  106989. private _ground;
  106990. /**
  106991. * Gets the ground mesh created by the helper.
  106992. */
  106993. readonly ground: Nullable<Mesh>;
  106994. private _groundTexture;
  106995. /**
  106996. * Gets the ground texture created by the helper.
  106997. */
  106998. readonly groundTexture: Nullable<BaseTexture>;
  106999. private _groundMirror;
  107000. /**
  107001. * Gets the ground mirror created by the helper.
  107002. */
  107003. readonly groundMirror: Nullable<MirrorTexture>;
  107004. /**
  107005. * Gets the ground mirror render list to helps pushing the meshes
  107006. * you wish in the ground reflection.
  107007. */
  107008. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  107009. private _groundMaterial;
  107010. /**
  107011. * Gets the ground material created by the helper.
  107012. */
  107013. readonly groundMaterial: Nullable<BackgroundMaterial>;
  107014. /**
  107015. * Stores the creation options.
  107016. */
  107017. private readonly _scene;
  107018. private _options;
  107019. /**
  107020. * This observable will be notified with any error during the creation of the environment,
  107021. * mainly texture creation errors.
  107022. */
  107023. onErrorObservable: Observable<{
  107024. message?: string;
  107025. exception?: any;
  107026. }>;
  107027. /**
  107028. * constructor
  107029. * @param options Defines the options we want to customize the helper
  107030. * @param scene The scene to add the material to
  107031. */
  107032. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  107033. /**
  107034. * Updates the background according to the new options
  107035. * @param options
  107036. */
  107037. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  107038. /**
  107039. * Sets the primary color of all the available elements.
  107040. * @param color the main color to affect to the ground and the background
  107041. */
  107042. setMainColor(color: Color3): void;
  107043. /**
  107044. * Setup the image processing according to the specified options.
  107045. */
  107046. private _setupImageProcessing;
  107047. /**
  107048. * Setup the environment texture according to the specified options.
  107049. */
  107050. private _setupEnvironmentTexture;
  107051. /**
  107052. * Setup the background according to the specified options.
  107053. */
  107054. private _setupBackground;
  107055. /**
  107056. * Get the scene sizes according to the setup.
  107057. */
  107058. private _getSceneSize;
  107059. /**
  107060. * Setup the ground according to the specified options.
  107061. */
  107062. private _setupGround;
  107063. /**
  107064. * Setup the ground material according to the specified options.
  107065. */
  107066. private _setupGroundMaterial;
  107067. /**
  107068. * Setup the ground diffuse texture according to the specified options.
  107069. */
  107070. private _setupGroundDiffuseTexture;
  107071. /**
  107072. * Setup the ground mirror texture according to the specified options.
  107073. */
  107074. private _setupGroundMirrorTexture;
  107075. /**
  107076. * Setup the ground to receive the mirror texture.
  107077. */
  107078. private _setupMirrorInGroundMaterial;
  107079. /**
  107080. * Setup the skybox according to the specified options.
  107081. */
  107082. private _setupSkybox;
  107083. /**
  107084. * Setup the skybox material according to the specified options.
  107085. */
  107086. private _setupSkyboxMaterial;
  107087. /**
  107088. * Setup the skybox reflection texture according to the specified options.
  107089. */
  107090. private _setupSkyboxReflectionTexture;
  107091. private _errorHandler;
  107092. /**
  107093. * Dispose all the elements created by the Helper.
  107094. */
  107095. dispose(): void;
  107096. }
  107097. }
  107098. declare module BABYLON {
  107099. /**
  107100. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  107101. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  107102. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  107103. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  107104. */
  107105. export class PhotoDome extends TransformNode {
  107106. /**
  107107. * Define the image as a Monoscopic panoramic 360 image.
  107108. */
  107109. static readonly MODE_MONOSCOPIC: number;
  107110. /**
  107111. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  107112. */
  107113. static readonly MODE_TOPBOTTOM: number;
  107114. /**
  107115. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  107116. */
  107117. static readonly MODE_SIDEBYSIDE: number;
  107118. private _useDirectMapping;
  107119. /**
  107120. * The texture being displayed on the sphere
  107121. */
  107122. protected _photoTexture: Texture;
  107123. /**
  107124. * Gets or sets the texture being displayed on the sphere
  107125. */
  107126. photoTexture: Texture;
  107127. /**
  107128. * Observable raised when an error occured while loading the 360 image
  107129. */
  107130. onLoadErrorObservable: Observable<string>;
  107131. /**
  107132. * The skybox material
  107133. */
  107134. protected _material: BackgroundMaterial;
  107135. /**
  107136. * The surface used for the skybox
  107137. */
  107138. protected _mesh: Mesh;
  107139. /**
  107140. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  107141. * Also see the options.resolution property.
  107142. */
  107143. fovMultiplier: number;
  107144. private _imageMode;
  107145. /**
  107146. * Gets or set the current video mode for the video. It can be:
  107147. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  107148. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  107149. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  107150. */
  107151. imageMode: number;
  107152. /**
  107153. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  107154. * @param name Element's name, child elements will append suffixes for their own names.
  107155. * @param urlsOfPhoto defines the url of the photo to display
  107156. * @param options defines an object containing optional or exposed sub element properties
  107157. * @param onError defines a callback called when an error occured while loading the texture
  107158. */
  107159. constructor(name: string, urlOfPhoto: string, options: {
  107160. resolution?: number;
  107161. size?: number;
  107162. useDirectMapping?: boolean;
  107163. faceForward?: boolean;
  107164. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  107165. private _onBeforeCameraRenderObserver;
  107166. private _changeImageMode;
  107167. /**
  107168. * Releases resources associated with this node.
  107169. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  107170. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  107171. */
  107172. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  107173. }
  107174. }
  107175. declare module BABYLON {
  107176. /** @hidden */
  107177. export var rgbdDecodePixelShader: {
  107178. name: string;
  107179. shader: string;
  107180. };
  107181. }
  107182. declare module BABYLON {
  107183. /**
  107184. * Class used to host texture specific utilities
  107185. */
  107186. export class BRDFTextureTools {
  107187. /**
  107188. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  107189. * @param texture the texture to expand.
  107190. */
  107191. private static _ExpandDefaultBRDFTexture;
  107192. /**
  107193. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  107194. * @param scene defines the hosting scene
  107195. * @returns the environment BRDF texture
  107196. */
  107197. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  107198. private static _environmentBRDFBase64Texture;
  107199. }
  107200. }
  107201. declare module BABYLON {
  107202. /**
  107203. * @hidden
  107204. */
  107205. export interface IMaterialClearCoatDefines {
  107206. CLEARCOAT: boolean;
  107207. CLEARCOAT_DEFAULTIOR: boolean;
  107208. CLEARCOAT_TEXTURE: boolean;
  107209. CLEARCOAT_TEXTUREDIRECTUV: number;
  107210. CLEARCOAT_BUMP: boolean;
  107211. CLEARCOAT_BUMPDIRECTUV: number;
  107212. CLEARCOAT_TINT: boolean;
  107213. CLEARCOAT_TINT_TEXTURE: boolean;
  107214. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  107215. /** @hidden */
  107216. _areTexturesDirty: boolean;
  107217. }
  107218. /**
  107219. * Define the code related to the clear coat parameters of the pbr material.
  107220. */
  107221. export class PBRClearCoatConfiguration {
  107222. /**
  107223. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  107224. * The default fits with a polyurethane material.
  107225. */
  107226. private static readonly _DefaultIndexOfRefraction;
  107227. private _isEnabled;
  107228. /**
  107229. * Defines if the clear coat is enabled in the material.
  107230. */
  107231. isEnabled: boolean;
  107232. /**
  107233. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  107234. */
  107235. intensity: number;
  107236. /**
  107237. * Defines the clear coat layer roughness.
  107238. */
  107239. roughness: number;
  107240. private _indexOfRefraction;
  107241. /**
  107242. * Defines the index of refraction of the clear coat.
  107243. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  107244. * The default fits with a polyurethane material.
  107245. * Changing the default value is more performance intensive.
  107246. */
  107247. indexOfRefraction: number;
  107248. private _texture;
  107249. /**
  107250. * Stores the clear coat values in a texture.
  107251. */
  107252. texture: Nullable<BaseTexture>;
  107253. private _bumpTexture;
  107254. /**
  107255. * Define the clear coat specific bump texture.
  107256. */
  107257. bumpTexture: Nullable<BaseTexture>;
  107258. private _isTintEnabled;
  107259. /**
  107260. * Defines if the clear coat tint is enabled in the material.
  107261. */
  107262. isTintEnabled: boolean;
  107263. /**
  107264. * Defines the clear coat tint of the material.
  107265. * This is only use if tint is enabled
  107266. */
  107267. tintColor: Color3;
  107268. /**
  107269. * Defines the distance at which the tint color should be found in the
  107270. * clear coat media.
  107271. * This is only use if tint is enabled
  107272. */
  107273. tintColorAtDistance: number;
  107274. /**
  107275. * Defines the clear coat layer thickness.
  107276. * This is only use if tint is enabled
  107277. */
  107278. tintThickness: number;
  107279. private _tintTexture;
  107280. /**
  107281. * Stores the clear tint values in a texture.
  107282. * rgb is tint
  107283. * a is a thickness factor
  107284. */
  107285. tintTexture: Nullable<BaseTexture>;
  107286. /** @hidden */
  107287. private _internalMarkAllSubMeshesAsTexturesDirty;
  107288. /** @hidden */
  107289. _markAllSubMeshesAsTexturesDirty(): void;
  107290. /**
  107291. * Instantiate a new istance of clear coat configuration.
  107292. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107293. */
  107294. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107295. /**
  107296. * Gets wehter the submesh is ready to be used or not.
  107297. * @param defines the list of "defines" to update.
  107298. * @param scene defines the scene the material belongs to.
  107299. * @param engine defines the engine the material belongs to.
  107300. * @param disableBumpMap defines wether the material disables bump or not.
  107301. * @returns - boolean indicating that the submesh is ready or not.
  107302. */
  107303. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  107304. /**
  107305. * Checks to see if a texture is used in the material.
  107306. * @param defines the list of "defines" to update.
  107307. * @param scene defines the scene to the material belongs to.
  107308. */
  107309. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  107310. /**
  107311. * Binds the material data.
  107312. * @param uniformBuffer defines the Uniform buffer to fill in.
  107313. * @param scene defines the scene the material belongs to.
  107314. * @param engine defines the engine the material belongs to.
  107315. * @param disableBumpMap defines wether the material disables bump or not.
  107316. * @param isFrozen defines wether the material is frozen or not.
  107317. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  107318. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  107319. */
  107320. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  107321. /**
  107322. * Checks to see if a texture is used in the material.
  107323. * @param texture - Base texture to use.
  107324. * @returns - Boolean specifying if a texture is used in the material.
  107325. */
  107326. hasTexture(texture: BaseTexture): boolean;
  107327. /**
  107328. * Returns an array of the actively used textures.
  107329. * @param activeTextures Array of BaseTextures
  107330. */
  107331. getActiveTextures(activeTextures: BaseTexture[]): void;
  107332. /**
  107333. * Returns the animatable textures.
  107334. * @param animatables Array of animatable textures.
  107335. */
  107336. getAnimatables(animatables: IAnimatable[]): void;
  107337. /**
  107338. * Disposes the resources of the material.
  107339. * @param forceDisposeTextures - Forces the disposal of all textures.
  107340. */
  107341. dispose(forceDisposeTextures?: boolean): void;
  107342. /**
  107343. * Get the current class name of the texture useful for serialization or dynamic coding.
  107344. * @returns "PBRClearCoatConfiguration"
  107345. */
  107346. getClassName(): string;
  107347. /**
  107348. * Add fallbacks to the effect fallbacks list.
  107349. * @param defines defines the Base texture to use.
  107350. * @param fallbacks defines the current fallback list.
  107351. * @param currentRank defines the current fallback rank.
  107352. * @returns the new fallback rank.
  107353. */
  107354. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107355. /**
  107356. * Add the required uniforms to the current list.
  107357. * @param uniforms defines the current uniform list.
  107358. */
  107359. static AddUniforms(uniforms: string[]): void;
  107360. /**
  107361. * Add the required samplers to the current list.
  107362. * @param samplers defines the current sampler list.
  107363. */
  107364. static AddSamplers(samplers: string[]): void;
  107365. /**
  107366. * Add the required uniforms to the current buffer.
  107367. * @param uniformBuffer defines the current uniform buffer.
  107368. */
  107369. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107370. /**
  107371. * Makes a duplicate of the current configuration into another one.
  107372. * @param clearCoatConfiguration define the config where to copy the info
  107373. */
  107374. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  107375. /**
  107376. * Serializes this clear coat configuration.
  107377. * @returns - An object with the serialized config.
  107378. */
  107379. serialize(): any;
  107380. /**
  107381. * Parses a anisotropy Configuration from a serialized object.
  107382. * @param source - Serialized object.
  107383. * @param scene Defines the scene we are parsing for
  107384. * @param rootUrl Defines the rootUrl to load from
  107385. */
  107386. parse(source: any, scene: Scene, rootUrl: string): void;
  107387. }
  107388. }
  107389. declare module BABYLON {
  107390. /**
  107391. * @hidden
  107392. */
  107393. export interface IMaterialAnisotropicDefines {
  107394. ANISOTROPIC: boolean;
  107395. ANISOTROPIC_TEXTURE: boolean;
  107396. ANISOTROPIC_TEXTUREDIRECTUV: number;
  107397. MAINUV1: boolean;
  107398. _areTexturesDirty: boolean;
  107399. _needUVs: boolean;
  107400. }
  107401. /**
  107402. * Define the code related to the anisotropic parameters of the pbr material.
  107403. */
  107404. export class PBRAnisotropicConfiguration {
  107405. private _isEnabled;
  107406. /**
  107407. * Defines if the anisotropy is enabled in the material.
  107408. */
  107409. isEnabled: boolean;
  107410. /**
  107411. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  107412. */
  107413. intensity: number;
  107414. /**
  107415. * Defines if the effect is along the tangents, bitangents or in between.
  107416. * By default, the effect is "strectching" the highlights along the tangents.
  107417. */
  107418. direction: Vector2;
  107419. private _texture;
  107420. /**
  107421. * Stores the anisotropy values in a texture.
  107422. * rg is direction (like normal from -1 to 1)
  107423. * b is a intensity
  107424. */
  107425. texture: Nullable<BaseTexture>;
  107426. /** @hidden */
  107427. private _internalMarkAllSubMeshesAsTexturesDirty;
  107428. /** @hidden */
  107429. _markAllSubMeshesAsTexturesDirty(): void;
  107430. /**
  107431. * Instantiate a new istance of anisotropy configuration.
  107432. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107433. */
  107434. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107435. /**
  107436. * Specifies that the submesh is ready to be used.
  107437. * @param defines the list of "defines" to update.
  107438. * @param scene defines the scene the material belongs to.
  107439. * @returns - boolean indicating that the submesh is ready or not.
  107440. */
  107441. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  107442. /**
  107443. * Checks to see if a texture is used in the material.
  107444. * @param defines the list of "defines" to update.
  107445. * @param mesh the mesh we are preparing the defines for.
  107446. * @param scene defines the scene the material belongs to.
  107447. */
  107448. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  107449. /**
  107450. * Binds the material data.
  107451. * @param uniformBuffer defines the Uniform buffer to fill in.
  107452. * @param scene defines the scene the material belongs to.
  107453. * @param isFrozen defines wether the material is frozen or not.
  107454. */
  107455. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  107456. /**
  107457. * Checks to see if a texture is used in the material.
  107458. * @param texture - Base texture to use.
  107459. * @returns - Boolean specifying if a texture is used in the material.
  107460. */
  107461. hasTexture(texture: BaseTexture): boolean;
  107462. /**
  107463. * Returns an array of the actively used textures.
  107464. * @param activeTextures Array of BaseTextures
  107465. */
  107466. getActiveTextures(activeTextures: BaseTexture[]): void;
  107467. /**
  107468. * Returns the animatable textures.
  107469. * @param animatables Array of animatable textures.
  107470. */
  107471. getAnimatables(animatables: IAnimatable[]): void;
  107472. /**
  107473. * Disposes the resources of the material.
  107474. * @param forceDisposeTextures - Forces the disposal of all textures.
  107475. */
  107476. dispose(forceDisposeTextures?: boolean): void;
  107477. /**
  107478. * Get the current class name of the texture useful for serialization or dynamic coding.
  107479. * @returns "PBRAnisotropicConfiguration"
  107480. */
  107481. getClassName(): string;
  107482. /**
  107483. * Add fallbacks to the effect fallbacks list.
  107484. * @param defines defines the Base texture to use.
  107485. * @param fallbacks defines the current fallback list.
  107486. * @param currentRank defines the current fallback rank.
  107487. * @returns the new fallback rank.
  107488. */
  107489. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107490. /**
  107491. * Add the required uniforms to the current list.
  107492. * @param uniforms defines the current uniform list.
  107493. */
  107494. static AddUniforms(uniforms: string[]): void;
  107495. /**
  107496. * Add the required uniforms to the current buffer.
  107497. * @param uniformBuffer defines the current uniform buffer.
  107498. */
  107499. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107500. /**
  107501. * Add the required samplers to the current list.
  107502. * @param samplers defines the current sampler list.
  107503. */
  107504. static AddSamplers(samplers: string[]): void;
  107505. /**
  107506. * Makes a duplicate of the current configuration into another one.
  107507. * @param anisotropicConfiguration define the config where to copy the info
  107508. */
  107509. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  107510. /**
  107511. * Serializes this anisotropy configuration.
  107512. * @returns - An object with the serialized config.
  107513. */
  107514. serialize(): any;
  107515. /**
  107516. * Parses a anisotropy Configuration from a serialized object.
  107517. * @param source - Serialized object.
  107518. * @param scene Defines the scene we are parsing for
  107519. * @param rootUrl Defines the rootUrl to load from
  107520. */
  107521. parse(source: any, scene: Scene, rootUrl: string): void;
  107522. }
  107523. }
  107524. declare module BABYLON {
  107525. /**
  107526. * @hidden
  107527. */
  107528. export interface IMaterialBRDFDefines {
  107529. BRDF_V_HEIGHT_CORRELATED: boolean;
  107530. MS_BRDF_ENERGY_CONSERVATION: boolean;
  107531. SPHERICAL_HARMONICS: boolean;
  107532. /** @hidden */
  107533. _areMiscDirty: boolean;
  107534. }
  107535. /**
  107536. * Define the code related to the BRDF parameters of the pbr material.
  107537. */
  107538. export class PBRBRDFConfiguration {
  107539. /**
  107540. * Default value used for the energy conservation.
  107541. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  107542. */
  107543. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  107544. /**
  107545. * Default value used for the Smith Visibility Height Correlated mode.
  107546. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  107547. */
  107548. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  107549. /**
  107550. * Default value used for the IBL diffuse part.
  107551. * This can help switching back to the polynomials mode globally which is a tiny bit
  107552. * less GPU intensive at the drawback of a lower quality.
  107553. */
  107554. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  107555. private _useEnergyConservation;
  107556. /**
  107557. * Defines if the material uses energy conservation.
  107558. */
  107559. useEnergyConservation: boolean;
  107560. private _useSmithVisibilityHeightCorrelated;
  107561. /**
  107562. * LEGACY Mode set to false
  107563. * Defines if the material uses height smith correlated visibility term.
  107564. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  107565. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  107566. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  107567. * Not relying on height correlated will also disable energy conservation.
  107568. */
  107569. useSmithVisibilityHeightCorrelated: boolean;
  107570. private _useSphericalHarmonics;
  107571. /**
  107572. * LEGACY Mode set to false
  107573. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  107574. * diffuse part of the IBL.
  107575. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  107576. * to the ground truth.
  107577. */
  107578. useSphericalHarmonics: boolean;
  107579. /** @hidden */
  107580. private _internalMarkAllSubMeshesAsMiscDirty;
  107581. /** @hidden */
  107582. _markAllSubMeshesAsMiscDirty(): void;
  107583. /**
  107584. * Instantiate a new istance of clear coat configuration.
  107585. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  107586. */
  107587. constructor(markAllSubMeshesAsMiscDirty: () => void);
  107588. /**
  107589. * Checks to see if a texture is used in the material.
  107590. * @param defines the list of "defines" to update.
  107591. */
  107592. prepareDefines(defines: IMaterialBRDFDefines): void;
  107593. /**
  107594. * Get the current class name of the texture useful for serialization or dynamic coding.
  107595. * @returns "PBRClearCoatConfiguration"
  107596. */
  107597. getClassName(): string;
  107598. /**
  107599. * Makes a duplicate of the current configuration into another one.
  107600. * @param brdfConfiguration define the config where to copy the info
  107601. */
  107602. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  107603. /**
  107604. * Serializes this BRDF configuration.
  107605. * @returns - An object with the serialized config.
  107606. */
  107607. serialize(): any;
  107608. /**
  107609. * Parses a anisotropy Configuration from a serialized object.
  107610. * @param source - Serialized object.
  107611. * @param scene Defines the scene we are parsing for
  107612. * @param rootUrl Defines the rootUrl to load from
  107613. */
  107614. parse(source: any, scene: Scene, rootUrl: string): void;
  107615. }
  107616. }
  107617. declare module BABYLON {
  107618. /**
  107619. * @hidden
  107620. */
  107621. export interface IMaterialSheenDefines {
  107622. SHEEN: boolean;
  107623. SHEEN_TEXTURE: boolean;
  107624. SHEEN_TEXTUREDIRECTUV: number;
  107625. SHEEN_LINKWITHALBEDO: boolean;
  107626. /** @hidden */
  107627. _areTexturesDirty: boolean;
  107628. }
  107629. /**
  107630. * Define the code related to the Sheen parameters of the pbr material.
  107631. */
  107632. export class PBRSheenConfiguration {
  107633. private _isEnabled;
  107634. /**
  107635. * Defines if the material uses sheen.
  107636. */
  107637. isEnabled: boolean;
  107638. private _linkSheenWithAlbedo;
  107639. /**
  107640. * Defines if the sheen is linked to the sheen color.
  107641. */
  107642. linkSheenWithAlbedo: boolean;
  107643. /**
  107644. * Defines the sheen intensity.
  107645. */
  107646. intensity: number;
  107647. /**
  107648. * Defines the sheen color.
  107649. */
  107650. color: Color3;
  107651. private _texture;
  107652. /**
  107653. * Stores the sheen tint values in a texture.
  107654. * rgb is tint
  107655. * a is a intensity
  107656. */
  107657. texture: Nullable<BaseTexture>;
  107658. /** @hidden */
  107659. private _internalMarkAllSubMeshesAsTexturesDirty;
  107660. /** @hidden */
  107661. _markAllSubMeshesAsTexturesDirty(): void;
  107662. /**
  107663. * Instantiate a new istance of clear coat configuration.
  107664. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107665. */
  107666. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107667. /**
  107668. * Specifies that the submesh is ready to be used.
  107669. * @param defines the list of "defines" to update.
  107670. * @param scene defines the scene the material belongs to.
  107671. * @returns - boolean indicating that the submesh is ready or not.
  107672. */
  107673. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  107674. /**
  107675. * Checks to see if a texture is used in the material.
  107676. * @param defines the list of "defines" to update.
  107677. * @param scene defines the scene the material belongs to.
  107678. */
  107679. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  107680. /**
  107681. * Binds the material data.
  107682. * @param uniformBuffer defines the Uniform buffer to fill in.
  107683. * @param scene defines the scene the material belongs to.
  107684. * @param isFrozen defines wether the material is frozen or not.
  107685. */
  107686. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  107687. /**
  107688. * Checks to see if a texture is used in the material.
  107689. * @param texture - Base texture to use.
  107690. * @returns - Boolean specifying if a texture is used in the material.
  107691. */
  107692. hasTexture(texture: BaseTexture): boolean;
  107693. /**
  107694. * Returns an array of the actively used textures.
  107695. * @param activeTextures Array of BaseTextures
  107696. */
  107697. getActiveTextures(activeTextures: BaseTexture[]): void;
  107698. /**
  107699. * Returns the animatable textures.
  107700. * @param animatables Array of animatable textures.
  107701. */
  107702. getAnimatables(animatables: IAnimatable[]): void;
  107703. /**
  107704. * Disposes the resources of the material.
  107705. * @param forceDisposeTextures - Forces the disposal of all textures.
  107706. */
  107707. dispose(forceDisposeTextures?: boolean): void;
  107708. /**
  107709. * Get the current class name of the texture useful for serialization or dynamic coding.
  107710. * @returns "PBRSheenConfiguration"
  107711. */
  107712. getClassName(): string;
  107713. /**
  107714. * Add fallbacks to the effect fallbacks list.
  107715. * @param defines defines the Base texture to use.
  107716. * @param fallbacks defines the current fallback list.
  107717. * @param currentRank defines the current fallback rank.
  107718. * @returns the new fallback rank.
  107719. */
  107720. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107721. /**
  107722. * Add the required uniforms to the current list.
  107723. * @param uniforms defines the current uniform list.
  107724. */
  107725. static AddUniforms(uniforms: string[]): void;
  107726. /**
  107727. * Add the required uniforms to the current buffer.
  107728. * @param uniformBuffer defines the current uniform buffer.
  107729. */
  107730. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107731. /**
  107732. * Add the required samplers to the current list.
  107733. * @param samplers defines the current sampler list.
  107734. */
  107735. static AddSamplers(samplers: string[]): void;
  107736. /**
  107737. * Makes a duplicate of the current configuration into another one.
  107738. * @param sheenConfiguration define the config where to copy the info
  107739. */
  107740. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  107741. /**
  107742. * Serializes this BRDF configuration.
  107743. * @returns - An object with the serialized config.
  107744. */
  107745. serialize(): any;
  107746. /**
  107747. * Parses a anisotropy Configuration from a serialized object.
  107748. * @param source - Serialized object.
  107749. * @param scene Defines the scene we are parsing for
  107750. * @param rootUrl Defines the rootUrl to load from
  107751. */
  107752. parse(source: any, scene: Scene, rootUrl: string): void;
  107753. }
  107754. }
  107755. declare module BABYLON {
  107756. /**
  107757. * @hidden
  107758. */
  107759. export interface IMaterialSubSurfaceDefines {
  107760. SUBSURFACE: boolean;
  107761. SS_REFRACTION: boolean;
  107762. SS_TRANSLUCENCY: boolean;
  107763. SS_SCATERRING: boolean;
  107764. SS_THICKNESSANDMASK_TEXTURE: boolean;
  107765. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  107766. SS_REFRACTIONMAP_3D: boolean;
  107767. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  107768. SS_LODINREFRACTIONALPHA: boolean;
  107769. SS_GAMMAREFRACTION: boolean;
  107770. SS_RGBDREFRACTION: boolean;
  107771. SS_LINEARSPECULARREFRACTION: boolean;
  107772. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  107773. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  107774. /** @hidden */
  107775. _areTexturesDirty: boolean;
  107776. }
  107777. /**
  107778. * Define the code related to the sub surface parameters of the pbr material.
  107779. */
  107780. export class PBRSubSurfaceConfiguration {
  107781. private _isRefractionEnabled;
  107782. /**
  107783. * Defines if the refraction is enabled in the material.
  107784. */
  107785. isRefractionEnabled: boolean;
  107786. private _isTranslucencyEnabled;
  107787. /**
  107788. * Defines if the translucency is enabled in the material.
  107789. */
  107790. isTranslucencyEnabled: boolean;
  107791. private _isScatteringEnabled;
  107792. /**
  107793. * Defines the refraction intensity of the material.
  107794. * The refraction when enabled replaces the Diffuse part of the material.
  107795. * The intensity helps transitionning between diffuse and refraction.
  107796. */
  107797. refractionIntensity: number;
  107798. /**
  107799. * Defines the translucency intensity of the material.
  107800. * When translucency has been enabled, this defines how much of the "translucency"
  107801. * is addded to the diffuse part of the material.
  107802. */
  107803. translucencyIntensity: number;
  107804. /**
  107805. * Defines the scattering intensity of the material.
  107806. * When scattering has been enabled, this defines how much of the "scattered light"
  107807. * is addded to the diffuse part of the material.
  107808. */
  107809. scatteringIntensity: number;
  107810. private _thicknessTexture;
  107811. /**
  107812. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  107813. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  107814. * 0 would mean minimumThickness
  107815. * 1 would mean maximumThickness
  107816. * The other channels might be use as a mask to vary the different effects intensity.
  107817. */
  107818. thicknessTexture: Nullable<BaseTexture>;
  107819. private _refractionTexture;
  107820. /**
  107821. * Defines the texture to use for refraction.
  107822. */
  107823. refractionTexture: Nullable<BaseTexture>;
  107824. private _indexOfRefraction;
  107825. /**
  107826. * Defines the index of refraction used in the material.
  107827. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  107828. */
  107829. indexOfRefraction: number;
  107830. private _invertRefractionY;
  107831. /**
  107832. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  107833. */
  107834. invertRefractionY: boolean;
  107835. private _linkRefractionWithTransparency;
  107836. /**
  107837. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  107838. * Materials half opaque for instance using refraction could benefit from this control.
  107839. */
  107840. linkRefractionWithTransparency: boolean;
  107841. /**
  107842. * Defines the minimum thickness stored in the thickness map.
  107843. * If no thickness map is defined, this value will be used to simulate thickness.
  107844. */
  107845. minimumThickness: number;
  107846. /**
  107847. * Defines the maximum thickness stored in the thickness map.
  107848. */
  107849. maximumThickness: number;
  107850. /**
  107851. * Defines the volume tint of the material.
  107852. * This is used for both translucency and scattering.
  107853. */
  107854. tintColor: Color3;
  107855. /**
  107856. * Defines the distance at which the tint color should be found in the media.
  107857. * This is used for refraction only.
  107858. */
  107859. tintColorAtDistance: number;
  107860. /**
  107861. * Defines how far each channel transmit through the media.
  107862. * It is defined as a color to simplify it selection.
  107863. */
  107864. diffusionDistance: Color3;
  107865. private _useMaskFromThicknessTexture;
  107866. /**
  107867. * Stores the intensity of the different subsurface effects in the thickness texture.
  107868. * * the green channel is the translucency intensity.
  107869. * * the blue channel is the scattering intensity.
  107870. * * the alpha channel is the refraction intensity.
  107871. */
  107872. useMaskFromThicknessTexture: boolean;
  107873. /** @hidden */
  107874. private _internalMarkAllSubMeshesAsTexturesDirty;
  107875. /** @hidden */
  107876. _markAllSubMeshesAsTexturesDirty(): void;
  107877. /**
  107878. * Instantiate a new istance of sub surface configuration.
  107879. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107880. */
  107881. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107882. /**
  107883. * Gets wehter the submesh is ready to be used or not.
  107884. * @param defines the list of "defines" to update.
  107885. * @param scene defines the scene the material belongs to.
  107886. * @returns - boolean indicating that the submesh is ready or not.
  107887. */
  107888. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  107889. /**
  107890. * Checks to see if a texture is used in the material.
  107891. * @param defines the list of "defines" to update.
  107892. * @param scene defines the scene to the material belongs to.
  107893. */
  107894. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  107895. /**
  107896. * Binds the material data.
  107897. * @param uniformBuffer defines the Uniform buffer to fill in.
  107898. * @param scene defines the scene the material belongs to.
  107899. * @param engine defines the engine the material belongs to.
  107900. * @param isFrozen defines wether the material is frozen or not.
  107901. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  107902. */
  107903. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  107904. /**
  107905. * Unbinds the material from the mesh.
  107906. * @param activeEffect defines the effect that should be unbound from.
  107907. * @returns true if unbound, otherwise false
  107908. */
  107909. unbind(activeEffect: Effect): boolean;
  107910. /**
  107911. * Returns the texture used for refraction or null if none is used.
  107912. * @param scene defines the scene the material belongs to.
  107913. * @returns - Refraction texture if present. If no refraction texture and refraction
  107914. * is linked with transparency, returns environment texture. Otherwise, returns null.
  107915. */
  107916. private _getRefractionTexture;
  107917. /**
  107918. * Returns true if alpha blending should be disabled.
  107919. */
  107920. readonly disableAlphaBlending: boolean;
  107921. /**
  107922. * Fills the list of render target textures.
  107923. * @param renderTargets the list of render targets to update
  107924. */
  107925. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  107926. /**
  107927. * Checks to see if a texture is used in the material.
  107928. * @param texture - Base texture to use.
  107929. * @returns - Boolean specifying if a texture is used in the material.
  107930. */
  107931. hasTexture(texture: BaseTexture): boolean;
  107932. /**
  107933. * Gets a boolean indicating that current material needs to register RTT
  107934. * @returns true if this uses a render target otherwise false.
  107935. */
  107936. hasRenderTargetTextures(): boolean;
  107937. /**
  107938. * Returns an array of the actively used textures.
  107939. * @param activeTextures Array of BaseTextures
  107940. */
  107941. getActiveTextures(activeTextures: BaseTexture[]): void;
  107942. /**
  107943. * Returns the animatable textures.
  107944. * @param animatables Array of animatable textures.
  107945. */
  107946. getAnimatables(animatables: IAnimatable[]): void;
  107947. /**
  107948. * Disposes the resources of the material.
  107949. * @param forceDisposeTextures - Forces the disposal of all textures.
  107950. */
  107951. dispose(forceDisposeTextures?: boolean): void;
  107952. /**
  107953. * Get the current class name of the texture useful for serialization or dynamic coding.
  107954. * @returns "PBRSubSurfaceConfiguration"
  107955. */
  107956. getClassName(): string;
  107957. /**
  107958. * Add fallbacks to the effect fallbacks list.
  107959. * @param defines defines the Base texture to use.
  107960. * @param fallbacks defines the current fallback list.
  107961. * @param currentRank defines the current fallback rank.
  107962. * @returns the new fallback rank.
  107963. */
  107964. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107965. /**
  107966. * Add the required uniforms to the current list.
  107967. * @param uniforms defines the current uniform list.
  107968. */
  107969. static AddUniforms(uniforms: string[]): void;
  107970. /**
  107971. * Add the required samplers to the current list.
  107972. * @param samplers defines the current sampler list.
  107973. */
  107974. static AddSamplers(samplers: string[]): void;
  107975. /**
  107976. * Add the required uniforms to the current buffer.
  107977. * @param uniformBuffer defines the current uniform buffer.
  107978. */
  107979. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107980. /**
  107981. * Makes a duplicate of the current configuration into another one.
  107982. * @param configuration define the config where to copy the info
  107983. */
  107984. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  107985. /**
  107986. * Serializes this Sub Surface configuration.
  107987. * @returns - An object with the serialized config.
  107988. */
  107989. serialize(): any;
  107990. /**
  107991. * Parses a anisotropy Configuration from a serialized object.
  107992. * @param source - Serialized object.
  107993. * @param scene Defines the scene we are parsing for
  107994. * @param rootUrl Defines the rootUrl to load from
  107995. */
  107996. parse(source: any, scene: Scene, rootUrl: string): void;
  107997. }
  107998. }
  107999. declare module BABYLON {
  108000. /** @hidden */
  108001. export var pbrFragmentDeclaration: {
  108002. name: string;
  108003. shader: string;
  108004. };
  108005. }
  108006. declare module BABYLON {
  108007. /** @hidden */
  108008. export var pbrUboDeclaration: {
  108009. name: string;
  108010. shader: string;
  108011. };
  108012. }
  108013. declare module BABYLON {
  108014. /** @hidden */
  108015. export var pbrFragmentExtraDeclaration: {
  108016. name: string;
  108017. shader: string;
  108018. };
  108019. }
  108020. declare module BABYLON {
  108021. /** @hidden */
  108022. export var pbrFragmentSamplersDeclaration: {
  108023. name: string;
  108024. shader: string;
  108025. };
  108026. }
  108027. declare module BABYLON {
  108028. /** @hidden */
  108029. export var pbrHelperFunctions: {
  108030. name: string;
  108031. shader: string;
  108032. };
  108033. }
  108034. declare module BABYLON {
  108035. /** @hidden */
  108036. export var harmonicsFunctions: {
  108037. name: string;
  108038. shader: string;
  108039. };
  108040. }
  108041. declare module BABYLON {
  108042. /** @hidden */
  108043. export var pbrDirectLightingSetupFunctions: {
  108044. name: string;
  108045. shader: string;
  108046. };
  108047. }
  108048. declare module BABYLON {
  108049. /** @hidden */
  108050. export var pbrDirectLightingFalloffFunctions: {
  108051. name: string;
  108052. shader: string;
  108053. };
  108054. }
  108055. declare module BABYLON {
  108056. /** @hidden */
  108057. export var pbrBRDFFunctions: {
  108058. name: string;
  108059. shader: string;
  108060. };
  108061. }
  108062. declare module BABYLON {
  108063. /** @hidden */
  108064. export var pbrDirectLightingFunctions: {
  108065. name: string;
  108066. shader: string;
  108067. };
  108068. }
  108069. declare module BABYLON {
  108070. /** @hidden */
  108071. export var pbrIBLFunctions: {
  108072. name: string;
  108073. shader: string;
  108074. };
  108075. }
  108076. declare module BABYLON {
  108077. /** @hidden */
  108078. export var pbrDebug: {
  108079. name: string;
  108080. shader: string;
  108081. };
  108082. }
  108083. declare module BABYLON {
  108084. /** @hidden */
  108085. export var pbrPixelShader: {
  108086. name: string;
  108087. shader: string;
  108088. };
  108089. }
  108090. declare module BABYLON {
  108091. /** @hidden */
  108092. export var pbrVertexDeclaration: {
  108093. name: string;
  108094. shader: string;
  108095. };
  108096. }
  108097. declare module BABYLON {
  108098. /** @hidden */
  108099. export var pbrVertexShader: {
  108100. name: string;
  108101. shader: string;
  108102. };
  108103. }
  108104. declare module BABYLON {
  108105. /**
  108106. * Manages the defines for the PBR Material.
  108107. * @hidden
  108108. */
  108109. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  108110. PBR: boolean;
  108111. MAINUV1: boolean;
  108112. MAINUV2: boolean;
  108113. UV1: boolean;
  108114. UV2: boolean;
  108115. ALBEDO: boolean;
  108116. ALBEDODIRECTUV: number;
  108117. VERTEXCOLOR: boolean;
  108118. AMBIENT: boolean;
  108119. AMBIENTDIRECTUV: number;
  108120. AMBIENTINGRAYSCALE: boolean;
  108121. OPACITY: boolean;
  108122. VERTEXALPHA: boolean;
  108123. OPACITYDIRECTUV: number;
  108124. OPACITYRGB: boolean;
  108125. ALPHATEST: boolean;
  108126. DEPTHPREPASS: boolean;
  108127. ALPHABLEND: boolean;
  108128. ALPHAFROMALBEDO: boolean;
  108129. ALPHATESTVALUE: string;
  108130. SPECULAROVERALPHA: boolean;
  108131. RADIANCEOVERALPHA: boolean;
  108132. ALPHAFRESNEL: boolean;
  108133. LINEARALPHAFRESNEL: boolean;
  108134. PREMULTIPLYALPHA: boolean;
  108135. EMISSIVE: boolean;
  108136. EMISSIVEDIRECTUV: number;
  108137. REFLECTIVITY: boolean;
  108138. REFLECTIVITYDIRECTUV: number;
  108139. SPECULARTERM: boolean;
  108140. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  108141. MICROSURFACEAUTOMATIC: boolean;
  108142. LODBASEDMICROSFURACE: boolean;
  108143. MICROSURFACEMAP: boolean;
  108144. MICROSURFACEMAPDIRECTUV: number;
  108145. METALLICWORKFLOW: boolean;
  108146. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  108147. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  108148. METALLNESSSTOREINMETALMAPBLUE: boolean;
  108149. AOSTOREINMETALMAPRED: boolean;
  108150. ENVIRONMENTBRDF: boolean;
  108151. ENVIRONMENTBRDF_RGBD: boolean;
  108152. NORMAL: boolean;
  108153. TANGENT: boolean;
  108154. BUMP: boolean;
  108155. BUMPDIRECTUV: number;
  108156. OBJECTSPACE_NORMALMAP: boolean;
  108157. PARALLAX: boolean;
  108158. PARALLAXOCCLUSION: boolean;
  108159. NORMALXYSCALE: boolean;
  108160. LIGHTMAP: boolean;
  108161. LIGHTMAPDIRECTUV: number;
  108162. USELIGHTMAPASSHADOWMAP: boolean;
  108163. GAMMALIGHTMAP: boolean;
  108164. REFLECTION: boolean;
  108165. REFLECTIONMAP_3D: boolean;
  108166. REFLECTIONMAP_SPHERICAL: boolean;
  108167. REFLECTIONMAP_PLANAR: boolean;
  108168. REFLECTIONMAP_CUBIC: boolean;
  108169. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  108170. REFLECTIONMAP_PROJECTION: boolean;
  108171. REFLECTIONMAP_SKYBOX: boolean;
  108172. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  108173. REFLECTIONMAP_EXPLICIT: boolean;
  108174. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  108175. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  108176. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  108177. INVERTCUBICMAP: boolean;
  108178. USESPHERICALFROMREFLECTIONMAP: boolean;
  108179. USEIRRADIANCEMAP: boolean;
  108180. SPHERICAL_HARMONICS: boolean;
  108181. USESPHERICALINVERTEX: boolean;
  108182. REFLECTIONMAP_OPPOSITEZ: boolean;
  108183. LODINREFLECTIONALPHA: boolean;
  108184. GAMMAREFLECTION: boolean;
  108185. RGBDREFLECTION: boolean;
  108186. LINEARSPECULARREFLECTION: boolean;
  108187. RADIANCEOCCLUSION: boolean;
  108188. HORIZONOCCLUSION: boolean;
  108189. INSTANCES: boolean;
  108190. NUM_BONE_INFLUENCERS: number;
  108191. BonesPerMesh: number;
  108192. BONETEXTURE: boolean;
  108193. NONUNIFORMSCALING: boolean;
  108194. MORPHTARGETS: boolean;
  108195. MORPHTARGETS_NORMAL: boolean;
  108196. MORPHTARGETS_TANGENT: boolean;
  108197. MORPHTARGETS_UV: boolean;
  108198. NUM_MORPH_INFLUENCERS: number;
  108199. IMAGEPROCESSING: boolean;
  108200. VIGNETTE: boolean;
  108201. VIGNETTEBLENDMODEMULTIPLY: boolean;
  108202. VIGNETTEBLENDMODEOPAQUE: boolean;
  108203. TONEMAPPING: boolean;
  108204. TONEMAPPING_ACES: boolean;
  108205. CONTRAST: boolean;
  108206. COLORCURVES: boolean;
  108207. COLORGRADING: boolean;
  108208. COLORGRADING3D: boolean;
  108209. SAMPLER3DGREENDEPTH: boolean;
  108210. SAMPLER3DBGRMAP: boolean;
  108211. IMAGEPROCESSINGPOSTPROCESS: boolean;
  108212. EXPOSURE: boolean;
  108213. MULTIVIEW: boolean;
  108214. USEPHYSICALLIGHTFALLOFF: boolean;
  108215. USEGLTFLIGHTFALLOFF: boolean;
  108216. TWOSIDEDLIGHTING: boolean;
  108217. SHADOWFLOAT: boolean;
  108218. CLIPPLANE: boolean;
  108219. CLIPPLANE2: boolean;
  108220. CLIPPLANE3: boolean;
  108221. CLIPPLANE4: boolean;
  108222. POINTSIZE: boolean;
  108223. FOG: boolean;
  108224. LOGARITHMICDEPTH: boolean;
  108225. FORCENORMALFORWARD: boolean;
  108226. SPECULARAA: boolean;
  108227. CLEARCOAT: boolean;
  108228. CLEARCOAT_DEFAULTIOR: boolean;
  108229. CLEARCOAT_TEXTURE: boolean;
  108230. CLEARCOAT_TEXTUREDIRECTUV: number;
  108231. CLEARCOAT_BUMP: boolean;
  108232. CLEARCOAT_BUMPDIRECTUV: number;
  108233. CLEARCOAT_TINT: boolean;
  108234. CLEARCOAT_TINT_TEXTURE: boolean;
  108235. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  108236. ANISOTROPIC: boolean;
  108237. ANISOTROPIC_TEXTURE: boolean;
  108238. ANISOTROPIC_TEXTUREDIRECTUV: number;
  108239. BRDF_V_HEIGHT_CORRELATED: boolean;
  108240. MS_BRDF_ENERGY_CONSERVATION: boolean;
  108241. SHEEN: boolean;
  108242. SHEEN_TEXTURE: boolean;
  108243. SHEEN_TEXTUREDIRECTUV: number;
  108244. SHEEN_LINKWITHALBEDO: boolean;
  108245. SUBSURFACE: boolean;
  108246. SS_REFRACTION: boolean;
  108247. SS_TRANSLUCENCY: boolean;
  108248. SS_SCATERRING: boolean;
  108249. SS_THICKNESSANDMASK_TEXTURE: boolean;
  108250. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  108251. SS_REFRACTIONMAP_3D: boolean;
  108252. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  108253. SS_LODINREFRACTIONALPHA: boolean;
  108254. SS_GAMMAREFRACTION: boolean;
  108255. SS_RGBDREFRACTION: boolean;
  108256. SS_LINEARSPECULARREFRACTION: boolean;
  108257. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  108258. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  108259. UNLIT: boolean;
  108260. DEBUGMODE: number;
  108261. /**
  108262. * Initializes the PBR Material defines.
  108263. */
  108264. constructor();
  108265. /**
  108266. * Resets the PBR Material defines.
  108267. */
  108268. reset(): void;
  108269. }
  108270. /**
  108271. * The Physically based material base class of BJS.
  108272. *
  108273. * This offers the main features of a standard PBR material.
  108274. * For more information, please refer to the documentation :
  108275. * https://doc.babylonjs.com/how_to/physically_based_rendering
  108276. */
  108277. export abstract class PBRBaseMaterial extends PushMaterial {
  108278. /**
  108279. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  108280. */
  108281. static readonly PBRMATERIAL_OPAQUE: number;
  108282. /**
  108283. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  108284. */
  108285. static readonly PBRMATERIAL_ALPHATEST: number;
  108286. /**
  108287. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108288. */
  108289. static readonly PBRMATERIAL_ALPHABLEND: number;
  108290. /**
  108291. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108292. * They are also discarded below the alpha cutoff threshold to improve performances.
  108293. */
  108294. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  108295. /**
  108296. * Defines the default value of how much AO map is occluding the analytical lights
  108297. * (point spot...).
  108298. */
  108299. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  108300. /**
  108301. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  108302. */
  108303. static readonly LIGHTFALLOFF_PHYSICAL: number;
  108304. /**
  108305. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  108306. * to enhance interoperability with other engines.
  108307. */
  108308. static readonly LIGHTFALLOFF_GLTF: number;
  108309. /**
  108310. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  108311. * to enhance interoperability with other materials.
  108312. */
  108313. static readonly LIGHTFALLOFF_STANDARD: number;
  108314. /**
  108315. * Intensity of the direct lights e.g. the four lights available in your scene.
  108316. * This impacts both the direct diffuse and specular highlights.
  108317. */
  108318. protected _directIntensity: number;
  108319. /**
  108320. * Intensity of the emissive part of the material.
  108321. * This helps controlling the emissive effect without modifying the emissive color.
  108322. */
  108323. protected _emissiveIntensity: number;
  108324. /**
  108325. * Intensity of the environment e.g. how much the environment will light the object
  108326. * either through harmonics for rough material or through the refelction for shiny ones.
  108327. */
  108328. protected _environmentIntensity: number;
  108329. /**
  108330. * This is a special control allowing the reduction of the specular highlights coming from the
  108331. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  108332. */
  108333. protected _specularIntensity: number;
  108334. /**
  108335. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  108336. */
  108337. private _lightingInfos;
  108338. /**
  108339. * Debug Control allowing disabling the bump map on this material.
  108340. */
  108341. protected _disableBumpMap: boolean;
  108342. /**
  108343. * AKA Diffuse Texture in standard nomenclature.
  108344. */
  108345. protected _albedoTexture: Nullable<BaseTexture>;
  108346. /**
  108347. * AKA Occlusion Texture in other nomenclature.
  108348. */
  108349. protected _ambientTexture: Nullable<BaseTexture>;
  108350. /**
  108351. * AKA Occlusion Texture Intensity in other nomenclature.
  108352. */
  108353. protected _ambientTextureStrength: number;
  108354. /**
  108355. * Defines how much the AO map is occluding the analytical lights (point spot...).
  108356. * 1 means it completely occludes it
  108357. * 0 mean it has no impact
  108358. */
  108359. protected _ambientTextureImpactOnAnalyticalLights: number;
  108360. /**
  108361. * Stores the alpha values in a texture.
  108362. */
  108363. protected _opacityTexture: Nullable<BaseTexture>;
  108364. /**
  108365. * Stores the reflection values in a texture.
  108366. */
  108367. protected _reflectionTexture: Nullable<BaseTexture>;
  108368. /**
  108369. * Stores the emissive values in a texture.
  108370. */
  108371. protected _emissiveTexture: Nullable<BaseTexture>;
  108372. /**
  108373. * AKA Specular texture in other nomenclature.
  108374. */
  108375. protected _reflectivityTexture: Nullable<BaseTexture>;
  108376. /**
  108377. * Used to switch from specular/glossiness to metallic/roughness workflow.
  108378. */
  108379. protected _metallicTexture: Nullable<BaseTexture>;
  108380. /**
  108381. * Specifies the metallic scalar of the metallic/roughness workflow.
  108382. * Can also be used to scale the metalness values of the metallic texture.
  108383. */
  108384. protected _metallic: Nullable<number>;
  108385. /**
  108386. * Specifies the roughness scalar of the metallic/roughness workflow.
  108387. * Can also be used to scale the roughness values of the metallic texture.
  108388. */
  108389. protected _roughness: Nullable<number>;
  108390. /**
  108391. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  108392. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  108393. */
  108394. protected _microSurfaceTexture: Nullable<BaseTexture>;
  108395. /**
  108396. * Stores surface normal data used to displace a mesh in a texture.
  108397. */
  108398. protected _bumpTexture: Nullable<BaseTexture>;
  108399. /**
  108400. * Stores the pre-calculated light information of a mesh in a texture.
  108401. */
  108402. protected _lightmapTexture: Nullable<BaseTexture>;
  108403. /**
  108404. * The color of a material in ambient lighting.
  108405. */
  108406. protected _ambientColor: Color3;
  108407. /**
  108408. * AKA Diffuse Color in other nomenclature.
  108409. */
  108410. protected _albedoColor: Color3;
  108411. /**
  108412. * AKA Specular Color in other nomenclature.
  108413. */
  108414. protected _reflectivityColor: Color3;
  108415. /**
  108416. * The color applied when light is reflected from a material.
  108417. */
  108418. protected _reflectionColor: Color3;
  108419. /**
  108420. * The color applied when light is emitted from a material.
  108421. */
  108422. protected _emissiveColor: Color3;
  108423. /**
  108424. * AKA Glossiness in other nomenclature.
  108425. */
  108426. protected _microSurface: number;
  108427. /**
  108428. * Specifies that the material will use the light map as a show map.
  108429. */
  108430. protected _useLightmapAsShadowmap: boolean;
  108431. /**
  108432. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  108433. * makes the reflect vector face the model (under horizon).
  108434. */
  108435. protected _useHorizonOcclusion: boolean;
  108436. /**
  108437. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  108438. * too much the area relying on ambient texture to define their ambient occlusion.
  108439. */
  108440. protected _useRadianceOcclusion: boolean;
  108441. /**
  108442. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  108443. */
  108444. protected _useAlphaFromAlbedoTexture: boolean;
  108445. /**
  108446. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  108447. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  108448. */
  108449. protected _useSpecularOverAlpha: boolean;
  108450. /**
  108451. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  108452. */
  108453. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  108454. /**
  108455. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  108456. */
  108457. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  108458. /**
  108459. * Specifies if the metallic texture contains the roughness information in its green channel.
  108460. */
  108461. protected _useRoughnessFromMetallicTextureGreen: boolean;
  108462. /**
  108463. * Specifies if the metallic texture contains the metallness information in its blue channel.
  108464. */
  108465. protected _useMetallnessFromMetallicTextureBlue: boolean;
  108466. /**
  108467. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  108468. */
  108469. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  108470. /**
  108471. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  108472. */
  108473. protected _useAmbientInGrayScale: boolean;
  108474. /**
  108475. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  108476. * The material will try to infer what glossiness each pixel should be.
  108477. */
  108478. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  108479. /**
  108480. * Defines the falloff type used in this material.
  108481. * It by default is Physical.
  108482. */
  108483. protected _lightFalloff: number;
  108484. /**
  108485. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  108486. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  108487. */
  108488. protected _useRadianceOverAlpha: boolean;
  108489. /**
  108490. * Allows using an object space normal map (instead of tangent space).
  108491. */
  108492. protected _useObjectSpaceNormalMap: boolean;
  108493. /**
  108494. * Allows using the bump map in parallax mode.
  108495. */
  108496. protected _useParallax: boolean;
  108497. /**
  108498. * Allows using the bump map in parallax occlusion mode.
  108499. */
  108500. protected _useParallaxOcclusion: boolean;
  108501. /**
  108502. * Controls the scale bias of the parallax mode.
  108503. */
  108504. protected _parallaxScaleBias: number;
  108505. /**
  108506. * If sets to true, disables all the lights affecting the material.
  108507. */
  108508. protected _disableLighting: boolean;
  108509. /**
  108510. * Number of Simultaneous lights allowed on the material.
  108511. */
  108512. protected _maxSimultaneousLights: number;
  108513. /**
  108514. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  108515. */
  108516. protected _invertNormalMapX: boolean;
  108517. /**
  108518. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  108519. */
  108520. protected _invertNormalMapY: boolean;
  108521. /**
  108522. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108523. */
  108524. protected _twoSidedLighting: boolean;
  108525. /**
  108526. * Defines the alpha limits in alpha test mode.
  108527. */
  108528. protected _alphaCutOff: number;
  108529. /**
  108530. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  108531. */
  108532. protected _forceAlphaTest: boolean;
  108533. /**
  108534. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108535. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  108536. */
  108537. protected _useAlphaFresnel: boolean;
  108538. /**
  108539. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108540. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  108541. */
  108542. protected _useLinearAlphaFresnel: boolean;
  108543. /**
  108544. * The transparency mode of the material.
  108545. */
  108546. protected _transparencyMode: Nullable<number>;
  108547. /**
  108548. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  108549. * from cos thetav and roughness:
  108550. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  108551. */
  108552. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  108553. /**
  108554. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  108555. */
  108556. protected _forceIrradianceInFragment: boolean;
  108557. /**
  108558. * Force normal to face away from face.
  108559. */
  108560. protected _forceNormalForward: boolean;
  108561. /**
  108562. * Enables specular anti aliasing in the PBR shader.
  108563. * It will both interacts on the Geometry for analytical and IBL lighting.
  108564. * It also prefilter the roughness map based on the bump values.
  108565. */
  108566. protected _enableSpecularAntiAliasing: boolean;
  108567. /**
  108568. * Default configuration related to image processing available in the PBR Material.
  108569. */
  108570. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108571. /**
  108572. * Keep track of the image processing observer to allow dispose and replace.
  108573. */
  108574. private _imageProcessingObserver;
  108575. /**
  108576. * Attaches a new image processing configuration to the PBR Material.
  108577. * @param configuration
  108578. */
  108579. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  108580. /**
  108581. * Stores the available render targets.
  108582. */
  108583. private _renderTargets;
  108584. /**
  108585. * Sets the global ambient color for the material used in lighting calculations.
  108586. */
  108587. private _globalAmbientColor;
  108588. /**
  108589. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  108590. */
  108591. private _useLogarithmicDepth;
  108592. /**
  108593. * If set to true, no lighting calculations will be applied.
  108594. */
  108595. private _unlit;
  108596. private _debugMode;
  108597. /**
  108598. * @hidden
  108599. * This is reserved for the inspector.
  108600. * Defines the material debug mode.
  108601. * It helps seeing only some components of the material while troubleshooting.
  108602. */
  108603. debugMode: number;
  108604. /**
  108605. * @hidden
  108606. * This is reserved for the inspector.
  108607. * Specify from where on screen the debug mode should start.
  108608. * The value goes from -1 (full screen) to 1 (not visible)
  108609. * It helps with side by side comparison against the final render
  108610. * This defaults to -1
  108611. */
  108612. private debugLimit;
  108613. /**
  108614. * @hidden
  108615. * This is reserved for the inspector.
  108616. * As the default viewing range might not be enough (if the ambient is really small for instance)
  108617. * You can use the factor to better multiply the final value.
  108618. */
  108619. private debugFactor;
  108620. /**
  108621. * Defines the clear coat layer parameters for the material.
  108622. */
  108623. readonly clearCoat: PBRClearCoatConfiguration;
  108624. /**
  108625. * Defines the anisotropic parameters for the material.
  108626. */
  108627. readonly anisotropy: PBRAnisotropicConfiguration;
  108628. /**
  108629. * Defines the BRDF parameters for the material.
  108630. */
  108631. readonly brdf: PBRBRDFConfiguration;
  108632. /**
  108633. * Defines the Sheen parameters for the material.
  108634. */
  108635. readonly sheen: PBRSheenConfiguration;
  108636. /**
  108637. * Defines the SubSurface parameters for the material.
  108638. */
  108639. readonly subSurface: PBRSubSurfaceConfiguration;
  108640. /**
  108641. * Custom callback helping to override the default shader used in the material.
  108642. */
  108643. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  108644. /**
  108645. * Instantiates a new PBRMaterial instance.
  108646. *
  108647. * @param name The material name
  108648. * @param scene The scene the material will be use in.
  108649. */
  108650. constructor(name: string, scene: Scene);
  108651. /**
  108652. * Gets a boolean indicating that current material needs to register RTT
  108653. */
  108654. readonly hasRenderTargetTextures: boolean;
  108655. /**
  108656. * Gets the name of the material class.
  108657. */
  108658. getClassName(): string;
  108659. /**
  108660. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  108661. */
  108662. /**
  108663. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  108664. */
  108665. useLogarithmicDepth: boolean;
  108666. /**
  108667. * Gets the current transparency mode.
  108668. */
  108669. /**
  108670. * Sets the transparency mode of the material.
  108671. *
  108672. * | Value | Type | Description |
  108673. * | ----- | ----------------------------------- | ----------- |
  108674. * | 0 | OPAQUE | |
  108675. * | 1 | ALPHATEST | |
  108676. * | 2 | ALPHABLEND | |
  108677. * | 3 | ALPHATESTANDBLEND | |
  108678. *
  108679. */
  108680. transparencyMode: Nullable<number>;
  108681. /**
  108682. * Returns true if alpha blending should be disabled.
  108683. */
  108684. private readonly _disableAlphaBlending;
  108685. /**
  108686. * Specifies whether or not this material should be rendered in alpha blend mode.
  108687. */
  108688. needAlphaBlending(): boolean;
  108689. /**
  108690. * Specifies if the mesh will require alpha blending.
  108691. * @param mesh - BJS mesh.
  108692. */
  108693. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  108694. /**
  108695. * Specifies whether or not this material should be rendered in alpha test mode.
  108696. */
  108697. needAlphaTesting(): boolean;
  108698. /**
  108699. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  108700. */
  108701. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  108702. /**
  108703. * Gets the texture used for the alpha test.
  108704. */
  108705. getAlphaTestTexture(): Nullable<BaseTexture>;
  108706. /**
  108707. * Specifies that the submesh is ready to be used.
  108708. * @param mesh - BJS mesh.
  108709. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  108710. * @param useInstances - Specifies that instances should be used.
  108711. * @returns - boolean indicating that the submesh is ready or not.
  108712. */
  108713. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  108714. /**
  108715. * Specifies if the material uses metallic roughness workflow.
  108716. * @returns boolean specifiying if the material uses metallic roughness workflow.
  108717. */
  108718. isMetallicWorkflow(): boolean;
  108719. private _prepareEffect;
  108720. private _prepareDefines;
  108721. /**
  108722. * Force shader compilation
  108723. */
  108724. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  108725. clipPlane: boolean;
  108726. }>): void;
  108727. /**
  108728. * Initializes the uniform buffer layout for the shader.
  108729. */
  108730. buildUniformLayout(): void;
  108731. /**
  108732. * Unbinds the material from the mesh
  108733. */
  108734. unbind(): void;
  108735. /**
  108736. * Binds the submesh data.
  108737. * @param world - The world matrix.
  108738. * @param mesh - The BJS mesh.
  108739. * @param subMesh - A submesh of the BJS mesh.
  108740. */
  108741. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  108742. /**
  108743. * Returns the animatable textures.
  108744. * @returns - Array of animatable textures.
  108745. */
  108746. getAnimatables(): IAnimatable[];
  108747. /**
  108748. * Returns the texture used for reflections.
  108749. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  108750. */
  108751. private _getReflectionTexture;
  108752. /**
  108753. * Returns an array of the actively used textures.
  108754. * @returns - Array of BaseTextures
  108755. */
  108756. getActiveTextures(): BaseTexture[];
  108757. /**
  108758. * Checks to see if a texture is used in the material.
  108759. * @param texture - Base texture to use.
  108760. * @returns - Boolean specifying if a texture is used in the material.
  108761. */
  108762. hasTexture(texture: BaseTexture): boolean;
  108763. /**
  108764. * Disposes the resources of the material.
  108765. * @param forceDisposeEffect - Forces the disposal of effects.
  108766. * @param forceDisposeTextures - Forces the disposal of all textures.
  108767. */
  108768. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  108769. }
  108770. }
  108771. declare module BABYLON {
  108772. /**
  108773. * The Physically based material of BJS.
  108774. *
  108775. * This offers the main features of a standard PBR material.
  108776. * For more information, please refer to the documentation :
  108777. * https://doc.babylonjs.com/how_to/physically_based_rendering
  108778. */
  108779. export class PBRMaterial extends PBRBaseMaterial {
  108780. /**
  108781. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  108782. */
  108783. static readonly PBRMATERIAL_OPAQUE: number;
  108784. /**
  108785. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  108786. */
  108787. static readonly PBRMATERIAL_ALPHATEST: number;
  108788. /**
  108789. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108790. */
  108791. static readonly PBRMATERIAL_ALPHABLEND: number;
  108792. /**
  108793. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108794. * They are also discarded below the alpha cutoff threshold to improve performances.
  108795. */
  108796. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  108797. /**
  108798. * Defines the default value of how much AO map is occluding the analytical lights
  108799. * (point spot...).
  108800. */
  108801. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  108802. /**
  108803. * Intensity of the direct lights e.g. the four lights available in your scene.
  108804. * This impacts both the direct diffuse and specular highlights.
  108805. */
  108806. directIntensity: number;
  108807. /**
  108808. * Intensity of the emissive part of the material.
  108809. * This helps controlling the emissive effect without modifying the emissive color.
  108810. */
  108811. emissiveIntensity: number;
  108812. /**
  108813. * Intensity of the environment e.g. how much the environment will light the object
  108814. * either through harmonics for rough material or through the refelction for shiny ones.
  108815. */
  108816. environmentIntensity: number;
  108817. /**
  108818. * This is a special control allowing the reduction of the specular highlights coming from the
  108819. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  108820. */
  108821. specularIntensity: number;
  108822. /**
  108823. * Debug Control allowing disabling the bump map on this material.
  108824. */
  108825. disableBumpMap: boolean;
  108826. /**
  108827. * AKA Diffuse Texture in standard nomenclature.
  108828. */
  108829. albedoTexture: BaseTexture;
  108830. /**
  108831. * AKA Occlusion Texture in other nomenclature.
  108832. */
  108833. ambientTexture: BaseTexture;
  108834. /**
  108835. * AKA Occlusion Texture Intensity in other nomenclature.
  108836. */
  108837. ambientTextureStrength: number;
  108838. /**
  108839. * Defines how much the AO map is occluding the analytical lights (point spot...).
  108840. * 1 means it completely occludes it
  108841. * 0 mean it has no impact
  108842. */
  108843. ambientTextureImpactOnAnalyticalLights: number;
  108844. /**
  108845. * Stores the alpha values in a texture.
  108846. */
  108847. opacityTexture: BaseTexture;
  108848. /**
  108849. * Stores the reflection values in a texture.
  108850. */
  108851. reflectionTexture: Nullable<BaseTexture>;
  108852. /**
  108853. * Stores the emissive values in a texture.
  108854. */
  108855. emissiveTexture: BaseTexture;
  108856. /**
  108857. * AKA Specular texture in other nomenclature.
  108858. */
  108859. reflectivityTexture: BaseTexture;
  108860. /**
  108861. * Used to switch from specular/glossiness to metallic/roughness workflow.
  108862. */
  108863. metallicTexture: BaseTexture;
  108864. /**
  108865. * Specifies the metallic scalar of the metallic/roughness workflow.
  108866. * Can also be used to scale the metalness values of the metallic texture.
  108867. */
  108868. metallic: Nullable<number>;
  108869. /**
  108870. * Specifies the roughness scalar of the metallic/roughness workflow.
  108871. * Can also be used to scale the roughness values of the metallic texture.
  108872. */
  108873. roughness: Nullable<number>;
  108874. /**
  108875. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  108876. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  108877. */
  108878. microSurfaceTexture: BaseTexture;
  108879. /**
  108880. * Stores surface normal data used to displace a mesh in a texture.
  108881. */
  108882. bumpTexture: BaseTexture;
  108883. /**
  108884. * Stores the pre-calculated light information of a mesh in a texture.
  108885. */
  108886. lightmapTexture: BaseTexture;
  108887. /**
  108888. * Stores the refracted light information in a texture.
  108889. */
  108890. refractionTexture: Nullable<BaseTexture>;
  108891. /**
  108892. * The color of a material in ambient lighting.
  108893. */
  108894. ambientColor: Color3;
  108895. /**
  108896. * AKA Diffuse Color in other nomenclature.
  108897. */
  108898. albedoColor: Color3;
  108899. /**
  108900. * AKA Specular Color in other nomenclature.
  108901. */
  108902. reflectivityColor: Color3;
  108903. /**
  108904. * The color reflected from the material.
  108905. */
  108906. reflectionColor: Color3;
  108907. /**
  108908. * The color emitted from the material.
  108909. */
  108910. emissiveColor: Color3;
  108911. /**
  108912. * AKA Glossiness in other nomenclature.
  108913. */
  108914. microSurface: number;
  108915. /**
  108916. * source material index of refraction (IOR)' / 'destination material IOR.
  108917. */
  108918. indexOfRefraction: number;
  108919. /**
  108920. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  108921. */
  108922. invertRefractionY: boolean;
  108923. /**
  108924. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  108925. * Materials half opaque for instance using refraction could benefit from this control.
  108926. */
  108927. linkRefractionWithTransparency: boolean;
  108928. /**
  108929. * If true, the light map contains occlusion information instead of lighting info.
  108930. */
  108931. useLightmapAsShadowmap: boolean;
  108932. /**
  108933. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  108934. */
  108935. useAlphaFromAlbedoTexture: boolean;
  108936. /**
  108937. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  108938. */
  108939. forceAlphaTest: boolean;
  108940. /**
  108941. * Defines the alpha limits in alpha test mode.
  108942. */
  108943. alphaCutOff: number;
  108944. /**
  108945. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  108946. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  108947. */
  108948. useSpecularOverAlpha: boolean;
  108949. /**
  108950. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  108951. */
  108952. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  108953. /**
  108954. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  108955. */
  108956. useRoughnessFromMetallicTextureAlpha: boolean;
  108957. /**
  108958. * Specifies if the metallic texture contains the roughness information in its green channel.
  108959. */
  108960. useRoughnessFromMetallicTextureGreen: boolean;
  108961. /**
  108962. * Specifies if the metallic texture contains the metallness information in its blue channel.
  108963. */
  108964. useMetallnessFromMetallicTextureBlue: boolean;
  108965. /**
  108966. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  108967. */
  108968. useAmbientOcclusionFromMetallicTextureRed: boolean;
  108969. /**
  108970. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  108971. */
  108972. useAmbientInGrayScale: boolean;
  108973. /**
  108974. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  108975. * The material will try to infer what glossiness each pixel should be.
  108976. */
  108977. useAutoMicroSurfaceFromReflectivityMap: boolean;
  108978. /**
  108979. * BJS is using an harcoded light falloff based on a manually sets up range.
  108980. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  108981. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  108982. */
  108983. /**
  108984. * BJS is using an harcoded light falloff based on a manually sets up range.
  108985. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  108986. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  108987. */
  108988. usePhysicalLightFalloff: boolean;
  108989. /**
  108990. * In order to support the falloff compatibility with gltf, a special mode has been added
  108991. * to reproduce the gltf light falloff.
  108992. */
  108993. /**
  108994. * In order to support the falloff compatibility with gltf, a special mode has been added
  108995. * to reproduce the gltf light falloff.
  108996. */
  108997. useGLTFLightFalloff: boolean;
  108998. /**
  108999. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  109000. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  109001. */
  109002. useRadianceOverAlpha: boolean;
  109003. /**
  109004. * Allows using an object space normal map (instead of tangent space).
  109005. */
  109006. useObjectSpaceNormalMap: boolean;
  109007. /**
  109008. * Allows using the bump map in parallax mode.
  109009. */
  109010. useParallax: boolean;
  109011. /**
  109012. * Allows using the bump map in parallax occlusion mode.
  109013. */
  109014. useParallaxOcclusion: boolean;
  109015. /**
  109016. * Controls the scale bias of the parallax mode.
  109017. */
  109018. parallaxScaleBias: number;
  109019. /**
  109020. * If sets to true, disables all the lights affecting the material.
  109021. */
  109022. disableLighting: boolean;
  109023. /**
  109024. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  109025. */
  109026. forceIrradianceInFragment: boolean;
  109027. /**
  109028. * Number of Simultaneous lights allowed on the material.
  109029. */
  109030. maxSimultaneousLights: number;
  109031. /**
  109032. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  109033. */
  109034. invertNormalMapX: boolean;
  109035. /**
  109036. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  109037. */
  109038. invertNormalMapY: boolean;
  109039. /**
  109040. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  109041. */
  109042. twoSidedLighting: boolean;
  109043. /**
  109044. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  109045. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  109046. */
  109047. useAlphaFresnel: boolean;
  109048. /**
  109049. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  109050. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  109051. */
  109052. useLinearAlphaFresnel: boolean;
  109053. /**
  109054. * Let user defines the brdf lookup texture used for IBL.
  109055. * A default 8bit version is embedded but you could point at :
  109056. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  109057. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  109058. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  109059. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  109060. */
  109061. environmentBRDFTexture: Nullable<BaseTexture>;
  109062. /**
  109063. * Force normal to face away from face.
  109064. */
  109065. forceNormalForward: boolean;
  109066. /**
  109067. * Enables specular anti aliasing in the PBR shader.
  109068. * It will both interacts on the Geometry for analytical and IBL lighting.
  109069. * It also prefilter the roughness map based on the bump values.
  109070. */
  109071. enableSpecularAntiAliasing: boolean;
  109072. /**
  109073. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  109074. * makes the reflect vector face the model (under horizon).
  109075. */
  109076. useHorizonOcclusion: boolean;
  109077. /**
  109078. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  109079. * too much the area relying on ambient texture to define their ambient occlusion.
  109080. */
  109081. useRadianceOcclusion: boolean;
  109082. /**
  109083. * If set to true, no lighting calculations will be applied.
  109084. */
  109085. unlit: boolean;
  109086. /**
  109087. * Gets the image processing configuration used either in this material.
  109088. */
  109089. /**
  109090. * Sets the Default image processing configuration used either in the this material.
  109091. *
  109092. * If sets to null, the scene one is in use.
  109093. */
  109094. imageProcessingConfiguration: ImageProcessingConfiguration;
  109095. /**
  109096. * Gets wether the color curves effect is enabled.
  109097. */
  109098. /**
  109099. * Sets wether the color curves effect is enabled.
  109100. */
  109101. cameraColorCurvesEnabled: boolean;
  109102. /**
  109103. * Gets wether the color grading effect is enabled.
  109104. */
  109105. /**
  109106. * Gets wether the color grading effect is enabled.
  109107. */
  109108. cameraColorGradingEnabled: boolean;
  109109. /**
  109110. * Gets wether tonemapping is enabled or not.
  109111. */
  109112. /**
  109113. * Sets wether tonemapping is enabled or not
  109114. */
  109115. cameraToneMappingEnabled: boolean;
  109116. /**
  109117. * The camera exposure used on this material.
  109118. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109119. * This corresponds to a photographic exposure.
  109120. */
  109121. /**
  109122. * The camera exposure used on this material.
  109123. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  109124. * This corresponds to a photographic exposure.
  109125. */
  109126. cameraExposure: number;
  109127. /**
  109128. * Gets The camera contrast used on this material.
  109129. */
  109130. /**
  109131. * Sets The camera contrast used on this material.
  109132. */
  109133. cameraContrast: number;
  109134. /**
  109135. * Gets the Color Grading 2D Lookup Texture.
  109136. */
  109137. /**
  109138. * Sets the Color Grading 2D Lookup Texture.
  109139. */
  109140. cameraColorGradingTexture: Nullable<BaseTexture>;
  109141. /**
  109142. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109143. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109144. * 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;
  109145. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109146. */
  109147. /**
  109148. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  109149. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  109150. * 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;
  109151. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  109152. */
  109153. cameraColorCurves: Nullable<ColorCurves>;
  109154. /**
  109155. * Instantiates a new PBRMaterial instance.
  109156. *
  109157. * @param name The material name
  109158. * @param scene The scene the material will be use in.
  109159. */
  109160. constructor(name: string, scene: Scene);
  109161. /**
  109162. * Returns the name of this material class.
  109163. */
  109164. getClassName(): string;
  109165. /**
  109166. * Makes a duplicate of the current material.
  109167. * @param name - name to use for the new material.
  109168. */
  109169. clone(name: string): PBRMaterial;
  109170. /**
  109171. * Serializes this PBR Material.
  109172. * @returns - An object with the serialized material.
  109173. */
  109174. serialize(): any;
  109175. /**
  109176. * Parses a PBR Material from a serialized object.
  109177. * @param source - Serialized object.
  109178. * @param scene - BJS scene instance.
  109179. * @param rootUrl - url for the scene object
  109180. * @returns - PBRMaterial
  109181. */
  109182. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  109183. }
  109184. }
  109185. declare module BABYLON {
  109186. /**
  109187. * Direct draw surface info
  109188. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  109189. */
  109190. export interface DDSInfo {
  109191. /**
  109192. * Width of the texture
  109193. */
  109194. width: number;
  109195. /**
  109196. * Width of the texture
  109197. */
  109198. height: number;
  109199. /**
  109200. * Number of Mipmaps for the texture
  109201. * @see https://en.wikipedia.org/wiki/Mipmap
  109202. */
  109203. mipmapCount: number;
  109204. /**
  109205. * If the textures format is a known fourCC format
  109206. * @see https://www.fourcc.org/
  109207. */
  109208. isFourCC: boolean;
  109209. /**
  109210. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  109211. */
  109212. isRGB: boolean;
  109213. /**
  109214. * If the texture is a lumincance format
  109215. */
  109216. isLuminance: boolean;
  109217. /**
  109218. * If this is a cube texture
  109219. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  109220. */
  109221. isCube: boolean;
  109222. /**
  109223. * If the texture is a compressed format eg. FOURCC_DXT1
  109224. */
  109225. isCompressed: boolean;
  109226. /**
  109227. * The dxgiFormat of the texture
  109228. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  109229. */
  109230. dxgiFormat: number;
  109231. /**
  109232. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  109233. */
  109234. textureType: number;
  109235. /**
  109236. * Sphericle polynomial created for the dds texture
  109237. */
  109238. sphericalPolynomial?: SphericalPolynomial;
  109239. }
  109240. /**
  109241. * Class used to provide DDS decompression tools
  109242. */
  109243. export class DDSTools {
  109244. /**
  109245. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  109246. */
  109247. static StoreLODInAlphaChannel: boolean;
  109248. /**
  109249. * Gets DDS information from an array buffer
  109250. * @param arrayBuffer defines the array buffer to read data from
  109251. * @returns the DDS information
  109252. */
  109253. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  109254. private static _FloatView;
  109255. private static _Int32View;
  109256. private static _ToHalfFloat;
  109257. private static _FromHalfFloat;
  109258. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  109259. private static _GetHalfFloatRGBAArrayBuffer;
  109260. private static _GetFloatRGBAArrayBuffer;
  109261. private static _GetFloatAsUIntRGBAArrayBuffer;
  109262. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  109263. private static _GetRGBAArrayBuffer;
  109264. private static _ExtractLongWordOrder;
  109265. private static _GetRGBArrayBuffer;
  109266. private static _GetLuminanceArrayBuffer;
  109267. /**
  109268. * Uploads DDS Levels to a Babylon Texture
  109269. * @hidden
  109270. */
  109271. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  109272. }
  109273. interface Engine {
  109274. /**
  109275. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  109276. * @param rootUrl defines the url where the file to load is located
  109277. * @param scene defines the current scene
  109278. * @param lodScale defines scale to apply to the mip map selection
  109279. * @param lodOffset defines offset to apply to the mip map selection
  109280. * @param onLoad defines an optional callback raised when the texture is loaded
  109281. * @param onError defines an optional callback raised if there is an issue to load the texture
  109282. * @param format defines the format of the data
  109283. * @param forcedExtension defines the extension to use to pick the right loader
  109284. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  109285. * @returns the cube texture as an InternalTexture
  109286. */
  109287. 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;
  109288. }
  109289. }
  109290. declare module BABYLON {
  109291. /**
  109292. * Implementation of the DDS Texture Loader.
  109293. * @hidden
  109294. */
  109295. export class _DDSTextureLoader implements IInternalTextureLoader {
  109296. /**
  109297. * Defines wether the loader supports cascade loading the different faces.
  109298. */
  109299. readonly supportCascades: boolean;
  109300. /**
  109301. * This returns if the loader support the current file information.
  109302. * @param extension defines the file extension of the file being loaded
  109303. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109304. * @param fallback defines the fallback internal texture if any
  109305. * @param isBase64 defines whether the texture is encoded as a base64
  109306. * @param isBuffer defines whether the texture data are stored as a buffer
  109307. * @returns true if the loader can load the specified file
  109308. */
  109309. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109310. /**
  109311. * Transform the url before loading if required.
  109312. * @param rootUrl the url of the texture
  109313. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109314. * @returns the transformed texture
  109315. */
  109316. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109317. /**
  109318. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109319. * @param rootUrl the url of the texture
  109320. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109321. * @returns the fallback texture
  109322. */
  109323. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109324. /**
  109325. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109326. * @param data contains the texture data
  109327. * @param texture defines the BabylonJS internal texture
  109328. * @param createPolynomials will be true if polynomials have been requested
  109329. * @param onLoad defines the callback to trigger once the texture is ready
  109330. * @param onError defines the callback to trigger in case of error
  109331. */
  109332. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109333. /**
  109334. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109335. * @param data contains the texture data
  109336. * @param texture defines the BabylonJS internal texture
  109337. * @param callback defines the method to call once ready to upload
  109338. */
  109339. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109340. }
  109341. }
  109342. declare module BABYLON {
  109343. /** @hidden */
  109344. export var rgbdEncodePixelShader: {
  109345. name: string;
  109346. shader: string;
  109347. };
  109348. }
  109349. declare module BABYLON {
  109350. /**
  109351. * Raw texture data and descriptor sufficient for WebGL texture upload
  109352. */
  109353. export interface EnvironmentTextureInfo {
  109354. /**
  109355. * Version of the environment map
  109356. */
  109357. version: number;
  109358. /**
  109359. * Width of image
  109360. */
  109361. width: number;
  109362. /**
  109363. * Irradiance information stored in the file.
  109364. */
  109365. irradiance: any;
  109366. /**
  109367. * Specular information stored in the file.
  109368. */
  109369. specular: any;
  109370. }
  109371. /**
  109372. * Sets of helpers addressing the serialization and deserialization of environment texture
  109373. * stored in a BabylonJS env file.
  109374. * Those files are usually stored as .env files.
  109375. */
  109376. export class EnvironmentTextureTools {
  109377. /**
  109378. * Magic number identifying the env file.
  109379. */
  109380. private static _MagicBytes;
  109381. /**
  109382. * Gets the environment info from an env file.
  109383. * @param data The array buffer containing the .env bytes.
  109384. * @returns the environment file info (the json header) if successfully parsed.
  109385. */
  109386. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  109387. /**
  109388. * Creates an environment texture from a loaded cube texture.
  109389. * @param texture defines the cube texture to convert in env file
  109390. * @return a promise containing the environment data if succesfull.
  109391. */
  109392. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  109393. /**
  109394. * Creates a JSON representation of the spherical data.
  109395. * @param texture defines the texture containing the polynomials
  109396. * @return the JSON representation of the spherical info
  109397. */
  109398. private static _CreateEnvTextureIrradiance;
  109399. /**
  109400. * Uploads the texture info contained in the env file to the GPU.
  109401. * @param texture defines the internal texture to upload to
  109402. * @param arrayBuffer defines the buffer cotaining the data to load
  109403. * @param info defines the texture info retrieved through the GetEnvInfo method
  109404. * @returns a promise
  109405. */
  109406. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  109407. /**
  109408. * Uploads the levels of image data to the GPU.
  109409. * @param texture defines the internal texture to upload to
  109410. * @param imageData defines the array buffer views of image data [mipmap][face]
  109411. * @returns a promise
  109412. */
  109413. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  109414. /**
  109415. * Uploads spherical polynomials information to the texture.
  109416. * @param texture defines the texture we are trying to upload the information to
  109417. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  109418. */
  109419. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  109420. /** @hidden */
  109421. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  109422. }
  109423. }
  109424. declare module BABYLON {
  109425. /**
  109426. * Implementation of the ENV Texture Loader.
  109427. * @hidden
  109428. */
  109429. export class _ENVTextureLoader implements IInternalTextureLoader {
  109430. /**
  109431. * Defines wether the loader supports cascade loading the different faces.
  109432. */
  109433. readonly supportCascades: boolean;
  109434. /**
  109435. * This returns if the loader support the current file information.
  109436. * @param extension defines the file extension of the file being loaded
  109437. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109438. * @param fallback defines the fallback internal texture if any
  109439. * @param isBase64 defines whether the texture is encoded as a base64
  109440. * @param isBuffer defines whether the texture data are stored as a buffer
  109441. * @returns true if the loader can load the specified file
  109442. */
  109443. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109444. /**
  109445. * Transform the url before loading if required.
  109446. * @param rootUrl the url of the texture
  109447. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109448. * @returns the transformed texture
  109449. */
  109450. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109451. /**
  109452. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109453. * @param rootUrl the url of the texture
  109454. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109455. * @returns the fallback texture
  109456. */
  109457. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109458. /**
  109459. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109460. * @param data contains the texture data
  109461. * @param texture defines the BabylonJS internal texture
  109462. * @param createPolynomials will be true if polynomials have been requested
  109463. * @param onLoad defines the callback to trigger once the texture is ready
  109464. * @param onError defines the callback to trigger in case of error
  109465. */
  109466. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109467. /**
  109468. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109469. * @param data contains the texture data
  109470. * @param texture defines the BabylonJS internal texture
  109471. * @param callback defines the method to call once ready to upload
  109472. */
  109473. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  109474. }
  109475. }
  109476. declare module BABYLON {
  109477. /**
  109478. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  109479. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  109480. */
  109481. export class KhronosTextureContainer {
  109482. /** contents of the KTX container file */
  109483. arrayBuffer: any;
  109484. private static HEADER_LEN;
  109485. private static COMPRESSED_2D;
  109486. private static COMPRESSED_3D;
  109487. private static TEX_2D;
  109488. private static TEX_3D;
  109489. /**
  109490. * Gets the openGL type
  109491. */
  109492. glType: number;
  109493. /**
  109494. * Gets the openGL type size
  109495. */
  109496. glTypeSize: number;
  109497. /**
  109498. * Gets the openGL format
  109499. */
  109500. glFormat: number;
  109501. /**
  109502. * Gets the openGL internal format
  109503. */
  109504. glInternalFormat: number;
  109505. /**
  109506. * Gets the base internal format
  109507. */
  109508. glBaseInternalFormat: number;
  109509. /**
  109510. * Gets image width in pixel
  109511. */
  109512. pixelWidth: number;
  109513. /**
  109514. * Gets image height in pixel
  109515. */
  109516. pixelHeight: number;
  109517. /**
  109518. * Gets image depth in pixels
  109519. */
  109520. pixelDepth: number;
  109521. /**
  109522. * Gets the number of array elements
  109523. */
  109524. numberOfArrayElements: number;
  109525. /**
  109526. * Gets the number of faces
  109527. */
  109528. numberOfFaces: number;
  109529. /**
  109530. * Gets the number of mipmap levels
  109531. */
  109532. numberOfMipmapLevels: number;
  109533. /**
  109534. * Gets the bytes of key value data
  109535. */
  109536. bytesOfKeyValueData: number;
  109537. /**
  109538. * Gets the load type
  109539. */
  109540. loadType: number;
  109541. /**
  109542. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  109543. */
  109544. isInvalid: boolean;
  109545. /**
  109546. * Creates a new KhronosTextureContainer
  109547. * @param arrayBuffer contents of the KTX container file
  109548. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  109549. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  109550. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  109551. */
  109552. constructor(
  109553. /** contents of the KTX container file */
  109554. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  109555. /**
  109556. * Uploads KTX content to a Babylon Texture.
  109557. * It is assumed that the texture has already been created & is currently bound
  109558. * @hidden
  109559. */
  109560. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  109561. private _upload2DCompressedLevels;
  109562. }
  109563. }
  109564. declare module BABYLON {
  109565. /**
  109566. * Implementation of the KTX Texture Loader.
  109567. * @hidden
  109568. */
  109569. export class _KTXTextureLoader implements IInternalTextureLoader {
  109570. /**
  109571. * Defines wether the loader supports cascade loading the different faces.
  109572. */
  109573. readonly supportCascades: boolean;
  109574. /**
  109575. * This returns if the loader support the current file information.
  109576. * @param extension defines the file extension of the file being loaded
  109577. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109578. * @param fallback defines the fallback internal texture if any
  109579. * @param isBase64 defines whether the texture is encoded as a base64
  109580. * @param isBuffer defines whether the texture data are stored as a buffer
  109581. * @returns true if the loader can load the specified file
  109582. */
  109583. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  109584. /**
  109585. * Transform the url before loading if required.
  109586. * @param rootUrl the url of the texture
  109587. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109588. * @returns the transformed texture
  109589. */
  109590. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  109591. /**
  109592. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  109593. * @param rootUrl the url of the texture
  109594. * @param textureFormatInUse defines the current compressed format in use iun the engine
  109595. * @returns the fallback texture
  109596. */
  109597. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  109598. /**
  109599. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  109600. * @param data contains the texture data
  109601. * @param texture defines the BabylonJS internal texture
  109602. * @param createPolynomials will be true if polynomials have been requested
  109603. * @param onLoad defines the callback to trigger once the texture is ready
  109604. * @param onError defines the callback to trigger in case of error
  109605. */
  109606. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  109607. /**
  109608. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  109609. * @param data contains the texture data
  109610. * @param texture defines the BabylonJS internal texture
  109611. * @param callback defines the method to call once ready to upload
  109612. */
  109613. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  109614. }
  109615. }
  109616. declare module BABYLON {
  109617. /** @hidden */
  109618. export var _forceSceneHelpersToBundle: boolean;
  109619. interface Scene {
  109620. /**
  109621. * Creates a default light for the scene.
  109622. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  109623. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  109624. */
  109625. createDefaultLight(replace?: boolean): void;
  109626. /**
  109627. * Creates a default camera for the scene.
  109628. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  109629. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  109630. * @param replace has default false, when true replaces the active camera in the scene
  109631. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  109632. */
  109633. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  109634. /**
  109635. * Creates a default camera and a default light.
  109636. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  109637. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  109638. * @param replace has the default false, when true replaces the active camera/light in the scene
  109639. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  109640. */
  109641. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  109642. /**
  109643. * Creates a new sky box
  109644. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  109645. * @param environmentTexture defines the texture to use as environment texture
  109646. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  109647. * @param scale defines the overall scale of the skybox
  109648. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  109649. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  109650. * @returns a new mesh holding the sky box
  109651. */
  109652. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  109653. /**
  109654. * Creates a new environment
  109655. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  109656. * @param options defines the options you can use to configure the environment
  109657. * @returns the new EnvironmentHelper
  109658. */
  109659. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  109660. /**
  109661. * Creates a new VREXperienceHelper
  109662. * @see http://doc.babylonjs.com/how_to/webvr_helper
  109663. * @param webVROptions defines the options used to create the new VREXperienceHelper
  109664. * @returns a new VREXperienceHelper
  109665. */
  109666. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  109667. /**
  109668. * Creates a new XREXperienceHelper
  109669. * @see http://doc.babylonjs.com/how_to/webxr
  109670. * @returns a promise for a new XREXperienceHelper
  109671. */
  109672. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  109673. }
  109674. }
  109675. declare module BABYLON {
  109676. /**
  109677. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  109678. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  109679. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  109680. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  109681. */
  109682. export class VideoDome extends TransformNode {
  109683. /**
  109684. * Define the video source as a Monoscopic panoramic 360 video.
  109685. */
  109686. static readonly MODE_MONOSCOPIC: number;
  109687. /**
  109688. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  109689. */
  109690. static readonly MODE_TOPBOTTOM: number;
  109691. /**
  109692. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  109693. */
  109694. static readonly MODE_SIDEBYSIDE: number;
  109695. private _useDirectMapping;
  109696. /**
  109697. * The video texture being displayed on the sphere
  109698. */
  109699. protected _videoTexture: VideoTexture;
  109700. /**
  109701. * Gets the video texture being displayed on the sphere
  109702. */
  109703. readonly videoTexture: VideoTexture;
  109704. /**
  109705. * The skybox material
  109706. */
  109707. protected _material: BackgroundMaterial;
  109708. /**
  109709. * The surface used for the skybox
  109710. */
  109711. protected _mesh: Mesh;
  109712. /**
  109713. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  109714. * Also see the options.resolution property.
  109715. */
  109716. fovMultiplier: number;
  109717. private _videoMode;
  109718. /**
  109719. * Gets or set the current video mode for the video. It can be:
  109720. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  109721. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  109722. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  109723. */
  109724. videoMode: number;
  109725. /**
  109726. * Oberserver used in Stereoscopic VR Mode.
  109727. */
  109728. private _onBeforeCameraRenderObserver;
  109729. /**
  109730. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  109731. * @param name Element's name, child elements will append suffixes for their own names.
  109732. * @param urlsOrVideo defines the url(s) or the video element to use
  109733. * @param options An object containing optional or exposed sub element properties
  109734. */
  109735. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  109736. resolution?: number;
  109737. clickToPlay?: boolean;
  109738. autoPlay?: boolean;
  109739. loop?: boolean;
  109740. size?: number;
  109741. poster?: string;
  109742. faceForward?: boolean;
  109743. useDirectMapping?: boolean;
  109744. }, scene: Scene);
  109745. private _changeVideoMode;
  109746. /**
  109747. * Releases resources associated with this node.
  109748. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109749. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109750. */
  109751. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109752. }
  109753. }
  109754. declare module BABYLON {
  109755. /**
  109756. * This class can be used to get instrumentation data from a Babylon engine
  109757. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  109758. */
  109759. export class EngineInstrumentation implements IDisposable {
  109760. /**
  109761. * Define the instrumented engine.
  109762. */
  109763. engine: Engine;
  109764. private _captureGPUFrameTime;
  109765. private _gpuFrameTimeToken;
  109766. private _gpuFrameTime;
  109767. private _captureShaderCompilationTime;
  109768. private _shaderCompilationTime;
  109769. private _onBeginFrameObserver;
  109770. private _onEndFrameObserver;
  109771. private _onBeforeShaderCompilationObserver;
  109772. private _onAfterShaderCompilationObserver;
  109773. /**
  109774. * Gets the perf counter used for GPU frame time
  109775. */
  109776. readonly gpuFrameTimeCounter: PerfCounter;
  109777. /**
  109778. * Gets the GPU frame time capture status
  109779. */
  109780. /**
  109781. * Enable or disable the GPU frame time capture
  109782. */
  109783. captureGPUFrameTime: boolean;
  109784. /**
  109785. * Gets the perf counter used for shader compilation time
  109786. */
  109787. readonly shaderCompilationTimeCounter: PerfCounter;
  109788. /**
  109789. * Gets the shader compilation time capture status
  109790. */
  109791. /**
  109792. * Enable or disable the shader compilation time capture
  109793. */
  109794. captureShaderCompilationTime: boolean;
  109795. /**
  109796. * Instantiates a new engine instrumentation.
  109797. * This class can be used to get instrumentation data from a Babylon engine
  109798. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  109799. * @param engine Defines the engine to instrument
  109800. */
  109801. constructor(
  109802. /**
  109803. * Define the instrumented engine.
  109804. */
  109805. engine: Engine);
  109806. /**
  109807. * Dispose and release associated resources.
  109808. */
  109809. dispose(): void;
  109810. }
  109811. }
  109812. declare module BABYLON {
  109813. /**
  109814. * This class can be used to get instrumentation data from a Babylon engine
  109815. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  109816. */
  109817. export class SceneInstrumentation implements IDisposable {
  109818. /**
  109819. * Defines the scene to instrument
  109820. */
  109821. scene: Scene;
  109822. private _captureActiveMeshesEvaluationTime;
  109823. private _activeMeshesEvaluationTime;
  109824. private _captureRenderTargetsRenderTime;
  109825. private _renderTargetsRenderTime;
  109826. private _captureFrameTime;
  109827. private _frameTime;
  109828. private _captureRenderTime;
  109829. private _renderTime;
  109830. private _captureInterFrameTime;
  109831. private _interFrameTime;
  109832. private _captureParticlesRenderTime;
  109833. private _particlesRenderTime;
  109834. private _captureSpritesRenderTime;
  109835. private _spritesRenderTime;
  109836. private _capturePhysicsTime;
  109837. private _physicsTime;
  109838. private _captureAnimationsTime;
  109839. private _animationsTime;
  109840. private _captureCameraRenderTime;
  109841. private _cameraRenderTime;
  109842. private _onBeforeActiveMeshesEvaluationObserver;
  109843. private _onAfterActiveMeshesEvaluationObserver;
  109844. private _onBeforeRenderTargetsRenderObserver;
  109845. private _onAfterRenderTargetsRenderObserver;
  109846. private _onAfterRenderObserver;
  109847. private _onBeforeDrawPhaseObserver;
  109848. private _onAfterDrawPhaseObserver;
  109849. private _onBeforeAnimationsObserver;
  109850. private _onBeforeParticlesRenderingObserver;
  109851. private _onAfterParticlesRenderingObserver;
  109852. private _onBeforeSpritesRenderingObserver;
  109853. private _onAfterSpritesRenderingObserver;
  109854. private _onBeforePhysicsObserver;
  109855. private _onAfterPhysicsObserver;
  109856. private _onAfterAnimationsObserver;
  109857. private _onBeforeCameraRenderObserver;
  109858. private _onAfterCameraRenderObserver;
  109859. /**
  109860. * Gets the perf counter used for active meshes evaluation time
  109861. */
  109862. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  109863. /**
  109864. * Gets the active meshes evaluation time capture status
  109865. */
  109866. /**
  109867. * Enable or disable the active meshes evaluation time capture
  109868. */
  109869. captureActiveMeshesEvaluationTime: boolean;
  109870. /**
  109871. * Gets the perf counter used for render targets render time
  109872. */
  109873. readonly renderTargetsRenderTimeCounter: PerfCounter;
  109874. /**
  109875. * Gets the render targets render time capture status
  109876. */
  109877. /**
  109878. * Enable or disable the render targets render time capture
  109879. */
  109880. captureRenderTargetsRenderTime: boolean;
  109881. /**
  109882. * Gets the perf counter used for particles render time
  109883. */
  109884. readonly particlesRenderTimeCounter: PerfCounter;
  109885. /**
  109886. * Gets the particles render time capture status
  109887. */
  109888. /**
  109889. * Enable or disable the particles render time capture
  109890. */
  109891. captureParticlesRenderTime: boolean;
  109892. /**
  109893. * Gets the perf counter used for sprites render time
  109894. */
  109895. readonly spritesRenderTimeCounter: PerfCounter;
  109896. /**
  109897. * Gets the sprites render time capture status
  109898. */
  109899. /**
  109900. * Enable or disable the sprites render time capture
  109901. */
  109902. captureSpritesRenderTime: boolean;
  109903. /**
  109904. * Gets the perf counter used for physics time
  109905. */
  109906. readonly physicsTimeCounter: PerfCounter;
  109907. /**
  109908. * Gets the physics time capture status
  109909. */
  109910. /**
  109911. * Enable or disable the physics time capture
  109912. */
  109913. capturePhysicsTime: boolean;
  109914. /**
  109915. * Gets the perf counter used for animations time
  109916. */
  109917. readonly animationsTimeCounter: PerfCounter;
  109918. /**
  109919. * Gets the animations time capture status
  109920. */
  109921. /**
  109922. * Enable or disable the animations time capture
  109923. */
  109924. captureAnimationsTime: boolean;
  109925. /**
  109926. * Gets the perf counter used for frame time capture
  109927. */
  109928. readonly frameTimeCounter: PerfCounter;
  109929. /**
  109930. * Gets the frame time capture status
  109931. */
  109932. /**
  109933. * Enable or disable the frame time capture
  109934. */
  109935. captureFrameTime: boolean;
  109936. /**
  109937. * Gets the perf counter used for inter-frames time capture
  109938. */
  109939. readonly interFrameTimeCounter: PerfCounter;
  109940. /**
  109941. * Gets the inter-frames time capture status
  109942. */
  109943. /**
  109944. * Enable or disable the inter-frames time capture
  109945. */
  109946. captureInterFrameTime: boolean;
  109947. /**
  109948. * Gets the perf counter used for render time capture
  109949. */
  109950. readonly renderTimeCounter: PerfCounter;
  109951. /**
  109952. * Gets the render time capture status
  109953. */
  109954. /**
  109955. * Enable or disable the render time capture
  109956. */
  109957. captureRenderTime: boolean;
  109958. /**
  109959. * Gets the perf counter used for camera render time capture
  109960. */
  109961. readonly cameraRenderTimeCounter: PerfCounter;
  109962. /**
  109963. * Gets the camera render time capture status
  109964. */
  109965. /**
  109966. * Enable or disable the camera render time capture
  109967. */
  109968. captureCameraRenderTime: boolean;
  109969. /**
  109970. * Gets the perf counter used for draw calls
  109971. */
  109972. readonly drawCallsCounter: PerfCounter;
  109973. /**
  109974. * Instantiates a new scene instrumentation.
  109975. * This class can be used to get instrumentation data from a Babylon engine
  109976. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  109977. * @param scene Defines the scene to instrument
  109978. */
  109979. constructor(
  109980. /**
  109981. * Defines the scene to instrument
  109982. */
  109983. scene: Scene);
  109984. /**
  109985. * Dispose and release associated resources.
  109986. */
  109987. dispose(): void;
  109988. }
  109989. }
  109990. declare module BABYLON {
  109991. /** @hidden */
  109992. export var glowMapGenerationPixelShader: {
  109993. name: string;
  109994. shader: string;
  109995. };
  109996. }
  109997. declare module BABYLON {
  109998. /** @hidden */
  109999. export var glowMapGenerationVertexShader: {
  110000. name: string;
  110001. shader: string;
  110002. };
  110003. }
  110004. declare module BABYLON {
  110005. /**
  110006. * Effect layer options. This helps customizing the behaviour
  110007. * of the effect layer.
  110008. */
  110009. export interface IEffectLayerOptions {
  110010. /**
  110011. * Multiplication factor apply to the canvas size to compute the render target size
  110012. * used to generated the objects (the smaller the faster).
  110013. */
  110014. mainTextureRatio: number;
  110015. /**
  110016. * Enforces a fixed size texture to ensure effect stability across devices.
  110017. */
  110018. mainTextureFixedSize?: number;
  110019. /**
  110020. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  110021. */
  110022. alphaBlendingMode: number;
  110023. /**
  110024. * The camera attached to the layer.
  110025. */
  110026. camera: Nullable<Camera>;
  110027. /**
  110028. * The rendering group to draw the layer in.
  110029. */
  110030. renderingGroupId: number;
  110031. }
  110032. /**
  110033. * The effect layer Helps adding post process effect blended with the main pass.
  110034. *
  110035. * This can be for instance use to generate glow or higlight effects on the scene.
  110036. *
  110037. * The effect layer class can not be used directly and is intented to inherited from to be
  110038. * customized per effects.
  110039. */
  110040. export abstract class EffectLayer {
  110041. private _vertexBuffers;
  110042. private _indexBuffer;
  110043. private _cachedDefines;
  110044. private _effectLayerMapGenerationEffect;
  110045. private _effectLayerOptions;
  110046. private _mergeEffect;
  110047. protected _scene: Scene;
  110048. protected _engine: Engine;
  110049. protected _maxSize: number;
  110050. protected _mainTextureDesiredSize: ISize;
  110051. protected _mainTexture: RenderTargetTexture;
  110052. protected _shouldRender: boolean;
  110053. protected _postProcesses: PostProcess[];
  110054. protected _textures: BaseTexture[];
  110055. protected _emissiveTextureAndColor: {
  110056. texture: Nullable<BaseTexture>;
  110057. color: Color4;
  110058. };
  110059. /**
  110060. * The name of the layer
  110061. */
  110062. name: string;
  110063. /**
  110064. * The clear color of the texture used to generate the glow map.
  110065. */
  110066. neutralColor: Color4;
  110067. /**
  110068. * Specifies wether the highlight layer is enabled or not.
  110069. */
  110070. isEnabled: boolean;
  110071. /**
  110072. * Gets the camera attached to the layer.
  110073. */
  110074. readonly camera: Nullable<Camera>;
  110075. /**
  110076. * Gets the rendering group id the layer should render in.
  110077. */
  110078. renderingGroupId: number;
  110079. /**
  110080. * An event triggered when the effect layer has been disposed.
  110081. */
  110082. onDisposeObservable: Observable<EffectLayer>;
  110083. /**
  110084. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  110085. */
  110086. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  110087. /**
  110088. * An event triggered when the generated texture is being merged in the scene.
  110089. */
  110090. onBeforeComposeObservable: Observable<EffectLayer>;
  110091. /**
  110092. * An event triggered when the generated texture has been merged in the scene.
  110093. */
  110094. onAfterComposeObservable: Observable<EffectLayer>;
  110095. /**
  110096. * An event triggered when the efffect layer changes its size.
  110097. */
  110098. onSizeChangedObservable: Observable<EffectLayer>;
  110099. /** @hidden */
  110100. static _SceneComponentInitialization: (scene: Scene) => void;
  110101. /**
  110102. * Instantiates a new effect Layer and references it in the scene.
  110103. * @param name The name of the layer
  110104. * @param scene The scene to use the layer in
  110105. */
  110106. constructor(
  110107. /** The Friendly of the effect in the scene */
  110108. name: string, scene: Scene);
  110109. /**
  110110. * Get the effect name of the layer.
  110111. * @return The effect name
  110112. */
  110113. abstract getEffectName(): string;
  110114. /**
  110115. * Checks for the readiness of the element composing the layer.
  110116. * @param subMesh the mesh to check for
  110117. * @param useInstances specify wether or not to use instances to render the mesh
  110118. * @return true if ready otherwise, false
  110119. */
  110120. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110121. /**
  110122. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  110123. * @returns true if the effect requires stencil during the main canvas render pass.
  110124. */
  110125. abstract needStencil(): boolean;
  110126. /**
  110127. * Create the merge effect. This is the shader use to blit the information back
  110128. * to the main canvas at the end of the scene rendering.
  110129. * @returns The effect containing the shader used to merge the effect on the main canvas
  110130. */
  110131. protected abstract _createMergeEffect(): Effect;
  110132. /**
  110133. * Creates the render target textures and post processes used in the effect layer.
  110134. */
  110135. protected abstract _createTextureAndPostProcesses(): void;
  110136. /**
  110137. * Implementation specific of rendering the generating effect on the main canvas.
  110138. * @param effect The effect used to render through
  110139. */
  110140. protected abstract _internalRender(effect: Effect): void;
  110141. /**
  110142. * Sets the required values for both the emissive texture and and the main color.
  110143. */
  110144. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  110145. /**
  110146. * Free any resources and references associated to a mesh.
  110147. * Internal use
  110148. * @param mesh The mesh to free.
  110149. */
  110150. abstract _disposeMesh(mesh: Mesh): void;
  110151. /**
  110152. * Serializes this layer (Glow or Highlight for example)
  110153. * @returns a serialized layer object
  110154. */
  110155. abstract serialize?(): any;
  110156. /**
  110157. * Initializes the effect layer with the required options.
  110158. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  110159. */
  110160. protected _init(options: Partial<IEffectLayerOptions>): void;
  110161. /**
  110162. * Generates the index buffer of the full screen quad blending to the main canvas.
  110163. */
  110164. private _generateIndexBuffer;
  110165. /**
  110166. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  110167. */
  110168. private _generateVertexBuffer;
  110169. /**
  110170. * Sets the main texture desired size which is the closest power of two
  110171. * of the engine canvas size.
  110172. */
  110173. private _setMainTextureSize;
  110174. /**
  110175. * Creates the main texture for the effect layer.
  110176. */
  110177. protected _createMainTexture(): void;
  110178. /**
  110179. * Adds specific effects defines.
  110180. * @param defines The defines to add specifics to.
  110181. */
  110182. protected _addCustomEffectDefines(defines: string[]): void;
  110183. /**
  110184. * Checks for the readiness of the element composing the layer.
  110185. * @param subMesh the mesh to check for
  110186. * @param useInstances specify wether or not to use instances to render the mesh
  110187. * @param emissiveTexture the associated emissive texture used to generate the glow
  110188. * @return true if ready otherwise, false
  110189. */
  110190. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  110191. /**
  110192. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  110193. */
  110194. render(): void;
  110195. /**
  110196. * Determine if a given mesh will be used in the current effect.
  110197. * @param mesh mesh to test
  110198. * @returns true if the mesh will be used
  110199. */
  110200. hasMesh(mesh: AbstractMesh): boolean;
  110201. /**
  110202. * Returns true if the layer contains information to display, otherwise false.
  110203. * @returns true if the glow layer should be rendered
  110204. */
  110205. shouldRender(): boolean;
  110206. /**
  110207. * Returns true if the mesh should render, otherwise false.
  110208. * @param mesh The mesh to render
  110209. * @returns true if it should render otherwise false
  110210. */
  110211. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  110212. /**
  110213. * Returns true if the mesh can be rendered, otherwise false.
  110214. * @param mesh The mesh to render
  110215. * @param material The material used on the mesh
  110216. * @returns true if it can be rendered otherwise false
  110217. */
  110218. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  110219. /**
  110220. * Returns true if the mesh should render, otherwise false.
  110221. * @param mesh The mesh to render
  110222. * @returns true if it should render otherwise false
  110223. */
  110224. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  110225. /**
  110226. * Renders the submesh passed in parameter to the generation map.
  110227. */
  110228. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  110229. /**
  110230. * Rebuild the required buffers.
  110231. * @hidden Internal use only.
  110232. */
  110233. _rebuild(): void;
  110234. /**
  110235. * Dispose only the render target textures and post process.
  110236. */
  110237. private _disposeTextureAndPostProcesses;
  110238. /**
  110239. * Dispose the highlight layer and free resources.
  110240. */
  110241. dispose(): void;
  110242. /**
  110243. * Gets the class name of the effect layer
  110244. * @returns the string with the class name of the effect layer
  110245. */
  110246. getClassName(): string;
  110247. /**
  110248. * Creates an effect layer from parsed effect layer data
  110249. * @param parsedEffectLayer defines effect layer data
  110250. * @param scene defines the current scene
  110251. * @param rootUrl defines the root URL containing the effect layer information
  110252. * @returns a parsed effect Layer
  110253. */
  110254. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  110255. }
  110256. }
  110257. declare module BABYLON {
  110258. interface AbstractScene {
  110259. /**
  110260. * The list of effect layers (highlights/glow) added to the scene
  110261. * @see http://doc.babylonjs.com/how_to/highlight_layer
  110262. * @see http://doc.babylonjs.com/how_to/glow_layer
  110263. */
  110264. effectLayers: Array<EffectLayer>;
  110265. /**
  110266. * Removes the given effect layer from this scene.
  110267. * @param toRemove defines the effect layer to remove
  110268. * @returns the index of the removed effect layer
  110269. */
  110270. removeEffectLayer(toRemove: EffectLayer): number;
  110271. /**
  110272. * Adds the given effect layer to this scene
  110273. * @param newEffectLayer defines the effect layer to add
  110274. */
  110275. addEffectLayer(newEffectLayer: EffectLayer): void;
  110276. }
  110277. /**
  110278. * Defines the layer scene component responsible to manage any effect layers
  110279. * in a given scene.
  110280. */
  110281. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  110282. /**
  110283. * The component name helpfull to identify the component in the list of scene components.
  110284. */
  110285. readonly name: string;
  110286. /**
  110287. * The scene the component belongs to.
  110288. */
  110289. scene: Scene;
  110290. private _engine;
  110291. private _renderEffects;
  110292. private _needStencil;
  110293. private _previousStencilState;
  110294. /**
  110295. * Creates a new instance of the component for the given scene
  110296. * @param scene Defines the scene to register the component in
  110297. */
  110298. constructor(scene: Scene);
  110299. /**
  110300. * Registers the component in a given scene
  110301. */
  110302. register(): void;
  110303. /**
  110304. * Rebuilds the elements related to this component in case of
  110305. * context lost for instance.
  110306. */
  110307. rebuild(): void;
  110308. /**
  110309. * Serializes the component data to the specified json object
  110310. * @param serializationObject The object to serialize to
  110311. */
  110312. serialize(serializationObject: any): void;
  110313. /**
  110314. * Adds all the elements from the container to the scene
  110315. * @param container the container holding the elements
  110316. */
  110317. addFromContainer(container: AbstractScene): void;
  110318. /**
  110319. * Removes all the elements in the container from the scene
  110320. * @param container contains the elements to remove
  110321. * @param dispose if the removed element should be disposed (default: false)
  110322. */
  110323. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110324. /**
  110325. * Disposes the component and the associated ressources.
  110326. */
  110327. dispose(): void;
  110328. private _isReadyForMesh;
  110329. private _renderMainTexture;
  110330. private _setStencil;
  110331. private _setStencilBack;
  110332. private _draw;
  110333. private _drawCamera;
  110334. private _drawRenderingGroup;
  110335. }
  110336. }
  110337. declare module BABYLON {
  110338. /** @hidden */
  110339. export var glowMapMergePixelShader: {
  110340. name: string;
  110341. shader: string;
  110342. };
  110343. }
  110344. declare module BABYLON {
  110345. /** @hidden */
  110346. export var glowMapMergeVertexShader: {
  110347. name: string;
  110348. shader: string;
  110349. };
  110350. }
  110351. declare module BABYLON {
  110352. interface AbstractScene {
  110353. /**
  110354. * Return a the first highlight layer of the scene with a given name.
  110355. * @param name The name of the highlight layer to look for.
  110356. * @return The highlight layer if found otherwise null.
  110357. */
  110358. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  110359. }
  110360. /**
  110361. * Glow layer options. This helps customizing the behaviour
  110362. * of the glow layer.
  110363. */
  110364. export interface IGlowLayerOptions {
  110365. /**
  110366. * Multiplication factor apply to the canvas size to compute the render target size
  110367. * used to generated the glowing objects (the smaller the faster).
  110368. */
  110369. mainTextureRatio: number;
  110370. /**
  110371. * Enforces a fixed size texture to ensure resize independant blur.
  110372. */
  110373. mainTextureFixedSize?: number;
  110374. /**
  110375. * How big is the kernel of the blur texture.
  110376. */
  110377. blurKernelSize: number;
  110378. /**
  110379. * The camera attached to the layer.
  110380. */
  110381. camera: Nullable<Camera>;
  110382. /**
  110383. * Enable MSAA by chosing the number of samples.
  110384. */
  110385. mainTextureSamples?: number;
  110386. /**
  110387. * The rendering group to draw the layer in.
  110388. */
  110389. renderingGroupId: number;
  110390. }
  110391. /**
  110392. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  110393. *
  110394. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  110395. * glowy meshes to your scene.
  110396. *
  110397. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  110398. */
  110399. export class GlowLayer extends EffectLayer {
  110400. /**
  110401. * Effect Name of the layer.
  110402. */
  110403. static readonly EffectName: string;
  110404. /**
  110405. * The default blur kernel size used for the glow.
  110406. */
  110407. static DefaultBlurKernelSize: number;
  110408. /**
  110409. * The default texture size ratio used for the glow.
  110410. */
  110411. static DefaultTextureRatio: number;
  110412. /**
  110413. * Sets the kernel size of the blur.
  110414. */
  110415. /**
  110416. * Gets the kernel size of the blur.
  110417. */
  110418. blurKernelSize: number;
  110419. /**
  110420. * Sets the glow intensity.
  110421. */
  110422. /**
  110423. * Gets the glow intensity.
  110424. */
  110425. intensity: number;
  110426. private _options;
  110427. private _intensity;
  110428. private _horizontalBlurPostprocess1;
  110429. private _verticalBlurPostprocess1;
  110430. private _horizontalBlurPostprocess2;
  110431. private _verticalBlurPostprocess2;
  110432. private _blurTexture1;
  110433. private _blurTexture2;
  110434. private _postProcesses1;
  110435. private _postProcesses2;
  110436. private _includedOnlyMeshes;
  110437. private _excludedMeshes;
  110438. /**
  110439. * Callback used to let the user override the color selection on a per mesh basis
  110440. */
  110441. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  110442. /**
  110443. * Callback used to let the user override the texture selection on a per mesh basis
  110444. */
  110445. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  110446. /**
  110447. * Instantiates a new glow Layer and references it to the scene.
  110448. * @param name The name of the layer
  110449. * @param scene The scene to use the layer in
  110450. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  110451. */
  110452. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  110453. /**
  110454. * Get the effect name of the layer.
  110455. * @return The effect name
  110456. */
  110457. getEffectName(): string;
  110458. /**
  110459. * Create the merge effect. This is the shader use to blit the information back
  110460. * to the main canvas at the end of the scene rendering.
  110461. */
  110462. protected _createMergeEffect(): Effect;
  110463. /**
  110464. * Creates the render target textures and post processes used in the glow layer.
  110465. */
  110466. protected _createTextureAndPostProcesses(): void;
  110467. /**
  110468. * Checks for the readiness of the element composing the layer.
  110469. * @param subMesh the mesh to check for
  110470. * @param useInstances specify wether or not to use instances to render the mesh
  110471. * @param emissiveTexture the associated emissive texture used to generate the glow
  110472. * @return true if ready otherwise, false
  110473. */
  110474. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110475. /**
  110476. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  110477. */
  110478. needStencil(): boolean;
  110479. /**
  110480. * Returns true if the mesh can be rendered, otherwise false.
  110481. * @param mesh The mesh to render
  110482. * @param material The material used on the mesh
  110483. * @returns true if it can be rendered otherwise false
  110484. */
  110485. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  110486. /**
  110487. * Implementation specific of rendering the generating effect on the main canvas.
  110488. * @param effect The effect used to render through
  110489. */
  110490. protected _internalRender(effect: Effect): void;
  110491. /**
  110492. * Sets the required values for both the emissive texture and and the main color.
  110493. */
  110494. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  110495. /**
  110496. * Returns true if the mesh should render, otherwise false.
  110497. * @param mesh The mesh to render
  110498. * @returns true if it should render otherwise false
  110499. */
  110500. protected _shouldRenderMesh(mesh: Mesh): boolean;
  110501. /**
  110502. * Adds specific effects defines.
  110503. * @param defines The defines to add specifics to.
  110504. */
  110505. protected _addCustomEffectDefines(defines: string[]): void;
  110506. /**
  110507. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  110508. * @param mesh The mesh to exclude from the glow layer
  110509. */
  110510. addExcludedMesh(mesh: Mesh): void;
  110511. /**
  110512. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  110513. * @param mesh The mesh to remove
  110514. */
  110515. removeExcludedMesh(mesh: Mesh): void;
  110516. /**
  110517. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  110518. * @param mesh The mesh to include in the glow layer
  110519. */
  110520. addIncludedOnlyMesh(mesh: Mesh): void;
  110521. /**
  110522. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  110523. * @param mesh The mesh to remove
  110524. */
  110525. removeIncludedOnlyMesh(mesh: Mesh): void;
  110526. /**
  110527. * Determine if a given mesh will be used in the glow layer
  110528. * @param mesh The mesh to test
  110529. * @returns true if the mesh will be highlighted by the current glow layer
  110530. */
  110531. hasMesh(mesh: AbstractMesh): boolean;
  110532. /**
  110533. * Free any resources and references associated to a mesh.
  110534. * Internal use
  110535. * @param mesh The mesh to free.
  110536. * @hidden
  110537. */
  110538. _disposeMesh(mesh: Mesh): void;
  110539. /**
  110540. * Gets the class name of the effect layer
  110541. * @returns the string with the class name of the effect layer
  110542. */
  110543. getClassName(): string;
  110544. /**
  110545. * Serializes this glow layer
  110546. * @returns a serialized glow layer object
  110547. */
  110548. serialize(): any;
  110549. /**
  110550. * Creates a Glow Layer from parsed glow layer data
  110551. * @param parsedGlowLayer defines glow layer data
  110552. * @param scene defines the current scene
  110553. * @param rootUrl defines the root URL containing the glow layer information
  110554. * @returns a parsed Glow Layer
  110555. */
  110556. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  110557. }
  110558. }
  110559. declare module BABYLON {
  110560. /** @hidden */
  110561. export var glowBlurPostProcessPixelShader: {
  110562. name: string;
  110563. shader: string;
  110564. };
  110565. }
  110566. declare module BABYLON {
  110567. interface AbstractScene {
  110568. /**
  110569. * Return a the first highlight layer of the scene with a given name.
  110570. * @param name The name of the highlight layer to look for.
  110571. * @return The highlight layer if found otherwise null.
  110572. */
  110573. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  110574. }
  110575. /**
  110576. * Highlight layer options. This helps customizing the behaviour
  110577. * of the highlight layer.
  110578. */
  110579. export interface IHighlightLayerOptions {
  110580. /**
  110581. * Multiplication factor apply to the canvas size to compute the render target size
  110582. * used to generated the glowing objects (the smaller the faster).
  110583. */
  110584. mainTextureRatio: number;
  110585. /**
  110586. * Enforces a fixed size texture to ensure resize independant blur.
  110587. */
  110588. mainTextureFixedSize?: number;
  110589. /**
  110590. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  110591. * of the picture to blur (the smaller the faster).
  110592. */
  110593. blurTextureSizeRatio: number;
  110594. /**
  110595. * How big in texel of the blur texture is the vertical blur.
  110596. */
  110597. blurVerticalSize: number;
  110598. /**
  110599. * How big in texel of the blur texture is the horizontal blur.
  110600. */
  110601. blurHorizontalSize: number;
  110602. /**
  110603. * Alpha blending mode used to apply the blur. Default is combine.
  110604. */
  110605. alphaBlendingMode: number;
  110606. /**
  110607. * The camera attached to the layer.
  110608. */
  110609. camera: Nullable<Camera>;
  110610. /**
  110611. * Should we display highlight as a solid stroke?
  110612. */
  110613. isStroke?: boolean;
  110614. /**
  110615. * The rendering group to draw the layer in.
  110616. */
  110617. renderingGroupId: number;
  110618. }
  110619. /**
  110620. * The highlight layer Helps adding a glow effect around a mesh.
  110621. *
  110622. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  110623. * glowy meshes to your scene.
  110624. *
  110625. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  110626. */
  110627. export class HighlightLayer extends EffectLayer {
  110628. name: string;
  110629. /**
  110630. * Effect Name of the highlight layer.
  110631. */
  110632. static readonly EffectName: string;
  110633. /**
  110634. * The neutral color used during the preparation of the glow effect.
  110635. * This is black by default as the blend operation is a blend operation.
  110636. */
  110637. static NeutralColor: Color4;
  110638. /**
  110639. * Stencil value used for glowing meshes.
  110640. */
  110641. static GlowingMeshStencilReference: number;
  110642. /**
  110643. * Stencil value used for the other meshes in the scene.
  110644. */
  110645. static NormalMeshStencilReference: number;
  110646. /**
  110647. * Specifies whether or not the inner glow is ACTIVE in the layer.
  110648. */
  110649. innerGlow: boolean;
  110650. /**
  110651. * Specifies whether or not the outer glow is ACTIVE in the layer.
  110652. */
  110653. outerGlow: boolean;
  110654. /**
  110655. * Specifies the horizontal size of the blur.
  110656. */
  110657. /**
  110658. * Gets the horizontal size of the blur.
  110659. */
  110660. blurHorizontalSize: number;
  110661. /**
  110662. * Specifies the vertical size of the blur.
  110663. */
  110664. /**
  110665. * Gets the vertical size of the blur.
  110666. */
  110667. blurVerticalSize: number;
  110668. /**
  110669. * An event triggered when the highlight layer is being blurred.
  110670. */
  110671. onBeforeBlurObservable: Observable<HighlightLayer>;
  110672. /**
  110673. * An event triggered when the highlight layer has been blurred.
  110674. */
  110675. onAfterBlurObservable: Observable<HighlightLayer>;
  110676. private _instanceGlowingMeshStencilReference;
  110677. private _options;
  110678. private _downSamplePostprocess;
  110679. private _horizontalBlurPostprocess;
  110680. private _verticalBlurPostprocess;
  110681. private _blurTexture;
  110682. private _meshes;
  110683. private _excludedMeshes;
  110684. /**
  110685. * Instantiates a new highlight Layer and references it to the scene..
  110686. * @param name The name of the layer
  110687. * @param scene The scene to use the layer in
  110688. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  110689. */
  110690. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  110691. /**
  110692. * Get the effect name of the layer.
  110693. * @return The effect name
  110694. */
  110695. getEffectName(): string;
  110696. /**
  110697. * Create the merge effect. This is the shader use to blit the information back
  110698. * to the main canvas at the end of the scene rendering.
  110699. */
  110700. protected _createMergeEffect(): Effect;
  110701. /**
  110702. * Creates the render target textures and post processes used in the highlight layer.
  110703. */
  110704. protected _createTextureAndPostProcesses(): void;
  110705. /**
  110706. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  110707. */
  110708. needStencil(): boolean;
  110709. /**
  110710. * Checks for the readiness of the element composing the layer.
  110711. * @param subMesh the mesh to check for
  110712. * @param useInstances specify wether or not to use instances to render the mesh
  110713. * @param emissiveTexture the associated emissive texture used to generate the glow
  110714. * @return true if ready otherwise, false
  110715. */
  110716. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  110717. /**
  110718. * Implementation specific of rendering the generating effect on the main canvas.
  110719. * @param effect The effect used to render through
  110720. */
  110721. protected _internalRender(effect: Effect): void;
  110722. /**
  110723. * Returns true if the layer contains information to display, otherwise false.
  110724. */
  110725. shouldRender(): boolean;
  110726. /**
  110727. * Returns true if the mesh should render, otherwise false.
  110728. * @param mesh The mesh to render
  110729. * @returns true if it should render otherwise false
  110730. */
  110731. protected _shouldRenderMesh(mesh: Mesh): boolean;
  110732. /**
  110733. * Sets the required values for both the emissive texture and and the main color.
  110734. */
  110735. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  110736. /**
  110737. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  110738. * @param mesh The mesh to exclude from the highlight layer
  110739. */
  110740. addExcludedMesh(mesh: Mesh): void;
  110741. /**
  110742. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  110743. * @param mesh The mesh to highlight
  110744. */
  110745. removeExcludedMesh(mesh: Mesh): void;
  110746. /**
  110747. * Determine if a given mesh will be highlighted by the current HighlightLayer
  110748. * @param mesh mesh to test
  110749. * @returns true if the mesh will be highlighted by the current HighlightLayer
  110750. */
  110751. hasMesh(mesh: AbstractMesh): boolean;
  110752. /**
  110753. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  110754. * @param mesh The mesh to highlight
  110755. * @param color The color of the highlight
  110756. * @param glowEmissiveOnly Extract the glow from the emissive texture
  110757. */
  110758. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  110759. /**
  110760. * Remove a mesh from the highlight layer in order to make it stop glowing.
  110761. * @param mesh The mesh to highlight
  110762. */
  110763. removeMesh(mesh: Mesh): void;
  110764. /**
  110765. * Force the stencil to the normal expected value for none glowing parts
  110766. */
  110767. private _defaultStencilReference;
  110768. /**
  110769. * Free any resources and references associated to a mesh.
  110770. * Internal use
  110771. * @param mesh The mesh to free.
  110772. * @hidden
  110773. */
  110774. _disposeMesh(mesh: Mesh): void;
  110775. /**
  110776. * Dispose the highlight layer and free resources.
  110777. */
  110778. dispose(): void;
  110779. /**
  110780. * Gets the class name of the effect layer
  110781. * @returns the string with the class name of the effect layer
  110782. */
  110783. getClassName(): string;
  110784. /**
  110785. * Serializes this Highlight layer
  110786. * @returns a serialized Highlight layer object
  110787. */
  110788. serialize(): any;
  110789. /**
  110790. * Creates a Highlight layer from parsed Highlight layer data
  110791. * @param parsedHightlightLayer defines the Highlight layer data
  110792. * @param scene defines the current scene
  110793. * @param rootUrl defines the root URL containing the Highlight layer information
  110794. * @returns a parsed Highlight layer
  110795. */
  110796. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  110797. }
  110798. }
  110799. declare module BABYLON {
  110800. interface AbstractScene {
  110801. /**
  110802. * The list of layers (background and foreground) of the scene
  110803. */
  110804. layers: Array<Layer>;
  110805. }
  110806. /**
  110807. * Defines the layer scene component responsible to manage any layers
  110808. * in a given scene.
  110809. */
  110810. export class LayerSceneComponent implements ISceneComponent {
  110811. /**
  110812. * The component name helpfull to identify the component in the list of scene components.
  110813. */
  110814. readonly name: string;
  110815. /**
  110816. * The scene the component belongs to.
  110817. */
  110818. scene: Scene;
  110819. private _engine;
  110820. /**
  110821. * Creates a new instance of the component for the given scene
  110822. * @param scene Defines the scene to register the component in
  110823. */
  110824. constructor(scene: Scene);
  110825. /**
  110826. * Registers the component in a given scene
  110827. */
  110828. register(): void;
  110829. /**
  110830. * Rebuilds the elements related to this component in case of
  110831. * context lost for instance.
  110832. */
  110833. rebuild(): void;
  110834. /**
  110835. * Disposes the component and the associated ressources.
  110836. */
  110837. dispose(): void;
  110838. private _draw;
  110839. private _drawCameraPredicate;
  110840. private _drawCameraBackground;
  110841. private _drawCameraForeground;
  110842. private _drawRenderTargetPredicate;
  110843. private _drawRenderTargetBackground;
  110844. private _drawRenderTargetForeground;
  110845. /**
  110846. * Adds all the elements from the container to the scene
  110847. * @param container the container holding the elements
  110848. */
  110849. addFromContainer(container: AbstractScene): void;
  110850. /**
  110851. * Removes all the elements in the container from the scene
  110852. * @param container contains the elements to remove
  110853. * @param dispose if the removed element should be disposed (default: false)
  110854. */
  110855. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110856. }
  110857. }
  110858. declare module BABYLON {
  110859. /** @hidden */
  110860. export var layerPixelShader: {
  110861. name: string;
  110862. shader: string;
  110863. };
  110864. }
  110865. declare module BABYLON {
  110866. /** @hidden */
  110867. export var layerVertexShader: {
  110868. name: string;
  110869. shader: string;
  110870. };
  110871. }
  110872. declare module BABYLON {
  110873. /**
  110874. * This represents a full screen 2d layer.
  110875. * This can be useful to display a picture in the background of your scene for instance.
  110876. * @see https://www.babylonjs-playground.com/#08A2BS#1
  110877. */
  110878. export class Layer {
  110879. /**
  110880. * Define the name of the layer.
  110881. */
  110882. name: string;
  110883. /**
  110884. * Define the texture the layer should display.
  110885. */
  110886. texture: Nullable<Texture>;
  110887. /**
  110888. * Is the layer in background or foreground.
  110889. */
  110890. isBackground: boolean;
  110891. /**
  110892. * Define the color of the layer (instead of texture).
  110893. */
  110894. color: Color4;
  110895. /**
  110896. * Define the scale of the layer in order to zoom in out of the texture.
  110897. */
  110898. scale: Vector2;
  110899. /**
  110900. * Define an offset for the layer in order to shift the texture.
  110901. */
  110902. offset: Vector2;
  110903. /**
  110904. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  110905. */
  110906. alphaBlendingMode: number;
  110907. /**
  110908. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  110909. * Alpha test will not mix with the background color in case of transparency.
  110910. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  110911. */
  110912. alphaTest: boolean;
  110913. /**
  110914. * Define a mask to restrict the layer to only some of the scene cameras.
  110915. */
  110916. layerMask: number;
  110917. /**
  110918. * Define the list of render target the layer is visible into.
  110919. */
  110920. renderTargetTextures: RenderTargetTexture[];
  110921. /**
  110922. * Define if the layer is only used in renderTarget or if it also
  110923. * renders in the main frame buffer of the canvas.
  110924. */
  110925. renderOnlyInRenderTargetTextures: boolean;
  110926. private _scene;
  110927. private _vertexBuffers;
  110928. private _indexBuffer;
  110929. private _effect;
  110930. private _alphaTestEffect;
  110931. /**
  110932. * An event triggered when the layer is disposed.
  110933. */
  110934. onDisposeObservable: Observable<Layer>;
  110935. private _onDisposeObserver;
  110936. /**
  110937. * Back compatibility with callback before the onDisposeObservable existed.
  110938. * The set callback will be triggered when the layer has been disposed.
  110939. */
  110940. onDispose: () => void;
  110941. /**
  110942. * An event triggered before rendering the scene
  110943. */
  110944. onBeforeRenderObservable: Observable<Layer>;
  110945. private _onBeforeRenderObserver;
  110946. /**
  110947. * Back compatibility with callback before the onBeforeRenderObservable existed.
  110948. * The set callback will be triggered just before rendering the layer.
  110949. */
  110950. onBeforeRender: () => void;
  110951. /**
  110952. * An event triggered after rendering the scene
  110953. */
  110954. onAfterRenderObservable: Observable<Layer>;
  110955. private _onAfterRenderObserver;
  110956. /**
  110957. * Back compatibility with callback before the onAfterRenderObservable existed.
  110958. * The set callback will be triggered just after rendering the layer.
  110959. */
  110960. onAfterRender: () => void;
  110961. /**
  110962. * Instantiates a new layer.
  110963. * This represents a full screen 2d layer.
  110964. * This can be useful to display a picture in the background of your scene for instance.
  110965. * @see https://www.babylonjs-playground.com/#08A2BS#1
  110966. * @param name Define the name of the layer in the scene
  110967. * @param imgUrl Define the url of the texture to display in the layer
  110968. * @param scene Define the scene the layer belongs to
  110969. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  110970. * @param color Defines a color for the layer
  110971. */
  110972. constructor(
  110973. /**
  110974. * Define the name of the layer.
  110975. */
  110976. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  110977. private _createIndexBuffer;
  110978. /** @hidden */
  110979. _rebuild(): void;
  110980. /**
  110981. * Renders the layer in the scene.
  110982. */
  110983. render(): void;
  110984. /**
  110985. * Disposes and releases the associated ressources.
  110986. */
  110987. dispose(): void;
  110988. }
  110989. }
  110990. declare module BABYLON {
  110991. /** @hidden */
  110992. export var lensFlarePixelShader: {
  110993. name: string;
  110994. shader: string;
  110995. };
  110996. }
  110997. declare module BABYLON {
  110998. /** @hidden */
  110999. export var lensFlareVertexShader: {
  111000. name: string;
  111001. shader: string;
  111002. };
  111003. }
  111004. declare module BABYLON {
  111005. /**
  111006. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  111007. * It is usually composed of several `lensFlare`.
  111008. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111009. */
  111010. export class LensFlareSystem {
  111011. /**
  111012. * Define the name of the lens flare system
  111013. */
  111014. name: string;
  111015. /**
  111016. * List of lens flares used in this system.
  111017. */
  111018. lensFlares: LensFlare[];
  111019. /**
  111020. * Define a limit from the border the lens flare can be visible.
  111021. */
  111022. borderLimit: number;
  111023. /**
  111024. * Define a viewport border we do not want to see the lens flare in.
  111025. */
  111026. viewportBorder: number;
  111027. /**
  111028. * Define a predicate which could limit the list of meshes able to occlude the effect.
  111029. */
  111030. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  111031. /**
  111032. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  111033. */
  111034. layerMask: number;
  111035. /**
  111036. * Define the id of the lens flare system in the scene.
  111037. * (equal to name by default)
  111038. */
  111039. id: string;
  111040. private _scene;
  111041. private _emitter;
  111042. private _vertexBuffers;
  111043. private _indexBuffer;
  111044. private _effect;
  111045. private _positionX;
  111046. private _positionY;
  111047. private _isEnabled;
  111048. /** @hidden */
  111049. static _SceneComponentInitialization: (scene: Scene) => void;
  111050. /**
  111051. * Instantiates a lens flare system.
  111052. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  111053. * It is usually composed of several `lensFlare`.
  111054. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111055. * @param name Define the name of the lens flare system in the scene
  111056. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  111057. * @param scene Define the scene the lens flare system belongs to
  111058. */
  111059. constructor(
  111060. /**
  111061. * Define the name of the lens flare system
  111062. */
  111063. name: string, emitter: any, scene: Scene);
  111064. /**
  111065. * Define if the lens flare system is enabled.
  111066. */
  111067. isEnabled: boolean;
  111068. /**
  111069. * Get the scene the effects belongs to.
  111070. * @returns the scene holding the lens flare system
  111071. */
  111072. getScene(): Scene;
  111073. /**
  111074. * Get the emitter of the lens flare system.
  111075. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  111076. * @returns the emitter of the lens flare system
  111077. */
  111078. getEmitter(): any;
  111079. /**
  111080. * Set the emitter of the lens flare system.
  111081. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  111082. * @param newEmitter Define the new emitter of the system
  111083. */
  111084. setEmitter(newEmitter: any): void;
  111085. /**
  111086. * Get the lens flare system emitter position.
  111087. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  111088. * @returns the position
  111089. */
  111090. getEmitterPosition(): Vector3;
  111091. /**
  111092. * @hidden
  111093. */
  111094. computeEffectivePosition(globalViewport: Viewport): boolean;
  111095. /** @hidden */
  111096. _isVisible(): boolean;
  111097. /**
  111098. * @hidden
  111099. */
  111100. render(): boolean;
  111101. /**
  111102. * Dispose and release the lens flare with its associated resources.
  111103. */
  111104. dispose(): void;
  111105. /**
  111106. * Parse a lens flare system from a JSON repressentation
  111107. * @param parsedLensFlareSystem Define the JSON to parse
  111108. * @param scene Define the scene the parsed system should be instantiated in
  111109. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  111110. * @returns the parsed system
  111111. */
  111112. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  111113. /**
  111114. * Serialize the current Lens Flare System into a JSON representation.
  111115. * @returns the serialized JSON
  111116. */
  111117. serialize(): any;
  111118. }
  111119. }
  111120. declare module BABYLON {
  111121. /**
  111122. * This represents one of the lens effect in a `lensFlareSystem`.
  111123. * It controls one of the indiviual texture used in the effect.
  111124. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111125. */
  111126. export class LensFlare {
  111127. /**
  111128. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  111129. */
  111130. size: number;
  111131. /**
  111132. * 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.
  111133. */
  111134. position: number;
  111135. /**
  111136. * Define the lens color.
  111137. */
  111138. color: Color3;
  111139. /**
  111140. * Define the lens texture.
  111141. */
  111142. texture: Nullable<Texture>;
  111143. /**
  111144. * Define the alpha mode to render this particular lens.
  111145. */
  111146. alphaMode: number;
  111147. private _system;
  111148. /**
  111149. * Creates a new Lens Flare.
  111150. * This represents one of the lens effect in a `lensFlareSystem`.
  111151. * It controls one of the indiviual texture used in the effect.
  111152. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111153. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  111154. * @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.
  111155. * @param color Define the lens color
  111156. * @param imgUrl Define the lens texture url
  111157. * @param system Define the `lensFlareSystem` this flare is part of
  111158. * @returns The newly created Lens Flare
  111159. */
  111160. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  111161. /**
  111162. * Instantiates a new Lens Flare.
  111163. * This represents one of the lens effect in a `lensFlareSystem`.
  111164. * It controls one of the indiviual texture used in the effect.
  111165. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111166. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  111167. * @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.
  111168. * @param color Define the lens color
  111169. * @param imgUrl Define the lens texture url
  111170. * @param system Define the `lensFlareSystem` this flare is part of
  111171. */
  111172. constructor(
  111173. /**
  111174. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  111175. */
  111176. size: number,
  111177. /**
  111178. * 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.
  111179. */
  111180. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  111181. /**
  111182. * Dispose and release the lens flare with its associated resources.
  111183. */
  111184. dispose(): void;
  111185. }
  111186. }
  111187. declare module BABYLON {
  111188. interface AbstractScene {
  111189. /**
  111190. * The list of lens flare system added to the scene
  111191. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  111192. */
  111193. lensFlareSystems: Array<LensFlareSystem>;
  111194. /**
  111195. * Removes the given lens flare system from this scene.
  111196. * @param toRemove The lens flare system to remove
  111197. * @returns The index of the removed lens flare system
  111198. */
  111199. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  111200. /**
  111201. * Adds the given lens flare system to this scene
  111202. * @param newLensFlareSystem The lens flare system to add
  111203. */
  111204. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  111205. /**
  111206. * Gets a lens flare system using its name
  111207. * @param name defines the name to look for
  111208. * @returns the lens flare system or null if not found
  111209. */
  111210. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  111211. /**
  111212. * Gets a lens flare system using its id
  111213. * @param id defines the id to look for
  111214. * @returns the lens flare system or null if not found
  111215. */
  111216. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  111217. }
  111218. /**
  111219. * Defines the lens flare scene component responsible to manage any lens flares
  111220. * in a given scene.
  111221. */
  111222. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  111223. /**
  111224. * The component name helpfull to identify the component in the list of scene components.
  111225. */
  111226. readonly name: string;
  111227. /**
  111228. * The scene the component belongs to.
  111229. */
  111230. scene: Scene;
  111231. /**
  111232. * Creates a new instance of the component for the given scene
  111233. * @param scene Defines the scene to register the component in
  111234. */
  111235. constructor(scene: Scene);
  111236. /**
  111237. * Registers the component in a given scene
  111238. */
  111239. register(): void;
  111240. /**
  111241. * Rebuilds the elements related to this component in case of
  111242. * context lost for instance.
  111243. */
  111244. rebuild(): void;
  111245. /**
  111246. * Adds all the elements from the container to the scene
  111247. * @param container the container holding the elements
  111248. */
  111249. addFromContainer(container: AbstractScene): void;
  111250. /**
  111251. * Removes all the elements in the container from the scene
  111252. * @param container contains the elements to remove
  111253. * @param dispose if the removed element should be disposed (default: false)
  111254. */
  111255. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111256. /**
  111257. * Serializes the component data to the specified json object
  111258. * @param serializationObject The object to serialize to
  111259. */
  111260. serialize(serializationObject: any): void;
  111261. /**
  111262. * Disposes the component and the associated ressources.
  111263. */
  111264. dispose(): void;
  111265. private _draw;
  111266. }
  111267. }
  111268. declare module BABYLON {
  111269. /**
  111270. * Defines the shadow generator component responsible to manage any shadow generators
  111271. * in a given scene.
  111272. */
  111273. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  111274. /**
  111275. * The component name helpfull to identify the component in the list of scene components.
  111276. */
  111277. readonly name: string;
  111278. /**
  111279. * The scene the component belongs to.
  111280. */
  111281. scene: Scene;
  111282. /**
  111283. * Creates a new instance of the component for the given scene
  111284. * @param scene Defines the scene to register the component in
  111285. */
  111286. constructor(scene: Scene);
  111287. /**
  111288. * Registers the component in a given scene
  111289. */
  111290. register(): void;
  111291. /**
  111292. * Rebuilds the elements related to this component in case of
  111293. * context lost for instance.
  111294. */
  111295. rebuild(): void;
  111296. /**
  111297. * Serializes the component data to the specified json object
  111298. * @param serializationObject The object to serialize to
  111299. */
  111300. serialize(serializationObject: any): void;
  111301. /**
  111302. * Adds all the elements from the container to the scene
  111303. * @param container the container holding the elements
  111304. */
  111305. addFromContainer(container: AbstractScene): void;
  111306. /**
  111307. * Removes all the elements in the container from the scene
  111308. * @param container contains the elements to remove
  111309. * @param dispose if the removed element should be disposed (default: false)
  111310. */
  111311. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111312. /**
  111313. * Rebuilds the elements related to this component in case of
  111314. * context lost for instance.
  111315. */
  111316. dispose(): void;
  111317. private _gatherRenderTargets;
  111318. }
  111319. }
  111320. declare module BABYLON {
  111321. /**
  111322. * A point light is a light defined by an unique point in world space.
  111323. * The light is emitted in every direction from this point.
  111324. * A good example of a point light is a standard light bulb.
  111325. * Documentation: https://doc.babylonjs.com/babylon101/lights
  111326. */
  111327. export class PointLight extends ShadowLight {
  111328. private _shadowAngle;
  111329. /**
  111330. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111331. * This specifies what angle the shadow will use to be created.
  111332. *
  111333. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  111334. */
  111335. /**
  111336. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111337. * This specifies what angle the shadow will use to be created.
  111338. *
  111339. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  111340. */
  111341. shadowAngle: number;
  111342. /**
  111343. * Gets the direction if it has been set.
  111344. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111345. */
  111346. /**
  111347. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  111348. */
  111349. direction: Vector3;
  111350. /**
  111351. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  111352. * A PointLight emits the light in every direction.
  111353. * It can cast shadows.
  111354. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  111355. * ```javascript
  111356. * var pointLight = new PointLight("pl", camera.position, scene);
  111357. * ```
  111358. * Documentation : https://doc.babylonjs.com/babylon101/lights
  111359. * @param name The light friendly name
  111360. * @param position The position of the point light in the scene
  111361. * @param scene The scene the lights belongs to
  111362. */
  111363. constructor(name: string, position: Vector3, scene: Scene);
  111364. /**
  111365. * Returns the string "PointLight"
  111366. * @returns the class name
  111367. */
  111368. getClassName(): string;
  111369. /**
  111370. * Returns the integer 0.
  111371. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  111372. */
  111373. getTypeID(): number;
  111374. /**
  111375. * Specifies wether or not the shadowmap should be a cube texture.
  111376. * @returns true if the shadowmap needs to be a cube texture.
  111377. */
  111378. needCube(): boolean;
  111379. /**
  111380. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  111381. * @param faceIndex The index of the face we are computed the direction to generate shadow
  111382. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  111383. */
  111384. getShadowDirection(faceIndex?: number): Vector3;
  111385. /**
  111386. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  111387. * - fov = PI / 2
  111388. * - aspect ratio : 1.0
  111389. * - z-near and far equal to the active camera minZ and maxZ.
  111390. * Returns the PointLight.
  111391. */
  111392. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  111393. protected _buildUniformLayout(): void;
  111394. /**
  111395. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  111396. * @param effect The effect to update
  111397. * @param lightIndex The index of the light in the effect to update
  111398. * @returns The point light
  111399. */
  111400. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  111401. /**
  111402. * Prepares the list of defines specific to the light type.
  111403. * @param defines the list of defines
  111404. * @param lightIndex defines the index of the light for the effect
  111405. */
  111406. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  111407. }
  111408. }
  111409. declare module BABYLON {
  111410. /**
  111411. * Header information of HDR texture files.
  111412. */
  111413. export interface HDRInfo {
  111414. /**
  111415. * The height of the texture in pixels.
  111416. */
  111417. height: number;
  111418. /**
  111419. * The width of the texture in pixels.
  111420. */
  111421. width: number;
  111422. /**
  111423. * The index of the beginning of the data in the binary file.
  111424. */
  111425. dataPosition: number;
  111426. }
  111427. /**
  111428. * This groups tools to convert HDR texture to native colors array.
  111429. */
  111430. export class HDRTools {
  111431. private static Ldexp;
  111432. private static Rgbe2float;
  111433. private static readStringLine;
  111434. /**
  111435. * Reads header information from an RGBE texture stored in a native array.
  111436. * More information on this format are available here:
  111437. * https://en.wikipedia.org/wiki/RGBE_image_format
  111438. *
  111439. * @param uint8array The binary file stored in native array.
  111440. * @return The header information.
  111441. */
  111442. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  111443. /**
  111444. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  111445. * This RGBE texture needs to store the information as a panorama.
  111446. *
  111447. * More information on this format are available here:
  111448. * https://en.wikipedia.org/wiki/RGBE_image_format
  111449. *
  111450. * @param buffer The binary file stored in an array buffer.
  111451. * @param size The expected size of the extracted cubemap.
  111452. * @return The Cube Map information.
  111453. */
  111454. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  111455. /**
  111456. * Returns the pixels data extracted from an RGBE texture.
  111457. * This pixels will be stored left to right up to down in the R G B order in one array.
  111458. *
  111459. * More information on this format are available here:
  111460. * https://en.wikipedia.org/wiki/RGBE_image_format
  111461. *
  111462. * @param uint8array The binary file stored in an array buffer.
  111463. * @param hdrInfo The header information of the file.
  111464. * @return The pixels data in RGB right to left up to down order.
  111465. */
  111466. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  111467. private static RGBE_ReadPixels_RLE;
  111468. }
  111469. }
  111470. declare module BABYLON {
  111471. /**
  111472. * This represents a texture coming from an HDR input.
  111473. *
  111474. * The only supported format is currently panorama picture stored in RGBE format.
  111475. * Example of such files can be found on HDRLib: http://hdrlib.com/
  111476. */
  111477. export class HDRCubeTexture extends BaseTexture {
  111478. private static _facesMapping;
  111479. private _generateHarmonics;
  111480. private _noMipmap;
  111481. private _textureMatrix;
  111482. private _size;
  111483. private _onLoad;
  111484. private _onError;
  111485. /**
  111486. * The texture URL.
  111487. */
  111488. url: string;
  111489. /**
  111490. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  111491. */
  111492. coordinatesMode: number;
  111493. protected _isBlocking: boolean;
  111494. /**
  111495. * Sets wether or not the texture is blocking during loading.
  111496. */
  111497. /**
  111498. * Gets wether or not the texture is blocking during loading.
  111499. */
  111500. isBlocking: boolean;
  111501. protected _rotationY: number;
  111502. /**
  111503. * Sets texture matrix rotation angle around Y axis in radians.
  111504. */
  111505. /**
  111506. * Gets texture matrix rotation angle around Y axis radians.
  111507. */
  111508. rotationY: number;
  111509. /**
  111510. * Gets or sets the center of the bounding box associated with the cube texture
  111511. * It must define where the camera used to render the texture was set
  111512. */
  111513. boundingBoxPosition: Vector3;
  111514. private _boundingBoxSize;
  111515. /**
  111516. * Gets or sets the size of the bounding box associated with the cube texture
  111517. * When defined, the cubemap will switch to local mode
  111518. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  111519. * @example https://www.babylonjs-playground.com/#RNASML
  111520. */
  111521. boundingBoxSize: Vector3;
  111522. /**
  111523. * Instantiates an HDRTexture from the following parameters.
  111524. *
  111525. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  111526. * @param scene The scene the texture will be used in
  111527. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  111528. * @param noMipmap Forces to not generate the mipmap if true
  111529. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  111530. * @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)
  111531. * @param reserved Reserved flag for internal use.
  111532. */
  111533. 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>);
  111534. /**
  111535. * Get the current class name of the texture useful for serialization or dynamic coding.
  111536. * @returns "HDRCubeTexture"
  111537. */
  111538. getClassName(): string;
  111539. /**
  111540. * Occurs when the file is raw .hdr file.
  111541. */
  111542. private loadTexture;
  111543. clone(): HDRCubeTexture;
  111544. delayLoad(): void;
  111545. /**
  111546. * Get the texture reflection matrix used to rotate/transform the reflection.
  111547. * @returns the reflection matrix
  111548. */
  111549. getReflectionTextureMatrix(): Matrix;
  111550. /**
  111551. * Set the texture reflection matrix used to rotate/transform the reflection.
  111552. * @param value Define the reflection matrix to set
  111553. */
  111554. setReflectionTextureMatrix(value: Matrix): void;
  111555. /**
  111556. * Parses a JSON representation of an HDR Texture in order to create the texture
  111557. * @param parsedTexture Define the JSON representation
  111558. * @param scene Define the scene the texture should be created in
  111559. * @param rootUrl Define the root url in case we need to load relative dependencies
  111560. * @returns the newly created texture after parsing
  111561. */
  111562. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  111563. serialize(): any;
  111564. }
  111565. }
  111566. declare module BABYLON {
  111567. /**
  111568. * Class used to control physics engine
  111569. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  111570. */
  111571. export class PhysicsEngine implements IPhysicsEngine {
  111572. private _physicsPlugin;
  111573. /**
  111574. * Global value used to control the smallest number supported by the simulation
  111575. */
  111576. static Epsilon: number;
  111577. private _impostors;
  111578. private _joints;
  111579. /**
  111580. * Gets the gravity vector used by the simulation
  111581. */
  111582. gravity: Vector3;
  111583. /**
  111584. * Factory used to create the default physics plugin.
  111585. * @returns The default physics plugin
  111586. */
  111587. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  111588. /**
  111589. * Creates a new Physics Engine
  111590. * @param gravity defines the gravity vector used by the simulation
  111591. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  111592. */
  111593. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  111594. /**
  111595. * Sets the gravity vector used by the simulation
  111596. * @param gravity defines the gravity vector to use
  111597. */
  111598. setGravity(gravity: Vector3): void;
  111599. /**
  111600. * Set the time step of the physics engine.
  111601. * Default is 1/60.
  111602. * To slow it down, enter 1/600 for example.
  111603. * To speed it up, 1/30
  111604. * @param newTimeStep defines the new timestep to apply to this world.
  111605. */
  111606. setTimeStep(newTimeStep?: number): void;
  111607. /**
  111608. * Get the time step of the physics engine.
  111609. * @returns the current time step
  111610. */
  111611. getTimeStep(): number;
  111612. /**
  111613. * Release all resources
  111614. */
  111615. dispose(): void;
  111616. /**
  111617. * Gets the name of the current physics plugin
  111618. * @returns the name of the plugin
  111619. */
  111620. getPhysicsPluginName(): string;
  111621. /**
  111622. * Adding a new impostor for the impostor tracking.
  111623. * This will be done by the impostor itself.
  111624. * @param impostor the impostor to add
  111625. */
  111626. addImpostor(impostor: PhysicsImpostor): void;
  111627. /**
  111628. * Remove an impostor from the engine.
  111629. * This impostor and its mesh will not longer be updated by the physics engine.
  111630. * @param impostor the impostor to remove
  111631. */
  111632. removeImpostor(impostor: PhysicsImpostor): void;
  111633. /**
  111634. * Add a joint to the physics engine
  111635. * @param mainImpostor defines the main impostor to which the joint is added.
  111636. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  111637. * @param joint defines the joint that will connect both impostors.
  111638. */
  111639. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  111640. /**
  111641. * Removes a joint from the simulation
  111642. * @param mainImpostor defines the impostor used with the joint
  111643. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  111644. * @param joint defines the joint to remove
  111645. */
  111646. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  111647. /**
  111648. * Called by the scene. No need to call it.
  111649. * @param delta defines the timespam between frames
  111650. */
  111651. _step(delta: number): void;
  111652. /**
  111653. * Gets the current plugin used to run the simulation
  111654. * @returns current plugin
  111655. */
  111656. getPhysicsPlugin(): IPhysicsEnginePlugin;
  111657. /**
  111658. * Gets the list of physic impostors
  111659. * @returns an array of PhysicsImpostor
  111660. */
  111661. getImpostors(): Array<PhysicsImpostor>;
  111662. /**
  111663. * Gets the impostor for a physics enabled object
  111664. * @param object defines the object impersonated by the impostor
  111665. * @returns the PhysicsImpostor or null if not found
  111666. */
  111667. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  111668. /**
  111669. * Gets the impostor for a physics body object
  111670. * @param body defines physics body used by the impostor
  111671. * @returns the PhysicsImpostor or null if not found
  111672. */
  111673. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  111674. /**
  111675. * Does a raycast in the physics world
  111676. * @param from when should the ray start?
  111677. * @param to when should the ray end?
  111678. * @returns PhysicsRaycastResult
  111679. */
  111680. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  111681. }
  111682. }
  111683. declare module BABYLON {
  111684. /** @hidden */
  111685. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  111686. private _useDeltaForWorldStep;
  111687. world: any;
  111688. name: string;
  111689. private _physicsMaterials;
  111690. private _fixedTimeStep;
  111691. private _cannonRaycastResult;
  111692. private _raycastResult;
  111693. private _physicsBodysToRemoveAfterStep;
  111694. BJSCANNON: any;
  111695. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  111696. setGravity(gravity: Vector3): void;
  111697. setTimeStep(timeStep: number): void;
  111698. getTimeStep(): number;
  111699. executeStep(delta: number): void;
  111700. private _removeMarkedPhysicsBodiesFromWorld;
  111701. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111702. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111703. generatePhysicsBody(impostor: PhysicsImpostor): void;
  111704. private _processChildMeshes;
  111705. removePhysicsBody(impostor: PhysicsImpostor): void;
  111706. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  111707. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  111708. private _addMaterial;
  111709. private _checkWithEpsilon;
  111710. private _createShape;
  111711. private _createHeightmap;
  111712. private _minus90X;
  111713. private _plus90X;
  111714. private _tmpPosition;
  111715. private _tmpDeltaPosition;
  111716. private _tmpUnityRotation;
  111717. private _updatePhysicsBodyTransformation;
  111718. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  111719. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  111720. isSupported(): boolean;
  111721. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111722. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111723. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111724. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111725. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  111726. getBodyMass(impostor: PhysicsImpostor): number;
  111727. getBodyFriction(impostor: PhysicsImpostor): number;
  111728. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  111729. getBodyRestitution(impostor: PhysicsImpostor): number;
  111730. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  111731. sleepBody(impostor: PhysicsImpostor): void;
  111732. wakeUpBody(impostor: PhysicsImpostor): void;
  111733. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  111734. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  111735. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  111736. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  111737. getRadius(impostor: PhysicsImpostor): number;
  111738. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  111739. dispose(): void;
  111740. private _extendNamespace;
  111741. /**
  111742. * Does a raycast in the physics world
  111743. * @param from when should the ray start?
  111744. * @param to when should the ray end?
  111745. * @returns PhysicsRaycastResult
  111746. */
  111747. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  111748. }
  111749. }
  111750. declare module BABYLON {
  111751. /** @hidden */
  111752. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  111753. world: any;
  111754. name: string;
  111755. BJSOIMO: any;
  111756. private _raycastResult;
  111757. constructor(iterations?: number, oimoInjection?: any);
  111758. setGravity(gravity: Vector3): void;
  111759. setTimeStep(timeStep: number): void;
  111760. getTimeStep(): number;
  111761. private _tmpImpostorsArray;
  111762. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  111763. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111764. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111765. generatePhysicsBody(impostor: PhysicsImpostor): void;
  111766. private _tmpPositionVector;
  111767. removePhysicsBody(impostor: PhysicsImpostor): void;
  111768. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  111769. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  111770. isSupported(): boolean;
  111771. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  111772. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  111773. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111774. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111775. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111776. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111777. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  111778. getBodyMass(impostor: PhysicsImpostor): number;
  111779. getBodyFriction(impostor: PhysicsImpostor): number;
  111780. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  111781. getBodyRestitution(impostor: PhysicsImpostor): number;
  111782. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  111783. sleepBody(impostor: PhysicsImpostor): void;
  111784. wakeUpBody(impostor: PhysicsImpostor): void;
  111785. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  111786. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  111787. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  111788. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  111789. getRadius(impostor: PhysicsImpostor): number;
  111790. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  111791. dispose(): void;
  111792. /**
  111793. * Does a raycast in the physics world
  111794. * @param from when should the ray start?
  111795. * @param to when should the ray end?
  111796. * @returns PhysicsRaycastResult
  111797. */
  111798. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  111799. }
  111800. }
  111801. declare module BABYLON {
  111802. /**
  111803. * Class containing static functions to help procedurally build meshes
  111804. */
  111805. export class RibbonBuilder {
  111806. /**
  111807. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  111808. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  111809. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  111810. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  111811. * * 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
  111812. * * 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
  111813. * * 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
  111814. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111815. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111816. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  111817. * * 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
  111818. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  111819. * * 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
  111820. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  111821. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111822. * @param name defines the name of the mesh
  111823. * @param options defines the options used to create the mesh
  111824. * @param scene defines the hosting scene
  111825. * @returns the ribbon mesh
  111826. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  111827. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  111828. */
  111829. static CreateRibbon(name: string, options: {
  111830. pathArray: Vector3[][];
  111831. closeArray?: boolean;
  111832. closePath?: boolean;
  111833. offset?: number;
  111834. updatable?: boolean;
  111835. sideOrientation?: number;
  111836. frontUVs?: Vector4;
  111837. backUVs?: Vector4;
  111838. instance?: Mesh;
  111839. invertUV?: boolean;
  111840. uvs?: Vector2[];
  111841. colors?: Color4[];
  111842. }, scene?: Nullable<Scene>): Mesh;
  111843. }
  111844. }
  111845. declare module BABYLON {
  111846. /**
  111847. * Class containing static functions to help procedurally build meshes
  111848. */
  111849. export class ShapeBuilder {
  111850. /**
  111851. * 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.
  111852. * * 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.
  111853. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  111854. * * 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.
  111855. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  111856. * * 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
  111857. * * 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
  111858. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  111859. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111860. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111861. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  111862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  111863. * @param name defines the name of the mesh
  111864. * @param options defines the options used to create the mesh
  111865. * @param scene defines the hosting scene
  111866. * @returns the extruded shape mesh
  111867. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  111868. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  111869. */
  111870. static ExtrudeShape(name: string, options: {
  111871. shape: Vector3[];
  111872. path: Vector3[];
  111873. scale?: number;
  111874. rotation?: number;
  111875. cap?: number;
  111876. updatable?: boolean;
  111877. sideOrientation?: number;
  111878. frontUVs?: Vector4;
  111879. backUVs?: Vector4;
  111880. instance?: Mesh;
  111881. invertUV?: boolean;
  111882. }, scene?: Nullable<Scene>): Mesh;
  111883. /**
  111884. * Creates an custom extruded shape mesh.
  111885. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  111886. * * 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.
  111887. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  111888. * * 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
  111889. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  111890. * * 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
  111891. * * It must returns a float value that will be the scale value applied to the shape on each path point
  111892. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  111893. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  111894. * * 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
  111895. * * 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
  111896. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  111897. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111898. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111899. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  111900. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111901. * @param name defines the name of the mesh
  111902. * @param options defines the options used to create the mesh
  111903. * @param scene defines the hosting scene
  111904. * @returns the custom extruded shape mesh
  111905. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  111906. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  111907. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  111908. */
  111909. static ExtrudeShapeCustom(name: string, options: {
  111910. shape: Vector3[];
  111911. path: Vector3[];
  111912. scaleFunction?: any;
  111913. rotationFunction?: any;
  111914. ribbonCloseArray?: boolean;
  111915. ribbonClosePath?: boolean;
  111916. cap?: number;
  111917. updatable?: boolean;
  111918. sideOrientation?: number;
  111919. frontUVs?: Vector4;
  111920. backUVs?: Vector4;
  111921. instance?: Mesh;
  111922. invertUV?: boolean;
  111923. }, scene?: Nullable<Scene>): Mesh;
  111924. private static _ExtrudeShapeGeneric;
  111925. }
  111926. }
  111927. declare module BABYLON {
  111928. /**
  111929. * AmmoJS Physics plugin
  111930. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111931. * @see https://github.com/kripken/ammo.js/
  111932. */
  111933. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  111934. private _useDeltaForWorldStep;
  111935. /**
  111936. * Reference to the Ammo library
  111937. */
  111938. bjsAMMO: any;
  111939. /**
  111940. * Created ammoJS world which physics bodies are added to
  111941. */
  111942. world: any;
  111943. /**
  111944. * Name of the plugin
  111945. */
  111946. name: string;
  111947. private _timeStep;
  111948. private _fixedTimeStep;
  111949. private _maxSteps;
  111950. private _tmpQuaternion;
  111951. private _tmpAmmoTransform;
  111952. private _tmpAmmoQuaternion;
  111953. private _tmpAmmoConcreteContactResultCallback;
  111954. private _collisionConfiguration;
  111955. private _dispatcher;
  111956. private _overlappingPairCache;
  111957. private _solver;
  111958. private _softBodySolver;
  111959. private _tmpAmmoVectorA;
  111960. private _tmpAmmoVectorB;
  111961. private _tmpAmmoVectorC;
  111962. private _tmpAmmoVectorD;
  111963. private _tmpContactCallbackResult;
  111964. private _tmpAmmoVectorRCA;
  111965. private _tmpAmmoVectorRCB;
  111966. private _raycastResult;
  111967. private static readonly DISABLE_COLLISION_FLAG;
  111968. private static readonly KINEMATIC_FLAG;
  111969. private static readonly DISABLE_DEACTIVATION_FLAG;
  111970. /**
  111971. * Initializes the ammoJS plugin
  111972. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  111973. * @param ammoInjection can be used to inject your own ammo reference
  111974. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  111975. */
  111976. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  111977. /**
  111978. * Sets the gravity of the physics world (m/(s^2))
  111979. * @param gravity Gravity to set
  111980. */
  111981. setGravity(gravity: Vector3): void;
  111982. /**
  111983. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  111984. * @param timeStep timestep to use in seconds
  111985. */
  111986. setTimeStep(timeStep: number): void;
  111987. /**
  111988. * 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)
  111989. * @param fixedTimeStep fixedTimeStep to use in seconds
  111990. */
  111991. setFixedTimeStep(fixedTimeStep: number): void;
  111992. /**
  111993. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  111994. * @param maxSteps the maximum number of steps by the physics engine per frame
  111995. */
  111996. setMaxSteps(maxSteps: number): void;
  111997. /**
  111998. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  111999. * @returns the current timestep in seconds
  112000. */
  112001. getTimeStep(): number;
  112002. private _isImpostorInContact;
  112003. private _isImpostorPairInContact;
  112004. private _stepSimulation;
  112005. /**
  112006. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  112007. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  112008. * After the step the babylon meshes are set to the position of the physics imposters
  112009. * @param delta amount of time to step forward
  112010. * @param impostors array of imposters to update before/after the step
  112011. */
  112012. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  112013. /**
  112014. * Update babylon mesh to match physics world object
  112015. * @param impostor imposter to match
  112016. */
  112017. private _afterSoftStep;
  112018. /**
  112019. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  112020. * @param impostor imposter to match
  112021. */
  112022. private _ropeStep;
  112023. /**
  112024. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  112025. * @param impostor imposter to match
  112026. */
  112027. private _softbodyOrClothStep;
  112028. private _tmpVector;
  112029. private _tmpMatrix;
  112030. /**
  112031. * Applies an impulse on the imposter
  112032. * @param impostor imposter to apply impulse to
  112033. * @param force amount of force to be applied to the imposter
  112034. * @param contactPoint the location to apply the impulse on the imposter
  112035. */
  112036. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112037. /**
  112038. * Applies a force on the imposter
  112039. * @param impostor imposter to apply force
  112040. * @param force amount of force to be applied to the imposter
  112041. * @param contactPoint the location to apply the force on the imposter
  112042. */
  112043. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  112044. /**
  112045. * Creates a physics body using the plugin
  112046. * @param impostor the imposter to create the physics body on
  112047. */
  112048. generatePhysicsBody(impostor: PhysicsImpostor): void;
  112049. /**
  112050. * Removes the physics body from the imposter and disposes of the body's memory
  112051. * @param impostor imposter to remove the physics body from
  112052. */
  112053. removePhysicsBody(impostor: PhysicsImpostor): void;
  112054. /**
  112055. * Generates a joint
  112056. * @param impostorJoint the imposter joint to create the joint with
  112057. */
  112058. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  112059. /**
  112060. * Removes a joint
  112061. * @param impostorJoint the imposter joint to remove the joint from
  112062. */
  112063. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  112064. private _addMeshVerts;
  112065. /**
  112066. * Initialise the soft body vertices to match its object's (mesh) vertices
  112067. * Softbody vertices (nodes) are in world space and to match this
  112068. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  112069. * @param impostor to create the softbody for
  112070. */
  112071. private _softVertexData;
  112072. /**
  112073. * Create an impostor's soft body
  112074. * @param impostor to create the softbody for
  112075. */
  112076. private _createSoftbody;
  112077. /**
  112078. * Create cloth for an impostor
  112079. * @param impostor to create the softbody for
  112080. */
  112081. private _createCloth;
  112082. /**
  112083. * Create rope for an impostor
  112084. * @param impostor to create the softbody for
  112085. */
  112086. private _createRope;
  112087. private _addHullVerts;
  112088. private _createShape;
  112089. /**
  112090. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  112091. * @param impostor imposter containing the physics body and babylon object
  112092. */
  112093. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  112094. /**
  112095. * Sets the babylon object's position/rotation from the physics body's position/rotation
  112096. * @param impostor imposter containing the physics body and babylon object
  112097. * @param newPosition new position
  112098. * @param newRotation new rotation
  112099. */
  112100. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  112101. /**
  112102. * If this plugin is supported
  112103. * @returns true if its supported
  112104. */
  112105. isSupported(): boolean;
  112106. /**
  112107. * Sets the linear velocity of the physics body
  112108. * @param impostor imposter to set the velocity on
  112109. * @param velocity velocity to set
  112110. */
  112111. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112112. /**
  112113. * Sets the angular velocity of the physics body
  112114. * @param impostor imposter to set the velocity on
  112115. * @param velocity velocity to set
  112116. */
  112117. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  112118. /**
  112119. * gets the linear velocity
  112120. * @param impostor imposter to get linear velocity from
  112121. * @returns linear velocity
  112122. */
  112123. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112124. /**
  112125. * gets the angular velocity
  112126. * @param impostor imposter to get angular velocity from
  112127. * @returns angular velocity
  112128. */
  112129. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  112130. /**
  112131. * Sets the mass of physics body
  112132. * @param impostor imposter to set the mass on
  112133. * @param mass mass to set
  112134. */
  112135. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  112136. /**
  112137. * Gets the mass of the physics body
  112138. * @param impostor imposter to get the mass from
  112139. * @returns mass
  112140. */
  112141. getBodyMass(impostor: PhysicsImpostor): number;
  112142. /**
  112143. * Gets friction of the impostor
  112144. * @param impostor impostor to get friction from
  112145. * @returns friction value
  112146. */
  112147. getBodyFriction(impostor: PhysicsImpostor): number;
  112148. /**
  112149. * Sets friction of the impostor
  112150. * @param impostor impostor to set friction on
  112151. * @param friction friction value
  112152. */
  112153. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  112154. /**
  112155. * Gets restitution of the impostor
  112156. * @param impostor impostor to get restitution from
  112157. * @returns restitution value
  112158. */
  112159. getBodyRestitution(impostor: PhysicsImpostor): number;
  112160. /**
  112161. * Sets resitution of the impostor
  112162. * @param impostor impostor to set resitution on
  112163. * @param restitution resitution value
  112164. */
  112165. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  112166. /**
  112167. * Gets pressure inside the impostor
  112168. * @param impostor impostor to get pressure from
  112169. * @returns pressure value
  112170. */
  112171. getBodyPressure(impostor: PhysicsImpostor): number;
  112172. /**
  112173. * Sets pressure inside a soft body impostor
  112174. * Cloth and rope must remain 0 pressure
  112175. * @param impostor impostor to set pressure on
  112176. * @param pressure pressure value
  112177. */
  112178. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  112179. /**
  112180. * Gets stiffness of the impostor
  112181. * @param impostor impostor to get stiffness from
  112182. * @returns pressure value
  112183. */
  112184. getBodyStiffness(impostor: PhysicsImpostor): number;
  112185. /**
  112186. * Sets stiffness of the impostor
  112187. * @param impostor impostor to set stiffness on
  112188. * @param stiffness stiffness value from 0 to 1
  112189. */
  112190. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  112191. /**
  112192. * Gets velocityIterations of the impostor
  112193. * @param impostor impostor to get velocity iterations from
  112194. * @returns velocityIterations value
  112195. */
  112196. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  112197. /**
  112198. * Sets velocityIterations of the impostor
  112199. * @param impostor impostor to set velocity iterations on
  112200. * @param velocityIterations velocityIterations value
  112201. */
  112202. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  112203. /**
  112204. * Gets positionIterations of the impostor
  112205. * @param impostor impostor to get position iterations from
  112206. * @returns positionIterations value
  112207. */
  112208. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  112209. /**
  112210. * Sets positionIterations of the impostor
  112211. * @param impostor impostor to set position on
  112212. * @param positionIterations positionIterations value
  112213. */
  112214. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  112215. /**
  112216. * Append an anchor to a cloth object
  112217. * @param impostor is the cloth impostor to add anchor to
  112218. * @param otherImpostor is the rigid impostor to anchor to
  112219. * @param width ratio across width from 0 to 1
  112220. * @param height ratio up height from 0 to 1
  112221. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  112222. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  112223. */
  112224. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  112225. /**
  112226. * Append an hook to a rope object
  112227. * @param impostor is the rope impostor to add hook to
  112228. * @param otherImpostor is the rigid impostor to hook to
  112229. * @param length ratio along the rope from 0 to 1
  112230. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  112231. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  112232. */
  112233. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  112234. /**
  112235. * Sleeps the physics body and stops it from being active
  112236. * @param impostor impostor to sleep
  112237. */
  112238. sleepBody(impostor: PhysicsImpostor): void;
  112239. /**
  112240. * Activates the physics body
  112241. * @param impostor impostor to activate
  112242. */
  112243. wakeUpBody(impostor: PhysicsImpostor): void;
  112244. /**
  112245. * Updates the distance parameters of the joint
  112246. * @param joint joint to update
  112247. * @param maxDistance maximum distance of the joint
  112248. * @param minDistance minimum distance of the joint
  112249. */
  112250. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  112251. /**
  112252. * Sets a motor on the joint
  112253. * @param joint joint to set motor on
  112254. * @param speed speed of the motor
  112255. * @param maxForce maximum force of the motor
  112256. * @param motorIndex index of the motor
  112257. */
  112258. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  112259. /**
  112260. * Sets the motors limit
  112261. * @param joint joint to set limit on
  112262. * @param upperLimit upper limit
  112263. * @param lowerLimit lower limit
  112264. */
  112265. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  112266. /**
  112267. * Syncs the position and rotation of a mesh with the impostor
  112268. * @param mesh mesh to sync
  112269. * @param impostor impostor to update the mesh with
  112270. */
  112271. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  112272. /**
  112273. * Gets the radius of the impostor
  112274. * @param impostor impostor to get radius from
  112275. * @returns the radius
  112276. */
  112277. getRadius(impostor: PhysicsImpostor): number;
  112278. /**
  112279. * Gets the box size of the impostor
  112280. * @param impostor impostor to get box size from
  112281. * @param result the resulting box size
  112282. */
  112283. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  112284. /**
  112285. * Disposes of the impostor
  112286. */
  112287. dispose(): void;
  112288. /**
  112289. * Does a raycast in the physics world
  112290. * @param from when should the ray start?
  112291. * @param to when should the ray end?
  112292. * @returns PhysicsRaycastResult
  112293. */
  112294. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  112295. }
  112296. }
  112297. declare module BABYLON {
  112298. interface AbstractScene {
  112299. /**
  112300. * The list of reflection probes added to the scene
  112301. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  112302. */
  112303. reflectionProbes: Array<ReflectionProbe>;
  112304. /**
  112305. * Removes the given reflection probe from this scene.
  112306. * @param toRemove The reflection probe to remove
  112307. * @returns The index of the removed reflection probe
  112308. */
  112309. removeReflectionProbe(toRemove: ReflectionProbe): number;
  112310. /**
  112311. * Adds the given reflection probe to this scene.
  112312. * @param newReflectionProbe The reflection probe to add
  112313. */
  112314. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  112315. }
  112316. /**
  112317. * Class used to generate realtime reflection / refraction cube textures
  112318. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  112319. */
  112320. export class ReflectionProbe {
  112321. /** defines the name of the probe */
  112322. name: string;
  112323. private _scene;
  112324. private _renderTargetTexture;
  112325. private _projectionMatrix;
  112326. private _viewMatrix;
  112327. private _target;
  112328. private _add;
  112329. private _attachedMesh;
  112330. private _invertYAxis;
  112331. /** Gets or sets probe position (center of the cube map) */
  112332. position: Vector3;
  112333. /**
  112334. * Creates a new reflection probe
  112335. * @param name defines the name of the probe
  112336. * @param size defines the texture resolution (for each face)
  112337. * @param scene defines the hosting scene
  112338. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  112339. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  112340. */
  112341. constructor(
  112342. /** defines the name of the probe */
  112343. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  112344. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  112345. samples: number;
  112346. /** Gets or sets the refresh rate to use (on every frame by default) */
  112347. refreshRate: number;
  112348. /**
  112349. * Gets the hosting scene
  112350. * @returns a Scene
  112351. */
  112352. getScene(): Scene;
  112353. /** Gets the internal CubeTexture used to render to */
  112354. readonly cubeTexture: RenderTargetTexture;
  112355. /** Gets the list of meshes to render */
  112356. readonly renderList: Nullable<AbstractMesh[]>;
  112357. /**
  112358. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  112359. * @param mesh defines the mesh to attach to
  112360. */
  112361. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  112362. /**
  112363. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  112364. * @param renderingGroupId The rendering group id corresponding to its index
  112365. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  112366. */
  112367. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  112368. /**
  112369. * Clean all associated resources
  112370. */
  112371. dispose(): void;
  112372. /**
  112373. * Converts the reflection probe information to a readable string for debug purpose.
  112374. * @param fullDetails Supports for multiple levels of logging within scene loading
  112375. * @returns the human readable reflection probe info
  112376. */
  112377. toString(fullDetails?: boolean): string;
  112378. /**
  112379. * Get the class name of the relfection probe.
  112380. * @returns "ReflectionProbe"
  112381. */
  112382. getClassName(): string;
  112383. /**
  112384. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  112385. * @returns The JSON representation of the texture
  112386. */
  112387. serialize(): any;
  112388. /**
  112389. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  112390. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  112391. * @param scene Define the scene the parsed reflection probe should be instantiated in
  112392. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  112393. * @returns The parsed reflection probe if successful
  112394. */
  112395. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  112396. }
  112397. }
  112398. declare module BABYLON {
  112399. /** @hidden */
  112400. export var _BabylonLoaderRegistered: boolean;
  112401. }
  112402. declare module BABYLON {
  112403. /**
  112404. * The Physically based simple base material of BJS.
  112405. *
  112406. * This enables better naming and convention enforcements on top of the pbrMaterial.
  112407. * It is used as the base class for both the specGloss and metalRough conventions.
  112408. */
  112409. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  112410. /**
  112411. * Number of Simultaneous lights allowed on the material.
  112412. */
  112413. maxSimultaneousLights: number;
  112414. /**
  112415. * If sets to true, disables all the lights affecting the material.
  112416. */
  112417. disableLighting: boolean;
  112418. /**
  112419. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  112420. */
  112421. environmentTexture: BaseTexture;
  112422. /**
  112423. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  112424. */
  112425. invertNormalMapX: boolean;
  112426. /**
  112427. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  112428. */
  112429. invertNormalMapY: boolean;
  112430. /**
  112431. * Normal map used in the model.
  112432. */
  112433. normalTexture: BaseTexture;
  112434. /**
  112435. * Emissivie color used to self-illuminate the model.
  112436. */
  112437. emissiveColor: Color3;
  112438. /**
  112439. * Emissivie texture used to self-illuminate the model.
  112440. */
  112441. emissiveTexture: BaseTexture;
  112442. /**
  112443. * Occlusion Channel Strenght.
  112444. */
  112445. occlusionStrength: number;
  112446. /**
  112447. * Occlusion Texture of the material (adding extra occlusion effects).
  112448. */
  112449. occlusionTexture: BaseTexture;
  112450. /**
  112451. * Defines the alpha limits in alpha test mode.
  112452. */
  112453. alphaCutOff: number;
  112454. /**
  112455. * Gets the current double sided mode.
  112456. */
  112457. /**
  112458. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  112459. */
  112460. doubleSided: boolean;
  112461. /**
  112462. * Stores the pre-calculated light information of a mesh in a texture.
  112463. */
  112464. lightmapTexture: BaseTexture;
  112465. /**
  112466. * If true, the light map contains occlusion information instead of lighting info.
  112467. */
  112468. useLightmapAsShadowmap: boolean;
  112469. /**
  112470. * Instantiates a new PBRMaterial instance.
  112471. *
  112472. * @param name The material name
  112473. * @param scene The scene the material will be use in.
  112474. */
  112475. constructor(name: string, scene: Scene);
  112476. getClassName(): string;
  112477. }
  112478. }
  112479. declare module BABYLON {
  112480. /**
  112481. * The PBR material of BJS following the metal roughness convention.
  112482. *
  112483. * This fits to the PBR convention in the GLTF definition:
  112484. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  112485. */
  112486. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  112487. /**
  112488. * The base color has two different interpretations depending on the value of metalness.
  112489. * When the material is a metal, the base color is the specific measured reflectance value
  112490. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  112491. * of the material.
  112492. */
  112493. baseColor: Color3;
  112494. /**
  112495. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  112496. * well as opacity information in the alpha channel.
  112497. */
  112498. baseTexture: BaseTexture;
  112499. /**
  112500. * Specifies the metallic scalar value of the material.
  112501. * Can also be used to scale the metalness values of the metallic texture.
  112502. */
  112503. metallic: number;
  112504. /**
  112505. * Specifies the roughness scalar value of the material.
  112506. * Can also be used to scale the roughness values of the metallic texture.
  112507. */
  112508. roughness: number;
  112509. /**
  112510. * Texture containing both the metallic value in the B channel and the
  112511. * roughness value in the G channel to keep better precision.
  112512. */
  112513. metallicRoughnessTexture: BaseTexture;
  112514. /**
  112515. * Instantiates a new PBRMetalRoughnessMaterial instance.
  112516. *
  112517. * @param name The material name
  112518. * @param scene The scene the material will be use in.
  112519. */
  112520. constructor(name: string, scene: Scene);
  112521. /**
  112522. * Return the currrent class name of the material.
  112523. */
  112524. getClassName(): string;
  112525. /**
  112526. * Makes a duplicate of the current material.
  112527. * @param name - name to use for the new material.
  112528. */
  112529. clone(name: string): PBRMetallicRoughnessMaterial;
  112530. /**
  112531. * Serialize the material to a parsable JSON object.
  112532. */
  112533. serialize(): any;
  112534. /**
  112535. * Parses a JSON object correponding to the serialize function.
  112536. */
  112537. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  112538. }
  112539. }
  112540. declare module BABYLON {
  112541. /**
  112542. * The PBR material of BJS following the specular glossiness convention.
  112543. *
  112544. * This fits to the PBR convention in the GLTF definition:
  112545. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  112546. */
  112547. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  112548. /**
  112549. * Specifies the diffuse color of the material.
  112550. */
  112551. diffuseColor: Color3;
  112552. /**
  112553. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  112554. * channel.
  112555. */
  112556. diffuseTexture: BaseTexture;
  112557. /**
  112558. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  112559. */
  112560. specularColor: Color3;
  112561. /**
  112562. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  112563. */
  112564. glossiness: number;
  112565. /**
  112566. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  112567. */
  112568. specularGlossinessTexture: BaseTexture;
  112569. /**
  112570. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  112571. *
  112572. * @param name The material name
  112573. * @param scene The scene the material will be use in.
  112574. */
  112575. constructor(name: string, scene: Scene);
  112576. /**
  112577. * Return the currrent class name of the material.
  112578. */
  112579. getClassName(): string;
  112580. /**
  112581. * Makes a duplicate of the current material.
  112582. * @param name - name to use for the new material.
  112583. */
  112584. clone(name: string): PBRSpecularGlossinessMaterial;
  112585. /**
  112586. * Serialize the material to a parsable JSON object.
  112587. */
  112588. serialize(): any;
  112589. /**
  112590. * Parses a JSON object correponding to the serialize function.
  112591. */
  112592. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  112593. }
  112594. }
  112595. declare module BABYLON {
  112596. /**
  112597. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  112598. * It can help converting any input color in a desired output one. This can then be used to create effects
  112599. * from sepia, black and white to sixties or futuristic rendering...
  112600. *
  112601. * The only supported format is currently 3dl.
  112602. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  112603. */
  112604. export class ColorGradingTexture extends BaseTexture {
  112605. /**
  112606. * The current texture matrix. (will always be identity in color grading texture)
  112607. */
  112608. private _textureMatrix;
  112609. /**
  112610. * The texture URL.
  112611. */
  112612. url: string;
  112613. /**
  112614. * Empty line regex stored for GC.
  112615. */
  112616. private static _noneEmptyLineRegex;
  112617. private _engine;
  112618. /**
  112619. * Instantiates a ColorGradingTexture from the following parameters.
  112620. *
  112621. * @param url The location of the color gradind data (currently only supporting 3dl)
  112622. * @param scene The scene the texture will be used in
  112623. */
  112624. constructor(url: string, scene: Scene);
  112625. /**
  112626. * Returns the texture matrix used in most of the material.
  112627. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  112628. */
  112629. getTextureMatrix(): Matrix;
  112630. /**
  112631. * Occurs when the file being loaded is a .3dl LUT file.
  112632. */
  112633. private load3dlTexture;
  112634. /**
  112635. * Starts the loading process of the texture.
  112636. */
  112637. private loadTexture;
  112638. /**
  112639. * Clones the color gradind texture.
  112640. */
  112641. clone(): ColorGradingTexture;
  112642. /**
  112643. * Called during delayed load for textures.
  112644. */
  112645. delayLoad(): void;
  112646. /**
  112647. * Parses a color grading texture serialized by Babylon.
  112648. * @param parsedTexture The texture information being parsedTexture
  112649. * @param scene The scene to load the texture in
  112650. * @param rootUrl The root url of the data assets to load
  112651. * @return A color gradind texture
  112652. */
  112653. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  112654. /**
  112655. * Serializes the LUT texture to json format.
  112656. */
  112657. serialize(): any;
  112658. }
  112659. }
  112660. declare module BABYLON {
  112661. /**
  112662. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  112663. */
  112664. export class EquiRectangularCubeTexture extends BaseTexture {
  112665. /** The six faces of the cube. */
  112666. private static _FacesMapping;
  112667. private _noMipmap;
  112668. private _onLoad;
  112669. private _onError;
  112670. /** The size of the cubemap. */
  112671. private _size;
  112672. /** The buffer of the image. */
  112673. private _buffer;
  112674. /** The width of the input image. */
  112675. private _width;
  112676. /** The height of the input image. */
  112677. private _height;
  112678. /** The URL to the image. */
  112679. url: string;
  112680. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  112681. coordinatesMode: number;
  112682. /**
  112683. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  112684. * @param url The location of the image
  112685. * @param scene The scene the texture will be used in
  112686. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  112687. * @param noMipmap Forces to not generate the mipmap if true
  112688. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  112689. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  112690. * @param onLoad — defines a callback called when texture is loaded
  112691. * @param onError — defines a callback called if there is an error
  112692. */
  112693. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  112694. /**
  112695. * Load the image data, by putting the image on a canvas and extracting its buffer.
  112696. */
  112697. private loadImage;
  112698. /**
  112699. * Convert the image buffer into a cubemap and create a CubeTexture.
  112700. */
  112701. private loadTexture;
  112702. /**
  112703. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  112704. * @param buffer The ArrayBuffer that should be converted.
  112705. * @returns The buffer as Float32Array.
  112706. */
  112707. private getFloat32ArrayFromArrayBuffer;
  112708. /**
  112709. * Get the current class name of the texture useful for serialization or dynamic coding.
  112710. * @returns "EquiRectangularCubeTexture"
  112711. */
  112712. getClassName(): string;
  112713. /**
  112714. * Create a clone of the current EquiRectangularCubeTexture and return it.
  112715. * @returns A clone of the current EquiRectangularCubeTexture.
  112716. */
  112717. clone(): EquiRectangularCubeTexture;
  112718. }
  112719. }
  112720. declare module BABYLON {
  112721. /**
  112722. * Based on jsTGALoader - Javascript loader for TGA file
  112723. * By Vincent Thibault
  112724. * @see http://blog.robrowser.com/javascript-tga-loader.html
  112725. */
  112726. export class TGATools {
  112727. private static _TYPE_INDEXED;
  112728. private static _TYPE_RGB;
  112729. private static _TYPE_GREY;
  112730. private static _TYPE_RLE_INDEXED;
  112731. private static _TYPE_RLE_RGB;
  112732. private static _TYPE_RLE_GREY;
  112733. private static _ORIGIN_MASK;
  112734. private static _ORIGIN_SHIFT;
  112735. private static _ORIGIN_BL;
  112736. private static _ORIGIN_BR;
  112737. private static _ORIGIN_UL;
  112738. private static _ORIGIN_UR;
  112739. /**
  112740. * Gets the header of a TGA file
  112741. * @param data defines the TGA data
  112742. * @returns the header
  112743. */
  112744. static GetTGAHeader(data: Uint8Array): any;
  112745. /**
  112746. * Uploads TGA content to a Babylon Texture
  112747. * @hidden
  112748. */
  112749. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  112750. /** @hidden */
  112751. 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;
  112752. /** @hidden */
  112753. 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;
  112754. /** @hidden */
  112755. 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;
  112756. /** @hidden */
  112757. 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;
  112758. /** @hidden */
  112759. 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;
  112760. /** @hidden */
  112761. 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;
  112762. }
  112763. }
  112764. declare module BABYLON {
  112765. /**
  112766. * Implementation of the TGA Texture Loader.
  112767. * @hidden
  112768. */
  112769. export class _TGATextureLoader implements IInternalTextureLoader {
  112770. /**
  112771. * Defines wether the loader supports cascade loading the different faces.
  112772. */
  112773. readonly supportCascades: boolean;
  112774. /**
  112775. * This returns if the loader support the current file information.
  112776. * @param extension defines the file extension of the file being loaded
  112777. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112778. * @param fallback defines the fallback internal texture if any
  112779. * @param isBase64 defines whether the texture is encoded as a base64
  112780. * @param isBuffer defines whether the texture data are stored as a buffer
  112781. * @returns true if the loader can load the specified file
  112782. */
  112783. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  112784. /**
  112785. * Transform the url before loading if required.
  112786. * @param rootUrl the url of the texture
  112787. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112788. * @returns the transformed texture
  112789. */
  112790. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  112791. /**
  112792. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  112793. * @param rootUrl the url of the texture
  112794. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112795. * @returns the fallback texture
  112796. */
  112797. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  112798. /**
  112799. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  112800. * @param data contains the texture data
  112801. * @param texture defines the BabylonJS internal texture
  112802. * @param createPolynomials will be true if polynomials have been requested
  112803. * @param onLoad defines the callback to trigger once the texture is ready
  112804. * @param onError defines the callback to trigger in case of error
  112805. */
  112806. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  112807. /**
  112808. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  112809. * @param data contains the texture data
  112810. * @param texture defines the BabylonJS internal texture
  112811. * @param callback defines the method to call once ready to upload
  112812. */
  112813. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  112814. }
  112815. }
  112816. declare module BABYLON {
  112817. /**
  112818. * Info about the .basis files
  112819. */
  112820. class BasisFileInfo {
  112821. /**
  112822. * If the file has alpha
  112823. */
  112824. hasAlpha: boolean;
  112825. /**
  112826. * Info about each image of the basis file
  112827. */
  112828. images: Array<{
  112829. levels: Array<{
  112830. width: number;
  112831. height: number;
  112832. transcodedPixels: ArrayBufferView;
  112833. }>;
  112834. }>;
  112835. }
  112836. /**
  112837. * Result of transcoding a basis file
  112838. */
  112839. class TranscodeResult {
  112840. /**
  112841. * Info about the .basis file
  112842. */
  112843. fileInfo: BasisFileInfo;
  112844. /**
  112845. * Format to use when loading the file
  112846. */
  112847. format: number;
  112848. }
  112849. /**
  112850. * Configuration options for the Basis transcoder
  112851. */
  112852. export class BasisTranscodeConfiguration {
  112853. /**
  112854. * Supported compression formats used to determine the supported output format of the transcoder
  112855. */
  112856. supportedCompressionFormats?: {
  112857. /**
  112858. * etc1 compression format
  112859. */
  112860. etc1?: boolean;
  112861. /**
  112862. * s3tc compression format
  112863. */
  112864. s3tc?: boolean;
  112865. /**
  112866. * pvrtc compression format
  112867. */
  112868. pvrtc?: boolean;
  112869. /**
  112870. * etc2 compression format
  112871. */
  112872. etc2?: boolean;
  112873. };
  112874. /**
  112875. * If mipmap levels should be loaded for transcoded images (Default: true)
  112876. */
  112877. loadMipmapLevels?: boolean;
  112878. /**
  112879. * Index of a single image to load (Default: all images)
  112880. */
  112881. loadSingleImage?: number;
  112882. }
  112883. /**
  112884. * Used to load .Basis files
  112885. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  112886. */
  112887. export class BasisTools {
  112888. private static _IgnoreSupportedFormats;
  112889. /**
  112890. * URL to use when loading the basis transcoder
  112891. */
  112892. static JSModuleURL: string;
  112893. /**
  112894. * URL to use when loading the wasm module for the transcoder
  112895. */
  112896. static WasmModuleURL: string;
  112897. /**
  112898. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  112899. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  112900. * @returns internal format corresponding to the Basis format
  112901. */
  112902. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  112903. private static _WorkerPromise;
  112904. private static _Worker;
  112905. private static _actionId;
  112906. private static _CreateWorkerAsync;
  112907. /**
  112908. * Transcodes a loaded image file to compressed pixel data
  112909. * @param imageData image data to transcode
  112910. * @param config configuration options for the transcoding
  112911. * @returns a promise resulting in the transcoded image
  112912. */
  112913. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  112914. /**
  112915. * Loads a texture from the transcode result
  112916. * @param texture texture load to
  112917. * @param transcodeResult the result of transcoding the basis file to load from
  112918. */
  112919. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  112920. }
  112921. }
  112922. declare module BABYLON {
  112923. /**
  112924. * Loader for .basis file format
  112925. */
  112926. export class _BasisTextureLoader implements IInternalTextureLoader {
  112927. /**
  112928. * Defines whether the loader supports cascade loading the different faces.
  112929. */
  112930. readonly supportCascades: boolean;
  112931. /**
  112932. * This returns if the loader support the current file information.
  112933. * @param extension defines the file extension of the file being loaded
  112934. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112935. * @param fallback defines the fallback internal texture if any
  112936. * @param isBase64 defines whether the texture is encoded as a base64
  112937. * @param isBuffer defines whether the texture data are stored as a buffer
  112938. * @returns true if the loader can load the specified file
  112939. */
  112940. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  112941. /**
  112942. * Transform the url before loading if required.
  112943. * @param rootUrl the url of the texture
  112944. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112945. * @returns the transformed texture
  112946. */
  112947. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  112948. /**
  112949. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  112950. * @param rootUrl the url of the texture
  112951. * @param textureFormatInUse defines the current compressed format in use iun the engine
  112952. * @returns the fallback texture
  112953. */
  112954. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  112955. /**
  112956. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  112957. * @param data contains the texture data
  112958. * @param texture defines the BabylonJS internal texture
  112959. * @param createPolynomials will be true if polynomials have been requested
  112960. * @param onLoad defines the callback to trigger once the texture is ready
  112961. * @param onError defines the callback to trigger in case of error
  112962. */
  112963. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  112964. /**
  112965. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  112966. * @param data contains the texture data
  112967. * @param texture defines the BabylonJS internal texture
  112968. * @param callback defines the method to call once ready to upload
  112969. */
  112970. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  112971. }
  112972. }
  112973. declare module BABYLON {
  112974. /**
  112975. * 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.
  112976. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  112977. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  112978. */
  112979. export class CustomProceduralTexture extends ProceduralTexture {
  112980. private _animate;
  112981. private _time;
  112982. private _config;
  112983. private _texturePath;
  112984. /**
  112985. * Instantiates a new Custom Procedural Texture.
  112986. * 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.
  112987. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  112988. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  112989. * @param name Define the name of the texture
  112990. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  112991. * @param size Define the size of the texture to create
  112992. * @param scene Define the scene the texture belongs to
  112993. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  112994. * @param generateMipMaps Define if the texture should creates mip maps or not
  112995. */
  112996. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  112997. private _loadJson;
  112998. /**
  112999. * Is the texture ready to be used ? (rendered at least once)
  113000. * @returns true if ready, otherwise, false.
  113001. */
  113002. isReady(): boolean;
  113003. /**
  113004. * Render the texture to its associated render target.
  113005. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  113006. */
  113007. render(useCameraPostProcess?: boolean): void;
  113008. /**
  113009. * Update the list of dependant textures samplers in the shader.
  113010. */
  113011. updateTextures(): void;
  113012. /**
  113013. * Update the uniform values of the procedural texture in the shader.
  113014. */
  113015. updateShaderUniforms(): void;
  113016. /**
  113017. * Define if the texture animates or not.
  113018. */
  113019. animate: boolean;
  113020. }
  113021. }
  113022. declare module BABYLON {
  113023. /** @hidden */
  113024. export var noisePixelShader: {
  113025. name: string;
  113026. shader: string;
  113027. };
  113028. }
  113029. declare module BABYLON {
  113030. /**
  113031. * Class used to generate noise procedural textures
  113032. */
  113033. export class NoiseProceduralTexture extends ProceduralTexture {
  113034. private _time;
  113035. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  113036. brightness: number;
  113037. /** Defines the number of octaves to process */
  113038. octaves: number;
  113039. /** Defines the level of persistence (0.8 by default) */
  113040. persistence: number;
  113041. /** Gets or sets animation speed factor (default is 1) */
  113042. animationSpeedFactor: number;
  113043. /**
  113044. * Creates a new NoiseProceduralTexture
  113045. * @param name defines the name fo the texture
  113046. * @param size defines the size of the texture (default is 256)
  113047. * @param scene defines the hosting scene
  113048. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  113049. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  113050. */
  113051. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  113052. private _updateShaderUniforms;
  113053. protected _getDefines(): string;
  113054. /** Generate the current state of the procedural texture */
  113055. render(useCameraPostProcess?: boolean): void;
  113056. /**
  113057. * Serializes this noise procedural texture
  113058. * @returns a serialized noise procedural texture object
  113059. */
  113060. serialize(): any;
  113061. /**
  113062. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  113063. * @param parsedTexture defines parsed texture data
  113064. * @param scene defines the current scene
  113065. * @param rootUrl defines the root URL containing noise procedural texture information
  113066. * @returns a parsed NoiseProceduralTexture
  113067. */
  113068. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  113069. }
  113070. }
  113071. declare module BABYLON {
  113072. /**
  113073. * Raw cube texture where the raw buffers are passed in
  113074. */
  113075. export class RawCubeTexture extends CubeTexture {
  113076. /**
  113077. * Creates a cube texture where the raw buffers are passed in.
  113078. * @param scene defines the scene the texture is attached to
  113079. * @param data defines the array of data to use to create each face
  113080. * @param size defines the size of the textures
  113081. * @param format defines the format of the data
  113082. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  113083. * @param generateMipMaps defines if the engine should generate the mip levels
  113084. * @param invertY defines if data must be stored with Y axis inverted
  113085. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  113086. * @param compression defines the compression used (null by default)
  113087. */
  113088. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  113089. /**
  113090. * Updates the raw cube texture.
  113091. * @param data defines the data to store
  113092. * @param format defines the data format
  113093. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  113094. * @param invertY defines if data must be stored with Y axis inverted
  113095. * @param compression defines the compression used (null by default)
  113096. * @param level defines which level of the texture to update
  113097. */
  113098. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  113099. /**
  113100. * Updates a raw cube texture with RGBD encoded data.
  113101. * @param data defines the array of data [mipmap][face] to use to create each face
  113102. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  113103. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  113104. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  113105. * @returns a promsie that resolves when the operation is complete
  113106. */
  113107. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  113108. /**
  113109. * Clones the raw cube texture.
  113110. * @return a new cube texture
  113111. */
  113112. clone(): CubeTexture;
  113113. /** @hidden */
  113114. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  113115. }
  113116. }
  113117. declare module BABYLON {
  113118. /**
  113119. * Class used to store 3D textures containing user data
  113120. */
  113121. export class RawTexture3D extends Texture {
  113122. /** Gets or sets the texture format to use */
  113123. format: number;
  113124. private _engine;
  113125. /**
  113126. * Create a new RawTexture3D
  113127. * @param data defines the data of the texture
  113128. * @param width defines the width of the texture
  113129. * @param height defines the height of the texture
  113130. * @param depth defines the depth of the texture
  113131. * @param format defines the texture format to use
  113132. * @param scene defines the hosting scene
  113133. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  113134. * @param invertY defines if texture must be stored with Y axis inverted
  113135. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  113136. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  113137. */
  113138. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  113139. /** Gets or sets the texture format to use */
  113140. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  113141. /**
  113142. * Update the texture with new data
  113143. * @param data defines the data to store in the texture
  113144. */
  113145. update(data: ArrayBufferView): void;
  113146. }
  113147. }
  113148. declare module BABYLON {
  113149. /**
  113150. * Creates a refraction texture used by refraction channel of the standard material.
  113151. * It is like a mirror but to see through a material.
  113152. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  113153. */
  113154. export class RefractionTexture extends RenderTargetTexture {
  113155. /**
  113156. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  113157. * 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.
  113158. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  113159. */
  113160. refractionPlane: Plane;
  113161. /**
  113162. * Define how deep under the surface we should see.
  113163. */
  113164. depth: number;
  113165. /**
  113166. * Creates a refraction texture used by refraction channel of the standard material.
  113167. * It is like a mirror but to see through a material.
  113168. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  113169. * @param name Define the texture name
  113170. * @param size Define the size of the underlying texture
  113171. * @param scene Define the scene the refraction belongs to
  113172. * @param generateMipMaps Define if we need to generate mips level for the refraction
  113173. */
  113174. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  113175. /**
  113176. * Clone the refraction texture.
  113177. * @returns the cloned texture
  113178. */
  113179. clone(): RefractionTexture;
  113180. /**
  113181. * Serialize the texture to a JSON representation you could use in Parse later on
  113182. * @returns the serialized JSON representation
  113183. */
  113184. serialize(): any;
  113185. }
  113186. }
  113187. declare module BABYLON {
  113188. /**
  113189. * Defines the options related to the creation of an HtmlElementTexture
  113190. */
  113191. export interface IHtmlElementTextureOptions {
  113192. /**
  113193. * Defines wether mip maps should be created or not.
  113194. */
  113195. generateMipMaps?: boolean;
  113196. /**
  113197. * Defines the sampling mode of the texture.
  113198. */
  113199. samplingMode?: number;
  113200. /**
  113201. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  113202. */
  113203. engine: Nullable<Engine>;
  113204. /**
  113205. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  113206. */
  113207. scene: Nullable<Scene>;
  113208. }
  113209. /**
  113210. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  113211. * To be as efficient as possible depending on your constraints nothing aside the first upload
  113212. * is automatically managed.
  113213. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  113214. * in your application.
  113215. *
  113216. * As the update is not automatic, you need to call them manually.
  113217. */
  113218. export class HtmlElementTexture extends BaseTexture {
  113219. /**
  113220. * The texture URL.
  113221. */
  113222. element: HTMLVideoElement | HTMLCanvasElement;
  113223. private static readonly DefaultOptions;
  113224. private _textureMatrix;
  113225. private _engine;
  113226. private _isVideo;
  113227. private _generateMipMaps;
  113228. private _samplingMode;
  113229. /**
  113230. * Instantiates a HtmlElementTexture from the following parameters.
  113231. *
  113232. * @param name Defines the name of the texture
  113233. * @param element Defines the video or canvas the texture is filled with
  113234. * @param options Defines the other none mandatory texture creation options
  113235. */
  113236. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  113237. private _createInternalTexture;
  113238. /**
  113239. * Returns the texture matrix used in most of the material.
  113240. */
  113241. getTextureMatrix(): Matrix;
  113242. /**
  113243. * Updates the content of the texture.
  113244. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  113245. */
  113246. update(invertY?: Nullable<boolean>): void;
  113247. }
  113248. }
  113249. declare module BABYLON {
  113250. /**
  113251. * Enum used to define the target of a block
  113252. */
  113253. export enum NodeMaterialBlockTargets {
  113254. /** Vertex shader */
  113255. Vertex = 1,
  113256. /** Fragment shader */
  113257. Fragment = 2,
  113258. /** Vertex and Fragment */
  113259. VertexAndFragment = 3
  113260. }
  113261. }
  113262. declare module BABYLON {
  113263. /**
  113264. * Defines the kind of connection point for node based material
  113265. */
  113266. export enum NodeMaterialBlockConnectionPointTypes {
  113267. /** Float */
  113268. Float = 1,
  113269. /** Int */
  113270. Int = 2,
  113271. /** Vector2 */
  113272. Vector2 = 4,
  113273. /** Vector3 */
  113274. Vector3 = 8,
  113275. /** Vector4 */
  113276. Vector4 = 16,
  113277. /** Color3 */
  113278. Color3 = 32,
  113279. /** Color4 */
  113280. Color4 = 64,
  113281. /** Matrix */
  113282. Matrix = 128,
  113283. /** Texture */
  113284. Texture = 256,
  113285. /** Texture3D */
  113286. Texture3D = 512,
  113287. /** Vector3 or Color3 */
  113288. Vector3OrColor3 = 40,
  113289. /** Vector3 or Vector4 */
  113290. Vector3OrVector4 = 24,
  113291. /** Vector4 or Color4 */
  113292. Vector4OrColor4 = 80,
  113293. /** Color3 or Color4 */
  113294. Color3OrColor4 = 96,
  113295. /** Vector3 or Color3 */
  113296. Vector3OrColor3OrVector4OrColor4 = 120,
  113297. /** Detect type based on connection */
  113298. AutoDetect = 1024,
  113299. /** Output type that will be defined by input type */
  113300. BasedOnInput = 2048,
  113301. /** Light */
  113302. Light = 4096
  113303. }
  113304. }
  113305. declare module BABYLON {
  113306. /**
  113307. * Enum used to define well known values e.g. values automatically provided by the system
  113308. */
  113309. export enum NodeMaterialWellKnownValues {
  113310. /** World */
  113311. World = 1,
  113312. /** View */
  113313. View = 2,
  113314. /** Projection */
  113315. Projection = 3,
  113316. /** ViewProjection */
  113317. ViewProjection = 4,
  113318. /** WorldView */
  113319. WorldView = 5,
  113320. /** WorldViewProjection */
  113321. WorldViewProjection = 6,
  113322. /** CameraPosition */
  113323. CameraPosition = 7,
  113324. /** Will be filled by the block itself */
  113325. Automatic = 8
  113326. }
  113327. }
  113328. declare module BABYLON {
  113329. /**
  113330. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  113331. */
  113332. export enum NodeMaterialBlockConnectionPointMode {
  113333. /** Value is an uniform */
  113334. Uniform = 0,
  113335. /** Value is a mesh attribute */
  113336. Attribute = 1,
  113337. /** Value is a varying between vertex and fragment shaders */
  113338. Varying = 2,
  113339. /** Mode is undefined */
  113340. Undefined = 3
  113341. }
  113342. }
  113343. declare module BABYLON {
  113344. /**
  113345. * Class used to store shared data between 2 NodeMaterialBuildState
  113346. */
  113347. export class NodeMaterialBuildStateSharedData {
  113348. /**
  113349. * Gets the list of emitted varyings
  113350. */
  113351. varyings: string[];
  113352. /**
  113353. * Gets the varying declaration string
  113354. */
  113355. varyingDeclaration: string;
  113356. /**
  113357. * Uniform connection points
  113358. */
  113359. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  113360. /**
  113361. * Bindable blocks (Blocks that need to set data to the effect)
  113362. */
  113363. bindableBlocks: NodeMaterialBlock[];
  113364. /**
  113365. * List of blocks that can provide a compilation fallback
  113366. */
  113367. blocksWithFallbacks: NodeMaterialBlock[];
  113368. /**
  113369. * List of blocks that can provide a define update
  113370. */
  113371. blocksWithDefines: NodeMaterialBlock[];
  113372. /**
  113373. * List of blocks that can provide a repeatable content
  113374. */
  113375. repeatableContentBlocks: NodeMaterialBlock[];
  113376. /**
  113377. * List of blocks that can provide a dynamic list of uniforms
  113378. */
  113379. dynamicUniformBlocks: NodeMaterialBlock[];
  113380. /**
  113381. * List of blocks that can block the isReady function for the material
  113382. */
  113383. blockingBlocks: NodeMaterialBlock[];
  113384. /**
  113385. * Build Id used to avoid multiple recompilations
  113386. */
  113387. buildId: number;
  113388. /** List of emitted variables */
  113389. variableNames: {
  113390. [key: string]: number;
  113391. };
  113392. /** List of emitted defines */
  113393. defineNames: {
  113394. [key: string]: number;
  113395. };
  113396. /** Should emit comments? */
  113397. emitComments: boolean;
  113398. /** Emit build activity */
  113399. verbose: boolean;
  113400. /**
  113401. * Gets the compilation hints emitted at compilation time
  113402. */
  113403. hints: {
  113404. needWorldViewMatrix: boolean;
  113405. needWorldViewProjectionMatrix: boolean;
  113406. needAlphaBlending: boolean;
  113407. needAlphaTesting: boolean;
  113408. };
  113409. /**
  113410. * List of compilation checks
  113411. */
  113412. checks: {
  113413. emitVertex: boolean;
  113414. emitFragment: boolean;
  113415. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  113416. };
  113417. /** Creates a new shared data */
  113418. constructor();
  113419. /**
  113420. * Emits console errors and exceptions if there is a failing check
  113421. */
  113422. emitErrors(): void;
  113423. }
  113424. }
  113425. declare module BABYLON {
  113426. /**
  113427. * Class used to store node based material build state
  113428. */
  113429. export class NodeMaterialBuildState {
  113430. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  113431. supportUniformBuffers: boolean;
  113432. /**
  113433. * Gets the list of emitted attributes
  113434. */
  113435. attributes: string[];
  113436. /**
  113437. * Gets the list of emitted uniforms
  113438. */
  113439. uniforms: string[];
  113440. /**
  113441. * Gets the list of emitted uniform buffers
  113442. */
  113443. uniformBuffers: string[];
  113444. /**
  113445. * Gets the list of emitted samplers
  113446. */
  113447. samplers: string[];
  113448. /**
  113449. * Gets the list of emitted functions
  113450. */
  113451. functions: {
  113452. [key: string]: string;
  113453. };
  113454. /**
  113455. * Gets the target of the compilation state
  113456. */
  113457. target: NodeMaterialBlockTargets;
  113458. /**
  113459. * Gets the list of emitted counters
  113460. */
  113461. counters: {
  113462. [key: string]: number;
  113463. };
  113464. /**
  113465. * Shared data between multiple NodeMaterialBuildState instances
  113466. */
  113467. sharedData: NodeMaterialBuildStateSharedData;
  113468. /** @hidden */
  113469. _vertexState: NodeMaterialBuildState;
  113470. private _attributeDeclaration;
  113471. private _uniformDeclaration;
  113472. private _samplerDeclaration;
  113473. private _varyingTransfer;
  113474. private _repeatableContentAnchorIndex;
  113475. /** @hidden */
  113476. _builtCompilationString: string;
  113477. /**
  113478. * Gets the emitted compilation strings
  113479. */
  113480. compilationString: string;
  113481. /**
  113482. * Finalize the compilation strings
  113483. * @param state defines the current compilation state
  113484. */
  113485. finalize(state: NodeMaterialBuildState): void;
  113486. /** @hidden */
  113487. readonly _repeatableContentAnchor: string;
  113488. /** @hidden */
  113489. _getFreeVariableName(prefix: string): string;
  113490. /** @hidden */
  113491. _getFreeDefineName(prefix: string): string;
  113492. /** @hidden */
  113493. _excludeVariableName(name: string): void;
  113494. /** @hidden */
  113495. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  113496. /** @hidden */
  113497. _emitFunction(name: string, code: string, comments: string): void;
  113498. /** @hidden */
  113499. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  113500. replaceStrings?: {
  113501. search: RegExp;
  113502. replace: string;
  113503. }[];
  113504. repeatKey?: string;
  113505. }): string;
  113506. /** @hidden */
  113507. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  113508. repeatKey?: string;
  113509. removeAttributes?: boolean;
  113510. removeUniforms?: boolean;
  113511. removeVaryings?: boolean;
  113512. removeIfDef?: boolean;
  113513. replaceStrings?: {
  113514. search: RegExp;
  113515. replace: string;
  113516. }[];
  113517. }, storeKey?: string): void;
  113518. /** @hidden */
  113519. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string, type?: Nullable<NodeMaterialBlockConnectionPointTypes>): void;
  113520. private _emitDefine;
  113521. /** @hidden */
  113522. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  113523. }
  113524. }
  113525. declare module BABYLON {
  113526. /**
  113527. * Root class for all node material optimizers
  113528. */
  113529. export class NodeMaterialOptimizer {
  113530. /**
  113531. * Function used to optimize a NodeMaterial graph
  113532. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  113533. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  113534. */
  113535. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  113536. }
  113537. }
  113538. declare module BABYLON {
  113539. /**
  113540. * Block used to transform a vector4 with a matrix
  113541. */
  113542. export class Vector4TransformBlock extends NodeMaterialBlock {
  113543. /**
  113544. * Defines the value to use to complement Vector3 to transform it to a Vector4
  113545. */
  113546. complementW: number;
  113547. /**
  113548. * Creates a new Vector4TransformBlock
  113549. * @param name defines the block name
  113550. */
  113551. constructor(name: string);
  113552. /**
  113553. * Gets the current class name
  113554. * @returns the class name
  113555. */
  113556. getClassName(): string;
  113557. /**
  113558. * Gets the vector input
  113559. */
  113560. readonly vector: NodeMaterialConnectionPoint;
  113561. /**
  113562. * Gets the output component
  113563. */
  113564. readonly output: NodeMaterialConnectionPoint;
  113565. /**
  113566. * Gets the matrix transform input
  113567. */
  113568. readonly transform: NodeMaterialConnectionPoint;
  113569. protected _buildBlock(state: NodeMaterialBuildState): this;
  113570. }
  113571. }
  113572. declare module BABYLON {
  113573. /**
  113574. * Block used to output the vertex position
  113575. */
  113576. export class VertexOutputBlock extends NodeMaterialBlock {
  113577. /**
  113578. * Creates a new VertexOutputBlock
  113579. * @param name defines the block name
  113580. */
  113581. constructor(name: string);
  113582. /**
  113583. * Gets the current class name
  113584. * @returns the class name
  113585. */
  113586. getClassName(): string;
  113587. /**
  113588. * Gets the vector input component
  113589. */
  113590. readonly vector: NodeMaterialConnectionPoint;
  113591. protected _buildBlock(state: NodeMaterialBuildState): this;
  113592. }
  113593. }
  113594. declare module BABYLON {
  113595. /**
  113596. * Block used to output the final color
  113597. */
  113598. export class FragmentOutputBlock extends NodeMaterialBlock {
  113599. /**
  113600. * Gets or sets a boolean indicating if this block will output an alpha value
  113601. */
  113602. alphaBlendingEnabled: boolean;
  113603. /**
  113604. * Create a new FragmentOutputBlock
  113605. * @param name defines the block name
  113606. */
  113607. constructor(name: string);
  113608. /**
  113609. * Gets the current class name
  113610. * @returns the class name
  113611. */
  113612. getClassName(): string;
  113613. /**
  113614. * Gets the color input component
  113615. */
  113616. readonly color: NodeMaterialConnectionPoint;
  113617. protected _buildBlock(state: NodeMaterialBuildState): this;
  113618. }
  113619. }
  113620. declare module BABYLON {
  113621. /**
  113622. * Interface used to configure the node material editor
  113623. */
  113624. export interface INodeMaterialEditorOptions {
  113625. /** Define the URl to load node editor script */
  113626. editorURL?: string;
  113627. }
  113628. /** @hidden */
  113629. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  113630. /** BONES */
  113631. NUM_BONE_INFLUENCERS: number;
  113632. BonesPerMesh: number;
  113633. BONETEXTURE: boolean;
  113634. /** MORPH TARGETS */
  113635. MORPHTARGETS: boolean;
  113636. MORPHTARGETS_NORMAL: boolean;
  113637. MORPHTARGETS_TANGENT: boolean;
  113638. MORPHTARGETS_UV: boolean;
  113639. NUM_MORPH_INFLUENCERS: number;
  113640. /** IMAGE PROCESSING */
  113641. IMAGEPROCESSING: boolean;
  113642. VIGNETTE: boolean;
  113643. VIGNETTEBLENDMODEMULTIPLY: boolean;
  113644. VIGNETTEBLENDMODEOPAQUE: boolean;
  113645. TONEMAPPING: boolean;
  113646. TONEMAPPING_ACES: boolean;
  113647. CONTRAST: boolean;
  113648. EXPOSURE: boolean;
  113649. COLORCURVES: boolean;
  113650. COLORGRADING: boolean;
  113651. COLORGRADING3D: boolean;
  113652. SAMPLER3DGREENDEPTH: boolean;
  113653. SAMPLER3DBGRMAP: boolean;
  113654. IMAGEPROCESSINGPOSTPROCESS: boolean;
  113655. constructor();
  113656. setValue(name: string, value: boolean): void;
  113657. }
  113658. /**
  113659. * Class used to configure NodeMaterial
  113660. */
  113661. export interface INodeMaterialOptions {
  113662. /**
  113663. * Defines if blocks should emit comments
  113664. */
  113665. emitComments: boolean;
  113666. }
  113667. /**
  113668. * Class used to create a node based material built by assembling shader blocks
  113669. */
  113670. export class NodeMaterial extends PushMaterial {
  113671. private _options;
  113672. private _vertexCompilationState;
  113673. private _fragmentCompilationState;
  113674. private _sharedData;
  113675. private _buildId;
  113676. private _buildWasSuccessful;
  113677. private _cachedWorldViewMatrix;
  113678. private _cachedWorldViewProjectionMatrix;
  113679. private _textureConnectionPoints;
  113680. private _optimizers;
  113681. /** Define the URl to load node editor script */
  113682. static EditorURL: string;
  113683. private BJSNODEMATERIALEDITOR;
  113684. /** Get the inspector from bundle or global */
  113685. private _getGlobalNodeMaterialEditor;
  113686. /**
  113687. * Defines the maximum number of lights that can be used in the material
  113688. */
  113689. maxSimultaneousLights: number;
  113690. /**
  113691. * Observable raised when the material is built
  113692. */
  113693. onBuildObservable: Observable<NodeMaterial>;
  113694. /**
  113695. * Gets or sets the root nodes of the material vertex shader
  113696. */
  113697. _vertexOutputNodes: NodeMaterialBlock[];
  113698. /**
  113699. * Gets or sets the root nodes of the material fragment (pixel) shader
  113700. */
  113701. _fragmentOutputNodes: NodeMaterialBlock[];
  113702. /** Gets or sets options to control the node material overall behavior */
  113703. options: INodeMaterialOptions;
  113704. /**
  113705. * Default configuration related to image processing available in the standard Material.
  113706. */
  113707. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  113708. /**
  113709. * Gets the image processing configuration used either in this material.
  113710. */
  113711. /**
  113712. * Sets the Default image processing configuration used either in the this material.
  113713. *
  113714. * If sets to null, the scene one is in use.
  113715. */
  113716. imageProcessingConfiguration: ImageProcessingConfiguration;
  113717. /**
  113718. * Create a new node based material
  113719. * @param name defines the material name
  113720. * @param scene defines the hosting scene
  113721. * @param options defines creation option
  113722. */
  113723. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  113724. /**
  113725. * Gets the current class name of the material e.g. "NodeMaterial"
  113726. * @returns the class name
  113727. */
  113728. getClassName(): string;
  113729. /**
  113730. * Keep track of the image processing observer to allow dispose and replace.
  113731. */
  113732. private _imageProcessingObserver;
  113733. /**
  113734. * Attaches a new image processing configuration to the Standard Material.
  113735. * @param configuration
  113736. */
  113737. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  113738. /**
  113739. * Adds a new optimizer to the list of optimizers
  113740. * @param optimizer defines the optimizers to add
  113741. * @returns the current material
  113742. */
  113743. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  113744. /**
  113745. * Remove an optimizer from the list of optimizers
  113746. * @param optimizer defines the optimizers to remove
  113747. * @returns the current material
  113748. */
  113749. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  113750. /**
  113751. * Add a new block to the list of output nodes
  113752. * @param node defines the node to add
  113753. * @returns the current material
  113754. */
  113755. addOutputNode(node: NodeMaterialBlock): this;
  113756. /**
  113757. * Remove a block from the list of root nodes
  113758. * @param node defines the node to remove
  113759. * @returns the current material
  113760. */
  113761. removeOutputNode(node: NodeMaterialBlock): this;
  113762. private _addVertexOutputNode;
  113763. private _removeVertexOutputNode;
  113764. private _addFragmentOutputNode;
  113765. private _removeFragmentOutputNode;
  113766. /**
  113767. * Specifies if the material will require alpha blending
  113768. * @returns a boolean specifying if alpha blending is needed
  113769. */
  113770. needAlphaBlending(): boolean;
  113771. /**
  113772. * Specifies if this material should be rendered in alpha test mode
  113773. * @returns a boolean specifying if an alpha test is needed.
  113774. */
  113775. needAlphaTesting(): boolean;
  113776. private _initializeBlock;
  113777. private _resetDualBlocks;
  113778. /**
  113779. * Build the material and generates the inner effect
  113780. * @param verbose defines if the build should log activity
  113781. */
  113782. build(verbose?: boolean): void;
  113783. /**
  113784. * Runs an otpimization phase to try to improve the shader code
  113785. */
  113786. optimize(): void;
  113787. private _prepareDefinesForAttributes;
  113788. /**
  113789. * Get if the submesh is ready to be used and all its information available.
  113790. * Child classes can use it to update shaders
  113791. * @param mesh defines the mesh to check
  113792. * @param subMesh defines which submesh to check
  113793. * @param useInstances specifies that instances should be used
  113794. * @returns a boolean indicating that the submesh is ready or not
  113795. */
  113796. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  113797. /**
  113798. * Binds the world matrix to the material
  113799. * @param world defines the world transformation matrix
  113800. */
  113801. bindOnlyWorldMatrix(world: Matrix): void;
  113802. /**
  113803. * Binds the submesh to this material by preparing the effect and shader to draw
  113804. * @param world defines the world transformation matrix
  113805. * @param mesh defines the mesh containing the submesh
  113806. * @param subMesh defines the submesh to bind the material to
  113807. */
  113808. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  113809. /**
  113810. * Gets the active textures from the material
  113811. * @returns an array of textures
  113812. */
  113813. getActiveTextures(): BaseTexture[];
  113814. /**
  113815. * Specifies if the material uses a texture
  113816. * @param texture defines the texture to check against the material
  113817. * @returns a boolean specifying if the material uses the texture
  113818. */
  113819. hasTexture(texture: BaseTexture): boolean;
  113820. /**
  113821. * Disposes the material
  113822. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  113823. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  113824. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  113825. */
  113826. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  113827. /** Creates the node editor window. */
  113828. private _createNodeEditor;
  113829. /**
  113830. * Launch the node material editor
  113831. * @param config Define the configuration of the editor
  113832. * @return a promise fulfilled when the node editor is visible
  113833. */
  113834. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  113835. /**
  113836. * Clear the current material
  113837. */
  113838. clear(): void;
  113839. /**
  113840. * Clear the current material and set it to a default state
  113841. */
  113842. setToDefault(): void;
  113843. }
  113844. }
  113845. declare module BABYLON {
  113846. /**
  113847. * Defines a block that can be used inside a node based material
  113848. */
  113849. export class NodeMaterialBlock {
  113850. private _buildId;
  113851. private _target;
  113852. private _isFinalMerger;
  113853. /** @hidden */
  113854. _inputs: NodeMaterialConnectionPoint[];
  113855. /** @hidden */
  113856. _outputs: NodeMaterialConnectionPoint[];
  113857. /**
  113858. * Gets or sets the name of the block
  113859. */
  113860. name: string;
  113861. /**
  113862. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  113863. */
  113864. readonly isFinalMerger: boolean;
  113865. /**
  113866. * Gets or sets the build Id
  113867. */
  113868. buildId: number;
  113869. /**
  113870. * Gets or sets the target of the block
  113871. */
  113872. target: NodeMaterialBlockTargets;
  113873. /**
  113874. * Gets the list of input points
  113875. */
  113876. readonly inputs: NodeMaterialConnectionPoint[];
  113877. /** Gets the list of output points */
  113878. readonly outputs: NodeMaterialConnectionPoint[];
  113879. /**
  113880. * Find an input by its name
  113881. * @param name defines the name of the input to look for
  113882. * @returns the input or null if not found
  113883. */
  113884. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  113885. /**
  113886. * Find an output by its name
  113887. * @param name defines the name of the outputto look for
  113888. * @returns the output or null if not found
  113889. */
  113890. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  113891. /**
  113892. * Creates a new NodeMaterialBlock
  113893. * @param name defines the block name
  113894. * @param target defines the target of that block (Vertex by default)
  113895. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  113896. */
  113897. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  113898. /**
  113899. * Initialize the block and prepare the context for build
  113900. * @param state defines the state that will be used for the build
  113901. */
  113902. initialize(state: NodeMaterialBuildState): void;
  113903. /**
  113904. * Bind data to effect. Will only be called for blocks with isBindable === true
  113905. * @param effect defines the effect to bind data to
  113906. * @param nodeMaterial defines the hosting NodeMaterial
  113907. * @param mesh defines the mesh that will be rendered
  113908. */
  113909. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  113910. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  113911. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  113912. protected _writeFloat(value: number): string;
  113913. /**
  113914. * Gets the current class name e.g. "NodeMaterialBlock"
  113915. * @returns the class name
  113916. */
  113917. getClassName(): string;
  113918. /**
  113919. * Register a new input. Must be called inside a block constructor
  113920. * @param name defines the connection point name
  113921. * @param type defines the connection point type
  113922. * @param isOptional defines a boolean indicating that this input can be omitted
  113923. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  113924. * @returns the current block
  113925. */
  113926. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  113927. /**
  113928. * Register a new output. Must be called inside a block constructor
  113929. * @param name defines the connection point name
  113930. * @param type defines the connection point type
  113931. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  113932. * @returns the current block
  113933. */
  113934. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  113935. /**
  113936. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  113937. * @param forOutput defines an optional connection point to check compatibility with
  113938. * @returns the first available input or null
  113939. */
  113940. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  113941. /**
  113942. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  113943. * @param forBlock defines an optional block to check compatibility with
  113944. * @returns the first available input or null
  113945. */
  113946. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  113947. /**
  113948. * Connect current block with another block
  113949. * @param other defines the block to connect with
  113950. * @param options define the various options to help pick the right connections
  113951. * @returns the current block
  113952. */
  113953. connectTo(other: NodeMaterialBlock, options?: {
  113954. input?: string;
  113955. output?: string;
  113956. outputSwizzle?: string;
  113957. }): this | undefined;
  113958. protected _buildBlock(state: NodeMaterialBuildState): void;
  113959. /**
  113960. * Add uniforms, samplers and uniform buffers at compilation time
  113961. * @param state defines the state to update
  113962. * @param nodeMaterial defines the node material requesting the update
  113963. * @param defines defines the material defines to update
  113964. */
  113965. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  113966. /**
  113967. * Add potential fallbacks if shader compilation fails
  113968. * @param mesh defines the mesh to be rendered
  113969. * @param fallbacks defines the current prioritized list of fallbacks
  113970. */
  113971. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  113972. /**
  113973. * Update defines for shader compilation
  113974. * @param mesh defines the mesh to be rendered
  113975. * @param nodeMaterial defines the node material requesting the update
  113976. * @param defines defines the material defines to update
  113977. * @param useInstances specifies that instances should be used
  113978. */
  113979. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  113980. /**
  113981. * Lets the block try to connect some inputs automatically
  113982. */
  113983. autoConfigure(): void;
  113984. /**
  113985. * Function called when a block is declared as repeatable content generator
  113986. * @param vertexShaderState defines the current compilation state for the vertex shader
  113987. * @param fragmentShaderState defines the current compilation state for the fragment shader
  113988. * @param mesh defines the mesh to be rendered
  113989. * @param defines defines the material defines to update
  113990. */
  113991. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  113992. /**
  113993. * Checks if the block is ready
  113994. * @param mesh defines the mesh to be rendered
  113995. * @param nodeMaterial defines the node material requesting the update
  113996. * @param defines defines the material defines to update
  113997. * @param useInstances specifies that instances should be used
  113998. * @returns true if the block is ready
  113999. */
  114000. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  114001. /**
  114002. * Compile the current node and generate the shader code
  114003. * @param state defines the current compilation state (uniforms, samplers, current string)
  114004. * @returns the current block
  114005. */
  114006. build(state: NodeMaterialBuildState): this | undefined;
  114007. }
  114008. }
  114009. declare module BABYLON {
  114010. /**
  114011. * Defines a connection point for a block
  114012. */
  114013. export class NodeMaterialConnectionPoint {
  114014. /** @hidden */
  114015. _ownerBlock: NodeMaterialBlock;
  114016. /** @hidden */
  114017. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  114018. private _associatedVariableName;
  114019. private _endpoints;
  114020. private _storedValue;
  114021. private _valueCallback;
  114022. private _mode;
  114023. /** @hidden */
  114024. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  114025. /** @hidden */
  114026. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  114027. /** @hidden */
  114028. _needToEmitVarying: boolean;
  114029. /** @hidden */
  114030. _forceUniformInVertexShaderOnly: boolean;
  114031. private _type;
  114032. /**
  114033. * Gets or sets the connection point type (default is float)
  114034. */
  114035. type: NodeMaterialBlockConnectionPointTypes;
  114036. /**
  114037. * Gets or sets the connection point name
  114038. */
  114039. name: string;
  114040. /**
  114041. * Gets or sets the swizzle to apply to this connection point when reading or writing
  114042. */
  114043. swizzle: string;
  114044. /**
  114045. * Gets or sets a boolean indicating that this connection point can be omitted
  114046. */
  114047. isOptional: boolean;
  114048. /**
  114049. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  114050. */
  114051. define: string;
  114052. /** Gets or sets the target of that connection point */
  114053. target: NodeMaterialBlockTargets;
  114054. /**
  114055. * Gets or sets the value of that point.
  114056. * Please note that this value will be ignored if valueCallback is defined
  114057. */
  114058. value: any;
  114059. /**
  114060. * Gets or sets a callback used to get the value of that point.
  114061. * Please note that setting this value will force the connection point to ignore the value property
  114062. */
  114063. valueCallback: () => any;
  114064. /**
  114065. * Gets or sets the associated variable name in the shader
  114066. */
  114067. associatedVariableName: string;
  114068. /**
  114069. * Gets a boolean indicating that this connection point not defined yet
  114070. */
  114071. readonly isUndefined: boolean;
  114072. /**
  114073. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  114074. * In this case the connection point name must be the name of the uniform to use.
  114075. * Can only be set on inputs
  114076. */
  114077. isUniform: boolean;
  114078. /**
  114079. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  114080. * In this case the connection point name must be the name of the attribute to use
  114081. * Can only be set on inputs
  114082. */
  114083. isAttribute: boolean;
  114084. /**
  114085. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  114086. * Can only be set on exit points
  114087. */
  114088. isVarying: boolean;
  114089. /** Get the other side of the connection (if any) */
  114090. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  114091. /** Get the block that owns this connection point */
  114092. readonly ownerBlock: NodeMaterialBlock;
  114093. /** Get the block connected on the other side of this connection (if any) */
  114094. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  114095. /** Get the block connected on the endpoints of this connection (if any) */
  114096. readonly connectedBlocks: Array<NodeMaterialBlock>;
  114097. /**
  114098. * Creates a new connection point
  114099. * @param name defines the connection point name
  114100. * @param ownerBlock defines the block hosting this connection point
  114101. */
  114102. constructor(name: string, ownerBlock: NodeMaterialBlock);
  114103. /**
  114104. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  114105. * @returns the class name
  114106. */
  114107. getClassName(): string;
  114108. /**
  114109. * Set the source of this connection point to a vertex attribute
  114110. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  114111. * @returns the current connection point
  114112. */
  114113. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  114114. /**
  114115. * Set the source of this connection point to a well known value
  114116. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  114117. * @returns the current connection point
  114118. */
  114119. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  114120. /**
  114121. * Gets a boolean indicating that the current connection point is a well known value
  114122. */
  114123. readonly isWellKnownValue: boolean;
  114124. /**
  114125. * Gets or sets the current well known value or null if not defined as well know value
  114126. */
  114127. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  114128. private _getTypeLength;
  114129. /**
  114130. * Gets an boolean indicating if the current point can be connected to another point
  114131. * @param connectionPoint defines the other connection point
  114132. * @returns true if the connection is possible
  114133. */
  114134. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  114135. /**
  114136. * Connect this point to another connection point
  114137. * @param connectionPoint defines the other connection point
  114138. * @returns the current connection point
  114139. */
  114140. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  114141. /**
  114142. * Disconnect this point from one of his endpoint
  114143. * @param endpoint defines the other connection point
  114144. * @returns the current connection point
  114145. */
  114146. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  114147. /**
  114148. * When connection point is an uniform, this function will send its value to the effect
  114149. * @param effect defines the effect to transmit value to
  114150. * @param world defines the world matrix
  114151. * @param worldView defines the worldxview matrix
  114152. * @param worldViewProjection defines the worldxviewxprojection matrix
  114153. */
  114154. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  114155. /**
  114156. * When connection point is an uniform, this function will send its value to the effect
  114157. * @param effect defines the effect to transmit value to
  114158. * @param scene defines the hosting scene
  114159. */
  114160. transmit(effect: Effect, scene: Scene): void;
  114161. }
  114162. }
  114163. declare module BABYLON {
  114164. /**
  114165. * Block used to add support for vertex skinning (bones)
  114166. */
  114167. export class BonesBlock extends NodeMaterialBlock {
  114168. /**
  114169. * Creates a new BonesBlock
  114170. * @param name defines the block name
  114171. */
  114172. constructor(name: string);
  114173. /**
  114174. * Initialize the block and prepare the context for build
  114175. * @param state defines the state that will be used for the build
  114176. */
  114177. initialize(state: NodeMaterialBuildState): void;
  114178. /**
  114179. * Gets the current class name
  114180. * @returns the class name
  114181. */
  114182. getClassName(): string;
  114183. /**
  114184. * Gets the matrix indices input component
  114185. */
  114186. readonly matricesIndices: NodeMaterialConnectionPoint;
  114187. /**
  114188. * Gets the matrix weights input component
  114189. */
  114190. readonly matricesWeights: NodeMaterialConnectionPoint;
  114191. /**
  114192. * Gets the extra matrix indices input component
  114193. */
  114194. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  114195. /**
  114196. * Gets the extra matrix weights input component
  114197. */
  114198. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  114199. /**
  114200. * Gets the world input component
  114201. */
  114202. readonly world: NodeMaterialConnectionPoint;
  114203. /**
  114204. * Gets the output component
  114205. */
  114206. readonly output: NodeMaterialConnectionPoint;
  114207. autoConfigure(): void;
  114208. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  114209. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114210. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114211. protected _buildBlock(state: NodeMaterialBuildState): this;
  114212. }
  114213. }
  114214. declare module BABYLON {
  114215. /**
  114216. * Block used to add support for instances
  114217. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  114218. */
  114219. export class InstancesBlock extends NodeMaterialBlock {
  114220. /**
  114221. * Creates a new InstancesBlock
  114222. * @param name defines the block name
  114223. */
  114224. constructor(name: string);
  114225. /**
  114226. * Gets the current class name
  114227. * @returns the class name
  114228. */
  114229. getClassName(): string;
  114230. /**
  114231. * Gets the first world row input component
  114232. */
  114233. readonly world0: NodeMaterialConnectionPoint;
  114234. /**
  114235. * Gets the second world row input component
  114236. */
  114237. readonly world1: NodeMaterialConnectionPoint;
  114238. /**
  114239. * Gets the third world row input component
  114240. */
  114241. readonly world2: NodeMaterialConnectionPoint;
  114242. /**
  114243. * Gets the forth world row input component
  114244. */
  114245. readonly world3: NodeMaterialConnectionPoint;
  114246. /**
  114247. * Gets the world input component
  114248. */
  114249. readonly world: NodeMaterialConnectionPoint;
  114250. /**
  114251. * Gets the output component
  114252. */
  114253. readonly output: NodeMaterialConnectionPoint;
  114254. autoConfigure(): void;
  114255. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  114256. protected _buildBlock(state: NodeMaterialBuildState): this;
  114257. }
  114258. }
  114259. declare module BABYLON {
  114260. /**
  114261. * Block used to add morph targets support to vertex shader
  114262. */
  114263. export class MorphTargetsBlock extends NodeMaterialBlock {
  114264. private _repeatableContentAnchor;
  114265. private _repeatebleContentGenerated;
  114266. /**
  114267. * Create a new MorphTargetsBlock
  114268. * @param name defines the block name
  114269. */
  114270. constructor(name: string);
  114271. /**
  114272. * Gets the current class name
  114273. * @returns the class name
  114274. */
  114275. getClassName(): string;
  114276. /**
  114277. * Gets the position input component
  114278. */
  114279. readonly position: NodeMaterialConnectionPoint;
  114280. /**
  114281. * Gets the normal input component
  114282. */
  114283. readonly normal: NodeMaterialConnectionPoint;
  114284. /**
  114285. * Gets the tangent input component
  114286. */
  114287. readonly tangent: NodeMaterialConnectionPoint;
  114288. /**
  114289. * Gets the tangent input component
  114290. */
  114291. readonly uv: NodeMaterialConnectionPoint;
  114292. /**
  114293. * Gets the position output component
  114294. */
  114295. readonly positionOutput: NodeMaterialConnectionPoint;
  114296. /**
  114297. * Gets the normal output component
  114298. */
  114299. readonly normalOutput: NodeMaterialConnectionPoint;
  114300. /**
  114301. * Gets the tangent output component
  114302. */
  114303. readonly tangentOutput: NodeMaterialConnectionPoint;
  114304. /**
  114305. * Gets the tangent output component
  114306. */
  114307. readonly uvOutput: NodeMaterialConnectionPoint;
  114308. initialize(state: NodeMaterialBuildState): void;
  114309. autoConfigure(): void;
  114310. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114311. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114312. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  114313. protected _buildBlock(state: NodeMaterialBuildState): this;
  114314. }
  114315. }
  114316. declare module BABYLON {
  114317. /**
  114318. * Block used to add an alpha test in the fragment shader
  114319. */
  114320. export class AlphaTestBlock extends NodeMaterialBlock {
  114321. /**
  114322. * Gets or sets the alpha value where alpha testing happens
  114323. */
  114324. alphaCutOff: number;
  114325. /**
  114326. * Create a new AlphaTestBlock
  114327. * @param name defines the block name
  114328. */
  114329. constructor(name: string);
  114330. /**
  114331. * Gets the current class name
  114332. * @returns the class name
  114333. */
  114334. getClassName(): string;
  114335. /**
  114336. * Gets the color input component
  114337. */
  114338. readonly color: NodeMaterialConnectionPoint;
  114339. protected _buildBlock(state: NodeMaterialBuildState): this;
  114340. }
  114341. }
  114342. declare module BABYLON {
  114343. /**
  114344. * Block used to create a Color4 out of 4 inputs (one for each component)
  114345. */
  114346. export class RGBAMergerBlock extends NodeMaterialBlock {
  114347. /**
  114348. * Create a new RGBAMergerBlock
  114349. * @param name defines the block name
  114350. */
  114351. constructor(name: string);
  114352. /**
  114353. * Gets the current class name
  114354. * @returns the class name
  114355. */
  114356. getClassName(): string;
  114357. /**
  114358. * Gets the R input component
  114359. */
  114360. readonly r: NodeMaterialConnectionPoint;
  114361. /**
  114362. * Gets the G input component
  114363. */
  114364. readonly g: NodeMaterialConnectionPoint;
  114365. /**
  114366. * Gets the B input component
  114367. */
  114368. readonly b: NodeMaterialConnectionPoint;
  114369. /**
  114370. * Gets the RGB input component
  114371. */
  114372. readonly rgb: NodeMaterialConnectionPoint;
  114373. /**
  114374. * Gets the R input component
  114375. */
  114376. readonly a: NodeMaterialConnectionPoint;
  114377. /**
  114378. * Gets the output component
  114379. */
  114380. readonly output: NodeMaterialConnectionPoint;
  114381. protected _buildBlock(state: NodeMaterialBuildState): this;
  114382. }
  114383. }
  114384. declare module BABYLON {
  114385. /**
  114386. * Block used to create a Color3 out of 3 inputs (one for each component)
  114387. */
  114388. export class RGBMergerBlock extends NodeMaterialBlock {
  114389. /**
  114390. * Create a new RGBMergerBlock
  114391. * @param name defines the block name
  114392. */
  114393. constructor(name: string);
  114394. /**
  114395. * Gets the current class name
  114396. * @returns the class name
  114397. */
  114398. getClassName(): string;
  114399. /**
  114400. * Gets the R component input
  114401. */
  114402. readonly r: NodeMaterialConnectionPoint;
  114403. /**
  114404. * Gets the G component input
  114405. */
  114406. readonly g: NodeMaterialConnectionPoint;
  114407. /**
  114408. * Gets the B component input
  114409. */
  114410. readonly b: NodeMaterialConnectionPoint;
  114411. /**
  114412. * Gets the output component
  114413. */
  114414. readonly output: NodeMaterialConnectionPoint;
  114415. protected _buildBlock(state: NodeMaterialBuildState): this;
  114416. }
  114417. }
  114418. declare module BABYLON {
  114419. /**
  114420. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  114421. */
  114422. export class RGBASplitterBlock extends NodeMaterialBlock {
  114423. /**
  114424. * Create a new RGBASplitterBlock
  114425. * @param name defines the block name
  114426. */
  114427. constructor(name: string);
  114428. /**
  114429. * Gets the current class name
  114430. * @returns the class name
  114431. */
  114432. getClassName(): string;
  114433. /**
  114434. * Gets the input component
  114435. */
  114436. readonly input: NodeMaterialConnectionPoint;
  114437. protected _buildBlock(state: NodeMaterialBuildState): this;
  114438. }
  114439. }
  114440. declare module BABYLON {
  114441. /**
  114442. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  114443. */
  114444. export class RGBSplitterBlock extends NodeMaterialBlock {
  114445. /**
  114446. * Create a new RGBSplitterBlock
  114447. * @param name defines the block name
  114448. */
  114449. constructor(name: string);
  114450. /**
  114451. * Gets the current class name
  114452. * @returns the class name
  114453. */
  114454. getClassName(): string;
  114455. /**
  114456. * Gets the input component
  114457. */
  114458. readonly input: NodeMaterialConnectionPoint;
  114459. protected _buildBlock(state: NodeMaterialBuildState): this;
  114460. }
  114461. }
  114462. declare module BABYLON {
  114463. /**
  114464. * Block used to read a texture from a sampler
  114465. */
  114466. export class TextureBlock extends NodeMaterialBlock {
  114467. private _defineName;
  114468. /**
  114469. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  114470. */
  114471. autoConnectTextureMatrix: boolean;
  114472. /**
  114473. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  114474. */
  114475. autoSelectUV: boolean;
  114476. /**
  114477. * Create a new TextureBlock
  114478. * @param name defines the block name
  114479. */
  114480. constructor(name: string);
  114481. /**
  114482. * Gets the current class name
  114483. * @returns the class name
  114484. */
  114485. getClassName(): string;
  114486. /**
  114487. * Gets the uv input component
  114488. */
  114489. readonly uv: NodeMaterialConnectionPoint;
  114490. /**
  114491. * Gets the texture information input component
  114492. */
  114493. readonly textureInfo: NodeMaterialConnectionPoint;
  114494. /**
  114495. * Gets the transformed uv input component
  114496. */
  114497. readonly transformedUV: NodeMaterialConnectionPoint;
  114498. /**
  114499. * Gets the texture input component
  114500. */
  114501. readonly texture: NodeMaterialConnectionPoint;
  114502. /**
  114503. * Gets the texture transform input component
  114504. */
  114505. readonly textureTransform: NodeMaterialConnectionPoint;
  114506. /**
  114507. * Gets the output component
  114508. */
  114509. readonly output: NodeMaterialConnectionPoint;
  114510. autoConfigure(): void;
  114511. initialize(state: NodeMaterialBuildState): void;
  114512. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114513. isReady(): boolean;
  114514. private _injectVertexCode;
  114515. protected _buildBlock(state: NodeMaterialBuildState): this;
  114516. }
  114517. }
  114518. declare module BABYLON {
  114519. /**
  114520. * Block used to add image processing support to fragment shader
  114521. */
  114522. export class ImageProcessingBlock extends NodeMaterialBlock {
  114523. /**
  114524. * Create a new ImageProcessingBlock
  114525. * @param name defines the block name
  114526. */
  114527. constructor(name: string);
  114528. /**
  114529. * Gets the current class name
  114530. * @returns the class name
  114531. */
  114532. getClassName(): string;
  114533. /**
  114534. * Gets the color input component
  114535. */
  114536. readonly color: NodeMaterialConnectionPoint;
  114537. /**
  114538. * Gets the output component
  114539. */
  114540. readonly output: NodeMaterialConnectionPoint;
  114541. /**
  114542. * Initialize the block and prepare the context for build
  114543. * @param state defines the state that will be used for the build
  114544. */
  114545. initialize(state: NodeMaterialBuildState): void;
  114546. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  114547. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114548. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114549. protected _buildBlock(state: NodeMaterialBuildState): this;
  114550. }
  114551. }
  114552. declare module BABYLON {
  114553. /**
  114554. * Block used to add support for scene fog
  114555. */
  114556. export class FogBlock extends NodeMaterialBlock {
  114557. /**
  114558. * Create a new FogBlock
  114559. * @param name defines the block name
  114560. */
  114561. constructor(name: string);
  114562. /**
  114563. * Gets the current class name
  114564. * @returns the class name
  114565. */
  114566. getClassName(): string;
  114567. /**
  114568. * Gets the world position input component
  114569. */
  114570. readonly worldPosition: NodeMaterialConnectionPoint;
  114571. /**
  114572. * Gets the view input component
  114573. */
  114574. readonly view: NodeMaterialConnectionPoint;
  114575. /**
  114576. * Gets the color input component
  114577. */
  114578. readonly color: NodeMaterialConnectionPoint;
  114579. /**
  114580. * Gets the fog color input component
  114581. */
  114582. readonly fogColor: NodeMaterialConnectionPoint;
  114583. /**
  114584. * Gets the for parameter input component
  114585. */
  114586. readonly fogParameters: NodeMaterialConnectionPoint;
  114587. /**
  114588. * Gets the output component
  114589. */
  114590. readonly output: NodeMaterialConnectionPoint;
  114591. autoConfigure(): void;
  114592. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114593. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114594. protected _buildBlock(state: NodeMaterialBuildState): this;
  114595. }
  114596. }
  114597. declare module BABYLON {
  114598. /**
  114599. * Block used to add light in the fragment shader
  114600. */
  114601. export class LightBlock extends NodeMaterialBlock {
  114602. private _lightId;
  114603. /**
  114604. * Create a new LightBlock
  114605. * @param name defines the block name
  114606. */
  114607. constructor(name: string);
  114608. /**
  114609. * Gets the current class name
  114610. * @returns the class name
  114611. */
  114612. getClassName(): string;
  114613. /**
  114614. * Gets the world position input component
  114615. */
  114616. readonly worldPosition: NodeMaterialConnectionPoint;
  114617. /**
  114618. * Gets the world normal input component
  114619. */
  114620. readonly worldNormal: NodeMaterialConnectionPoint;
  114621. /**
  114622. * Gets the light input component.
  114623. * If not defined, all lights will be considered
  114624. */
  114625. readonly light: NodeMaterialConnectionPoint;
  114626. /**
  114627. * Gets the camera (or eye) position component
  114628. */
  114629. readonly cameraPosition: NodeMaterialConnectionPoint;
  114630. /**
  114631. * Gets the diffuse output component
  114632. */
  114633. readonly diffuseOutput: NodeMaterialConnectionPoint;
  114634. /**
  114635. * Gets the specular output component
  114636. */
  114637. readonly specularOutput: NodeMaterialConnectionPoint;
  114638. autoConfigure(): void;
  114639. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114640. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  114641. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  114642. private _injectVertexCode;
  114643. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  114644. }
  114645. }
  114646. declare module BABYLON {
  114647. /**
  114648. * Block used to multiply 2 values
  114649. */
  114650. export class MultiplyBlock extends NodeMaterialBlock {
  114651. /**
  114652. * Creates a new MultiplyBlock
  114653. * @param name defines the block name
  114654. */
  114655. constructor(name: string);
  114656. /**
  114657. * Gets the current class name
  114658. * @returns the class name
  114659. */
  114660. getClassName(): string;
  114661. /**
  114662. * Gets the left operand input component
  114663. */
  114664. readonly left: NodeMaterialConnectionPoint;
  114665. /**
  114666. * Gets the right operand input component
  114667. */
  114668. readonly right: NodeMaterialConnectionPoint;
  114669. /**
  114670. * Gets the output component
  114671. */
  114672. readonly output: NodeMaterialConnectionPoint;
  114673. protected _buildBlock(state: NodeMaterialBuildState): this;
  114674. }
  114675. }
  114676. declare module BABYLON {
  114677. /**
  114678. * Block used to add 2 vector4
  114679. */
  114680. export class AddBlock extends NodeMaterialBlock {
  114681. /**
  114682. * Creates a new AddBlock
  114683. * @param name defines the block name
  114684. */
  114685. constructor(name: string);
  114686. /**
  114687. * Gets the current class name
  114688. * @returns the class name
  114689. */
  114690. getClassName(): string;
  114691. /**
  114692. * Gets the left operand input component
  114693. */
  114694. readonly left: NodeMaterialConnectionPoint;
  114695. /**
  114696. * Gets the right operand input component
  114697. */
  114698. readonly right: NodeMaterialConnectionPoint;
  114699. /**
  114700. * Gets the output component
  114701. */
  114702. readonly output: NodeMaterialConnectionPoint;
  114703. protected _buildBlock(state: NodeMaterialBuildState): this;
  114704. }
  114705. }
  114706. declare module BABYLON {
  114707. /**
  114708. * Block used to clamp a float
  114709. */
  114710. export class ClampBlock extends NodeMaterialBlock {
  114711. /** Gets or sets the minimum range */
  114712. minimum: number;
  114713. /** Gets or sets the maximum range */
  114714. maximum: number;
  114715. /**
  114716. * Creates a new ClampBlock
  114717. * @param name defines the block name
  114718. */
  114719. constructor(name: string);
  114720. /**
  114721. * Gets the current class name
  114722. * @returns the class name
  114723. */
  114724. getClassName(): string;
  114725. /**
  114726. * Gets the value input component
  114727. */
  114728. readonly value: NodeMaterialConnectionPoint;
  114729. /**
  114730. * Gets the output component
  114731. */
  114732. readonly output: NodeMaterialConnectionPoint;
  114733. protected _buildBlock(state: NodeMaterialBuildState): this;
  114734. }
  114735. }
  114736. declare module BABYLON {
  114737. /**
  114738. * Block used to transform a vector2 with a matrix
  114739. */
  114740. export class Vector2TransformBlock extends NodeMaterialBlock {
  114741. /**
  114742. * Defines the value to use to complement Vector2 to transform it to a Vector4
  114743. */
  114744. complementZ: number;
  114745. /**
  114746. * Defines the value to use to complement Vector2 to transform it to a Vector4
  114747. */
  114748. complementW: number;
  114749. /**
  114750. * Creates a new Vector2TransformBlock
  114751. * @param name defines the block name
  114752. */
  114753. constructor(name: string);
  114754. /**
  114755. * Gets the vector input
  114756. */
  114757. readonly vector: NodeMaterialConnectionPoint;
  114758. /**
  114759. * Gets the matrix transform input
  114760. */
  114761. readonly transform: NodeMaterialConnectionPoint;
  114762. /**
  114763. * Gets the output component
  114764. */
  114765. readonly output: NodeMaterialConnectionPoint;
  114766. /**
  114767. * Gets the current class name
  114768. * @returns the class name
  114769. */
  114770. getClassName(): string;
  114771. protected _buildBlock(state: NodeMaterialBuildState): this;
  114772. }
  114773. }
  114774. declare module BABYLON {
  114775. /**
  114776. * Block used to transform a vector3 with a matrix
  114777. */
  114778. export class Vector3TransformBlock extends NodeMaterialBlock {
  114779. /**
  114780. * Defines the value to use to complement Vector3 to transform it to a Vector4
  114781. */
  114782. complement: number;
  114783. /**
  114784. * Creates a new Vector3TransformBlock
  114785. * @param name defines the block name
  114786. */
  114787. constructor(name: string);
  114788. /**
  114789. * Gets the vector input
  114790. */
  114791. readonly vector: NodeMaterialConnectionPoint;
  114792. /**
  114793. * Gets the matrix transform input
  114794. */
  114795. readonly transform: NodeMaterialConnectionPoint;
  114796. /**
  114797. * Gets the output component
  114798. */
  114799. readonly output: NodeMaterialConnectionPoint;
  114800. /**
  114801. * Gets the current class name
  114802. * @returns the class name
  114803. */
  114804. getClassName(): string;
  114805. protected _buildBlock(state: NodeMaterialBuildState): this;
  114806. }
  114807. }
  114808. declare module BABYLON {
  114809. /**
  114810. * Helper class to render one or more effects
  114811. */
  114812. export class EffectRenderer {
  114813. private engine;
  114814. private static _Vertices;
  114815. private static _Indices;
  114816. private _vertexBuffers;
  114817. private _indexBuffer;
  114818. private _ringBufferIndex;
  114819. private _ringScreenBuffer;
  114820. private _getNextFrameBuffer;
  114821. /**
  114822. * Creates an effect renderer
  114823. * @param engine the engine to use for rendering
  114824. */
  114825. constructor(engine: Engine);
  114826. /**
  114827. * renders one or more effects to a specified texture
  114828. * @param effectWrappers list of effects to renderer
  114829. * @param outputTexture texture to draw to, if null it will render to the screen
  114830. */
  114831. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  114832. /**
  114833. * Disposes of the effect renderer
  114834. */
  114835. dispose(): void;
  114836. }
  114837. /**
  114838. * Options to create an EffectWrapper
  114839. */
  114840. interface EffectWrapperCreationOptions {
  114841. /**
  114842. * Engine to use to create the effect
  114843. */
  114844. engine: Engine;
  114845. /**
  114846. * Fragment shader for the effect
  114847. */
  114848. fragmentShader: string;
  114849. /**
  114850. * Attributes to use in the shader
  114851. */
  114852. attributeNames: Array<string>;
  114853. /**
  114854. * Uniforms to use in the shader
  114855. */
  114856. uniformNames: Array<string>;
  114857. /**
  114858. * Texture sampler names to use in the shader
  114859. */
  114860. samplerNames: Array<string>;
  114861. }
  114862. /**
  114863. * Wraps an effect to be used for rendering
  114864. */
  114865. export class EffectWrapper {
  114866. /**
  114867. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  114868. */
  114869. onApplyObservable: Observable<{}>;
  114870. /**
  114871. * The underlying effect
  114872. */
  114873. effect: Effect;
  114874. /**
  114875. * Creates an effect to be renderer
  114876. * @param creationOptions options to create the effect
  114877. */
  114878. constructor(creationOptions: EffectWrapperCreationOptions);
  114879. /**
  114880. * Disposes of the effect wrapper
  114881. */
  114882. dispose(): void;
  114883. }
  114884. }
  114885. declare module BABYLON {
  114886. /**
  114887. * Helper class to push actions to a pool of workers.
  114888. */
  114889. export class WorkerPool implements IDisposable {
  114890. private _workerInfos;
  114891. private _pendingActions;
  114892. /**
  114893. * Constructor
  114894. * @param workers Array of workers to use for actions
  114895. */
  114896. constructor(workers: Array<Worker>);
  114897. /**
  114898. * Terminates all workers and clears any pending actions.
  114899. */
  114900. dispose(): void;
  114901. /**
  114902. * Pushes an action to the worker pool. If all the workers are active, the action will be
  114903. * pended until a worker has completed its action.
  114904. * @param action The action to perform. Call onComplete when the action is complete.
  114905. */
  114906. push(action: (worker: Worker, onComplete: () => void) => void): void;
  114907. private _execute;
  114908. }
  114909. }
  114910. declare module BABYLON {
  114911. /**
  114912. * Configuration for Draco compression
  114913. */
  114914. export interface IDracoCompressionConfiguration {
  114915. /**
  114916. * Configuration for the decoder.
  114917. */
  114918. decoder: {
  114919. /**
  114920. * The url to the WebAssembly module.
  114921. */
  114922. wasmUrl?: string;
  114923. /**
  114924. * The url to the WebAssembly binary.
  114925. */
  114926. wasmBinaryUrl?: string;
  114927. /**
  114928. * The url to the fallback JavaScript module.
  114929. */
  114930. fallbackUrl?: string;
  114931. };
  114932. }
  114933. /**
  114934. * Draco compression (https://google.github.io/draco/)
  114935. *
  114936. * This class wraps the Draco module.
  114937. *
  114938. * **Encoder**
  114939. *
  114940. * The encoder is not currently implemented.
  114941. *
  114942. * **Decoder**
  114943. *
  114944. * 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.
  114945. *
  114946. * To update the configuration, use the following code:
  114947. * ```javascript
  114948. * DracoCompression.Configuration = {
  114949. * decoder: {
  114950. * wasmUrl: "<url to the WebAssembly library>",
  114951. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  114952. * fallbackUrl: "<url to the fallback JavaScript library>",
  114953. * }
  114954. * };
  114955. * ```
  114956. *
  114957. * 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.
  114958. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  114959. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  114960. *
  114961. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  114962. * ```javascript
  114963. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  114964. * ```
  114965. *
  114966. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  114967. */
  114968. export class DracoCompression implements IDisposable {
  114969. private _workerPoolPromise?;
  114970. private _decoderModulePromise?;
  114971. /**
  114972. * The configuration. Defaults to the following urls:
  114973. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  114974. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  114975. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  114976. */
  114977. static Configuration: IDracoCompressionConfiguration;
  114978. /**
  114979. * Returns true if the decoder configuration is available.
  114980. */
  114981. static readonly DecoderAvailable: boolean;
  114982. /**
  114983. * Default number of workers to create when creating the draco compression object.
  114984. */
  114985. static DefaultNumWorkers: number;
  114986. private static GetDefaultNumWorkers;
  114987. private static _Default;
  114988. /**
  114989. * Default instance for the draco compression object.
  114990. */
  114991. static readonly Default: DracoCompression;
  114992. /**
  114993. * Constructor
  114994. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  114995. */
  114996. constructor(numWorkers?: number);
  114997. /**
  114998. * Stop all async operations and release resources.
  114999. */
  115000. dispose(): void;
  115001. /**
  115002. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  115003. * @returns a promise that resolves when ready
  115004. */
  115005. whenReadyAsync(): Promise<void>;
  115006. /**
  115007. * Decode Draco compressed mesh data to vertex data.
  115008. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  115009. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  115010. * @returns A promise that resolves with the decoded vertex data
  115011. */
  115012. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  115013. [kind: string]: number;
  115014. }): Promise<VertexData>;
  115015. }
  115016. }
  115017. declare module BABYLON {
  115018. /**
  115019. * Class for building Constructive Solid Geometry
  115020. */
  115021. export class CSG {
  115022. private polygons;
  115023. /**
  115024. * The world matrix
  115025. */
  115026. matrix: Matrix;
  115027. /**
  115028. * Stores the position
  115029. */
  115030. position: Vector3;
  115031. /**
  115032. * Stores the rotation
  115033. */
  115034. rotation: Vector3;
  115035. /**
  115036. * Stores the rotation quaternion
  115037. */
  115038. rotationQuaternion: Nullable<Quaternion>;
  115039. /**
  115040. * Stores the scaling vector
  115041. */
  115042. scaling: Vector3;
  115043. /**
  115044. * Convert the Mesh to CSG
  115045. * @param mesh The Mesh to convert to CSG
  115046. * @returns A new CSG from the Mesh
  115047. */
  115048. static FromMesh(mesh: Mesh): CSG;
  115049. /**
  115050. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  115051. * @param polygons Polygons used to construct a CSG solid
  115052. */
  115053. private static FromPolygons;
  115054. /**
  115055. * Clones, or makes a deep copy, of the CSG
  115056. * @returns A new CSG
  115057. */
  115058. clone(): CSG;
  115059. /**
  115060. * Unions this CSG with another CSG
  115061. * @param csg The CSG to union against this CSG
  115062. * @returns The unioned CSG
  115063. */
  115064. union(csg: CSG): CSG;
  115065. /**
  115066. * Unions this CSG with another CSG in place
  115067. * @param csg The CSG to union against this CSG
  115068. */
  115069. unionInPlace(csg: CSG): void;
  115070. /**
  115071. * Subtracts this CSG with another CSG
  115072. * @param csg The CSG to subtract against this CSG
  115073. * @returns A new CSG
  115074. */
  115075. subtract(csg: CSG): CSG;
  115076. /**
  115077. * Subtracts this CSG with another CSG in place
  115078. * @param csg The CSG to subtact against this CSG
  115079. */
  115080. subtractInPlace(csg: CSG): void;
  115081. /**
  115082. * Intersect this CSG with another CSG
  115083. * @param csg The CSG to intersect against this CSG
  115084. * @returns A new CSG
  115085. */
  115086. intersect(csg: CSG): CSG;
  115087. /**
  115088. * Intersects this CSG with another CSG in place
  115089. * @param csg The CSG to intersect against this CSG
  115090. */
  115091. intersectInPlace(csg: CSG): void;
  115092. /**
  115093. * Return a new CSG solid with solid and empty space switched. This solid is
  115094. * not modified.
  115095. * @returns A new CSG solid with solid and empty space switched
  115096. */
  115097. inverse(): CSG;
  115098. /**
  115099. * Inverses the CSG in place
  115100. */
  115101. inverseInPlace(): void;
  115102. /**
  115103. * This is used to keep meshes transformations so they can be restored
  115104. * when we build back a Babylon Mesh
  115105. * NB : All CSG operations are performed in world coordinates
  115106. * @param csg The CSG to copy the transform attributes from
  115107. * @returns This CSG
  115108. */
  115109. copyTransformAttributes(csg: CSG): CSG;
  115110. /**
  115111. * Build Raw mesh from CSG
  115112. * Coordinates here are in world space
  115113. * @param name The name of the mesh geometry
  115114. * @param scene The Scene
  115115. * @param keepSubMeshes Specifies if the submeshes should be kept
  115116. * @returns A new Mesh
  115117. */
  115118. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  115119. /**
  115120. * Build Mesh from CSG taking material and transforms into account
  115121. * @param name The name of the Mesh
  115122. * @param material The material of the Mesh
  115123. * @param scene The Scene
  115124. * @param keepSubMeshes Specifies if submeshes should be kept
  115125. * @returns The new Mesh
  115126. */
  115127. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  115128. }
  115129. }
  115130. declare module BABYLON {
  115131. /**
  115132. * Class used to create a trail following a mesh
  115133. */
  115134. export class TrailMesh extends Mesh {
  115135. private _generator;
  115136. private _autoStart;
  115137. private _running;
  115138. private _diameter;
  115139. private _length;
  115140. private _sectionPolygonPointsCount;
  115141. private _sectionVectors;
  115142. private _sectionNormalVectors;
  115143. private _beforeRenderObserver;
  115144. /**
  115145. * @constructor
  115146. * @param name The value used by scene.getMeshByName() to do a lookup.
  115147. * @param generator The mesh to generate a trail.
  115148. * @param scene The scene to add this mesh to.
  115149. * @param diameter Diameter of trailing mesh. Default is 1.
  115150. * @param length Length of trailing mesh. Default is 60.
  115151. * @param autoStart Automatically start trailing mesh. Default true.
  115152. */
  115153. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  115154. /**
  115155. * "TrailMesh"
  115156. * @returns "TrailMesh"
  115157. */
  115158. getClassName(): string;
  115159. private _createMesh;
  115160. /**
  115161. * Start trailing mesh.
  115162. */
  115163. start(): void;
  115164. /**
  115165. * Stop trailing mesh.
  115166. */
  115167. stop(): void;
  115168. /**
  115169. * Update trailing mesh geometry.
  115170. */
  115171. update(): void;
  115172. /**
  115173. * Returns a new TrailMesh object.
  115174. * @param name is a string, the name given to the new mesh
  115175. * @param newGenerator use new generator object for cloned trail mesh
  115176. * @returns a new mesh
  115177. */
  115178. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  115179. /**
  115180. * Serializes this trail mesh
  115181. * @param serializationObject object to write serialization to
  115182. */
  115183. serialize(serializationObject: any): void;
  115184. /**
  115185. * Parses a serialized trail mesh
  115186. * @param parsedMesh the serialized mesh
  115187. * @param scene the scene to create the trail mesh in
  115188. * @returns the created trail mesh
  115189. */
  115190. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  115191. }
  115192. }
  115193. declare module BABYLON {
  115194. /**
  115195. * Class containing static functions to help procedurally build meshes
  115196. */
  115197. export class TiledBoxBuilder {
  115198. /**
  115199. * Creates a box mesh
  115200. * 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)
  115201. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115202. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115203. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115204. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115205. * @param name defines the name of the mesh
  115206. * @param options defines the options used to create the mesh
  115207. * @param scene defines the hosting scene
  115208. * @returns the box mesh
  115209. */
  115210. static CreateTiledBox(name: string, options: {
  115211. pattern?: number;
  115212. width?: number;
  115213. height?: number;
  115214. depth?: number;
  115215. tileSize?: number;
  115216. tileWidth?: number;
  115217. tileHeight?: number;
  115218. alignHorizontal?: number;
  115219. alignVertical?: number;
  115220. faceUV?: Vector4[];
  115221. faceColors?: Color4[];
  115222. sideOrientation?: number;
  115223. updatable?: boolean;
  115224. }, scene?: Nullable<Scene>): Mesh;
  115225. }
  115226. }
  115227. declare module BABYLON {
  115228. /**
  115229. * Class containing static functions to help procedurally build meshes
  115230. */
  115231. export class TorusKnotBuilder {
  115232. /**
  115233. * Creates a torus knot mesh
  115234. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  115235. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  115236. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  115237. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  115238. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115239. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115240. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115241. * @param name defines the name of the mesh
  115242. * @param options defines the options used to create the mesh
  115243. * @param scene defines the hosting scene
  115244. * @returns the torus knot mesh
  115245. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  115246. */
  115247. static CreateTorusKnot(name: string, options: {
  115248. radius?: number;
  115249. tube?: number;
  115250. radialSegments?: number;
  115251. tubularSegments?: number;
  115252. p?: number;
  115253. q?: number;
  115254. updatable?: boolean;
  115255. sideOrientation?: number;
  115256. frontUVs?: Vector4;
  115257. backUVs?: Vector4;
  115258. }, scene: any): Mesh;
  115259. }
  115260. }
  115261. declare module BABYLON {
  115262. /**
  115263. * Polygon
  115264. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  115265. */
  115266. export class Polygon {
  115267. /**
  115268. * Creates a rectangle
  115269. * @param xmin bottom X coord
  115270. * @param ymin bottom Y coord
  115271. * @param xmax top X coord
  115272. * @param ymax top Y coord
  115273. * @returns points that make the resulting rectation
  115274. */
  115275. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  115276. /**
  115277. * Creates a circle
  115278. * @param radius radius of circle
  115279. * @param cx scale in x
  115280. * @param cy scale in y
  115281. * @param numberOfSides number of sides that make up the circle
  115282. * @returns points that make the resulting circle
  115283. */
  115284. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  115285. /**
  115286. * Creates a polygon from input string
  115287. * @param input Input polygon data
  115288. * @returns the parsed points
  115289. */
  115290. static Parse(input: string): Vector2[];
  115291. /**
  115292. * Starts building a polygon from x and y coordinates
  115293. * @param x x coordinate
  115294. * @param y y coordinate
  115295. * @returns the started path2
  115296. */
  115297. static StartingAt(x: number, y: number): Path2;
  115298. }
  115299. /**
  115300. * Builds a polygon
  115301. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  115302. */
  115303. export class PolygonMeshBuilder {
  115304. private _points;
  115305. private _outlinepoints;
  115306. private _holes;
  115307. private _name;
  115308. private _scene;
  115309. private _epoints;
  115310. private _eholes;
  115311. private _addToepoint;
  115312. /**
  115313. * Babylon reference to the earcut plugin.
  115314. */
  115315. bjsEarcut: any;
  115316. /**
  115317. * Creates a PolygonMeshBuilder
  115318. * @param name name of the builder
  115319. * @param contours Path of the polygon
  115320. * @param scene scene to add to when creating the mesh
  115321. * @param earcutInjection can be used to inject your own earcut reference
  115322. */
  115323. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  115324. /**
  115325. * Adds a whole within the polygon
  115326. * @param hole Array of points defining the hole
  115327. * @returns this
  115328. */
  115329. addHole(hole: Vector2[]): PolygonMeshBuilder;
  115330. /**
  115331. * Creates the polygon
  115332. * @param updatable If the mesh should be updatable
  115333. * @param depth The depth of the mesh created
  115334. * @returns the created mesh
  115335. */
  115336. build(updatable?: boolean, depth?: number): Mesh;
  115337. /**
  115338. * Creates the polygon
  115339. * @param depth The depth of the mesh created
  115340. * @returns the created VertexData
  115341. */
  115342. buildVertexData(depth?: number): VertexData;
  115343. /**
  115344. * Adds a side to the polygon
  115345. * @param positions points that make the polygon
  115346. * @param normals normals of the polygon
  115347. * @param uvs uvs of the polygon
  115348. * @param indices indices of the polygon
  115349. * @param bounds bounds of the polygon
  115350. * @param points points of the polygon
  115351. * @param depth depth of the polygon
  115352. * @param flip flip of the polygon
  115353. */
  115354. private addSide;
  115355. }
  115356. }
  115357. declare module BABYLON {
  115358. /**
  115359. * Class containing static functions to help procedurally build meshes
  115360. */
  115361. export class PolygonBuilder {
  115362. /**
  115363. * Creates a polygon mesh
  115364. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  115365. * * 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
  115366. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115367. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115368. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  115369. * * Remember you can only change the shape positions, not their number when updating a polygon
  115370. * @param name defines the name of the mesh
  115371. * @param options defines the options used to create the mesh
  115372. * @param scene defines the hosting scene
  115373. * @param earcutInjection can be used to inject your own earcut reference
  115374. * @returns the polygon mesh
  115375. */
  115376. static CreatePolygon(name: string, options: {
  115377. shape: Vector3[];
  115378. holes?: Vector3[][];
  115379. depth?: number;
  115380. faceUV?: Vector4[];
  115381. faceColors?: Color4[];
  115382. updatable?: boolean;
  115383. sideOrientation?: number;
  115384. frontUVs?: Vector4;
  115385. backUVs?: Vector4;
  115386. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  115387. /**
  115388. * Creates an extruded polygon mesh, with depth in the Y direction.
  115389. * * 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)
  115390. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115391. * @param name defines the name of the mesh
  115392. * @param options defines the options used to create the mesh
  115393. * @param scene defines the hosting scene
  115394. * @param earcutInjection can be used to inject your own earcut reference
  115395. * @returns the polygon mesh
  115396. */
  115397. static ExtrudePolygon(name: string, options: {
  115398. shape: Vector3[];
  115399. holes?: Vector3[][];
  115400. depth?: number;
  115401. faceUV?: Vector4[];
  115402. faceColors?: Color4[];
  115403. updatable?: boolean;
  115404. sideOrientation?: number;
  115405. frontUVs?: Vector4;
  115406. backUVs?: Vector4;
  115407. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  115408. }
  115409. }
  115410. declare module BABYLON {
  115411. /**
  115412. * Class containing static functions to help procedurally build meshes
  115413. */
  115414. export class LatheBuilder {
  115415. /**
  115416. * Creates lathe mesh.
  115417. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  115418. * * 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
  115419. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  115420. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  115421. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  115422. * * 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
  115423. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  115424. * * 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
  115425. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115426. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115427. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115428. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115429. * @param name defines the name of the mesh
  115430. * @param options defines the options used to create the mesh
  115431. * @param scene defines the hosting scene
  115432. * @returns the lathe mesh
  115433. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  115434. */
  115435. static CreateLathe(name: string, options: {
  115436. shape: Vector3[];
  115437. radius?: number;
  115438. tessellation?: number;
  115439. clip?: number;
  115440. arc?: number;
  115441. closed?: boolean;
  115442. updatable?: boolean;
  115443. sideOrientation?: number;
  115444. frontUVs?: Vector4;
  115445. backUVs?: Vector4;
  115446. cap?: number;
  115447. invertUV?: boolean;
  115448. }, scene?: Nullable<Scene>): Mesh;
  115449. }
  115450. }
  115451. declare module BABYLON {
  115452. /**
  115453. * Class containing static functions to help procedurally build meshes
  115454. */
  115455. export class TiledPlaneBuilder {
  115456. /**
  115457. * Creates a tiled plane mesh
  115458. * * The parameter `pattern` will, depending on value, do nothing or
  115459. * * * flip (reflect about central vertical) alternate tiles across and up
  115460. * * * flip every tile on alternate rows
  115461. * * * rotate (180 degs) alternate tiles across and up
  115462. * * * rotate every tile on alternate rows
  115463. * * * flip and rotate alternate tiles across and up
  115464. * * * flip and rotate every tile on alternate rows
  115465. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  115466. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  115467. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115468. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  115469. * * 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)
  115470. * * 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)
  115471. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  115472. * @param name defines the name of the mesh
  115473. * @param options defines the options used to create the mesh
  115474. * @param scene defines the hosting scene
  115475. * @returns the box mesh
  115476. */
  115477. static CreateTiledPlane(name: string, options: {
  115478. pattern?: number;
  115479. tileSize?: number;
  115480. tileWidth?: number;
  115481. tileHeight?: number;
  115482. size?: number;
  115483. width?: number;
  115484. height?: number;
  115485. alignHorizontal?: number;
  115486. alignVertical?: number;
  115487. sideOrientation?: number;
  115488. frontUVs?: Vector4;
  115489. backUVs?: Vector4;
  115490. updatable?: boolean;
  115491. }, scene?: Nullable<Scene>): Mesh;
  115492. }
  115493. }
  115494. declare module BABYLON {
  115495. /**
  115496. * Class containing static functions to help procedurally build meshes
  115497. */
  115498. export class TubeBuilder {
  115499. /**
  115500. * Creates a tube mesh.
  115501. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  115502. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  115503. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  115504. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  115505. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  115506. * * 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)
  115507. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  115508. * * 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
  115509. * * 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
  115510. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115511. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115512. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115514. * @param name defines the name of the mesh
  115515. * @param options defines the options used to create the mesh
  115516. * @param scene defines the hosting scene
  115517. * @returns the tube mesh
  115518. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115519. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  115520. */
  115521. static CreateTube(name: string, options: {
  115522. path: Vector3[];
  115523. radius?: number;
  115524. tessellation?: number;
  115525. radiusFunction?: {
  115526. (i: number, distance: number): number;
  115527. };
  115528. cap?: number;
  115529. arc?: number;
  115530. updatable?: boolean;
  115531. sideOrientation?: number;
  115532. frontUVs?: Vector4;
  115533. backUVs?: Vector4;
  115534. instance?: Mesh;
  115535. invertUV?: boolean;
  115536. }, scene?: Nullable<Scene>): Mesh;
  115537. }
  115538. }
  115539. declare module BABYLON {
  115540. /**
  115541. * Class containing static functions to help procedurally build meshes
  115542. */
  115543. export class IcoSphereBuilder {
  115544. /**
  115545. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  115546. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  115547. * * 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`)
  115548. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  115549. * * 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
  115550. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115551. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115553. * @param name defines the name of the mesh
  115554. * @param options defines the options used to create the mesh
  115555. * @param scene defines the hosting scene
  115556. * @returns the icosahedron mesh
  115557. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  115558. */
  115559. static CreateIcoSphere(name: string, options: {
  115560. radius?: number;
  115561. radiusX?: number;
  115562. radiusY?: number;
  115563. radiusZ?: number;
  115564. flat?: boolean;
  115565. subdivisions?: number;
  115566. sideOrientation?: number;
  115567. frontUVs?: Vector4;
  115568. backUVs?: Vector4;
  115569. updatable?: boolean;
  115570. }, scene?: Nullable<Scene>): Mesh;
  115571. }
  115572. }
  115573. declare module BABYLON {
  115574. /**
  115575. * Class containing static functions to help procedurally build meshes
  115576. */
  115577. export class DecalBuilder {
  115578. /**
  115579. * Creates a decal mesh.
  115580. * 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
  115581. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  115582. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  115583. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  115584. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  115585. * @param name defines the name of the mesh
  115586. * @param sourceMesh defines the mesh where the decal must be applied
  115587. * @param options defines the options used to create the mesh
  115588. * @param scene defines the hosting scene
  115589. * @returns the decal mesh
  115590. * @see https://doc.babylonjs.com/how_to/decals
  115591. */
  115592. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  115593. position?: Vector3;
  115594. normal?: Vector3;
  115595. size?: Vector3;
  115596. angle?: number;
  115597. }): Mesh;
  115598. }
  115599. }
  115600. declare module BABYLON {
  115601. /**
  115602. * Class containing static functions to help procedurally build meshes
  115603. */
  115604. export class MeshBuilder {
  115605. /**
  115606. * Creates a box mesh
  115607. * * The parameter `size` sets the size (float) of each box side (default 1)
  115608. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  115609. * * 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)
  115610. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  115611. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115612. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115613. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115614. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  115615. * @param name defines the name of the mesh
  115616. * @param options defines the options used to create the mesh
  115617. * @param scene defines the hosting scene
  115618. * @returns the box mesh
  115619. */
  115620. static CreateBox(name: string, options: {
  115621. size?: number;
  115622. width?: number;
  115623. height?: number;
  115624. depth?: number;
  115625. faceUV?: Vector4[];
  115626. faceColors?: Color4[];
  115627. sideOrientation?: number;
  115628. frontUVs?: Vector4;
  115629. backUVs?: Vector4;
  115630. updatable?: boolean;
  115631. }, scene?: Nullable<Scene>): Mesh;
  115632. /**
  115633. * Creates a tiled box mesh
  115634. * * faceTiles sets the pattern, tile size and number of tiles for a face
  115635. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115636. * @param name defines the name of the mesh
  115637. * @param options defines the options used to create the mesh
  115638. * @param scene defines the hosting scene
  115639. * @returns the tiled box mesh
  115640. */
  115641. static CreateTiledBox(name: string, options: {
  115642. pattern?: number;
  115643. size?: number;
  115644. width?: number;
  115645. height?: number;
  115646. depth: number;
  115647. tileSize?: number;
  115648. tileWidth?: number;
  115649. tileHeight?: number;
  115650. faceUV?: Vector4[];
  115651. faceColors?: Color4[];
  115652. alignHorizontal?: number;
  115653. alignVertical?: number;
  115654. sideOrientation?: number;
  115655. updatable?: boolean;
  115656. }, scene?: Nullable<Scene>): Mesh;
  115657. /**
  115658. * Creates a sphere mesh
  115659. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  115660. * * 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`)
  115661. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  115662. * * 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
  115663. * * 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)
  115664. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115665. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115666. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115667. * @param name defines the name of the mesh
  115668. * @param options defines the options used to create the mesh
  115669. * @param scene defines the hosting scene
  115670. * @returns the sphere mesh
  115671. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  115672. */
  115673. static CreateSphere(name: string, options: {
  115674. segments?: number;
  115675. diameter?: number;
  115676. diameterX?: number;
  115677. diameterY?: number;
  115678. diameterZ?: number;
  115679. arc?: number;
  115680. slice?: number;
  115681. sideOrientation?: number;
  115682. frontUVs?: Vector4;
  115683. backUVs?: Vector4;
  115684. updatable?: boolean;
  115685. }, scene?: Nullable<Scene>): Mesh;
  115686. /**
  115687. * Creates a plane polygonal mesh. By default, this is a disc
  115688. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  115689. * * 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
  115690. * * 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
  115691. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115692. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115694. * @param name defines the name of the mesh
  115695. * @param options defines the options used to create the mesh
  115696. * @param scene defines the hosting scene
  115697. * @returns the plane polygonal mesh
  115698. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  115699. */
  115700. static CreateDisc(name: string, options: {
  115701. radius?: number;
  115702. tessellation?: number;
  115703. arc?: number;
  115704. updatable?: boolean;
  115705. sideOrientation?: number;
  115706. frontUVs?: Vector4;
  115707. backUVs?: Vector4;
  115708. }, scene?: Nullable<Scene>): Mesh;
  115709. /**
  115710. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  115711. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  115712. * * 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`)
  115713. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  115714. * * 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
  115715. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115716. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115717. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115718. * @param name defines the name of the mesh
  115719. * @param options defines the options used to create the mesh
  115720. * @param scene defines the hosting scene
  115721. * @returns the icosahedron mesh
  115722. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  115723. */
  115724. static CreateIcoSphere(name: string, options: {
  115725. radius?: number;
  115726. radiusX?: number;
  115727. radiusY?: number;
  115728. radiusZ?: number;
  115729. flat?: boolean;
  115730. subdivisions?: number;
  115731. sideOrientation?: number;
  115732. frontUVs?: Vector4;
  115733. backUVs?: Vector4;
  115734. updatable?: boolean;
  115735. }, scene?: Nullable<Scene>): Mesh;
  115736. /**
  115737. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  115738. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  115739. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  115740. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  115741. * * 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
  115742. * * 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
  115743. * * 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
  115744. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115745. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115746. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115747. * * 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
  115748. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  115749. * * 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
  115750. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  115751. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115752. * @param name defines the name of the mesh
  115753. * @param options defines the options used to create the mesh
  115754. * @param scene defines the hosting scene
  115755. * @returns the ribbon mesh
  115756. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  115757. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115758. */
  115759. static CreateRibbon(name: string, options: {
  115760. pathArray: Vector3[][];
  115761. closeArray?: boolean;
  115762. closePath?: boolean;
  115763. offset?: number;
  115764. updatable?: boolean;
  115765. sideOrientation?: number;
  115766. frontUVs?: Vector4;
  115767. backUVs?: Vector4;
  115768. instance?: Mesh;
  115769. invertUV?: boolean;
  115770. uvs?: Vector2[];
  115771. colors?: Color4[];
  115772. }, scene?: Nullable<Scene>): Mesh;
  115773. /**
  115774. * Creates a cylinder or a cone mesh
  115775. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  115776. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  115777. * * 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.
  115778. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  115779. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  115780. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  115781. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  115782. * * 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).
  115783. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  115784. * * 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).
  115785. * * 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
  115786. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  115787. * * 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
  115788. * * 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.
  115789. * * If `enclose` is false, a ring surface is one element.
  115790. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  115791. * * 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
  115792. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115793. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115794. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115795. * @param name defines the name of the mesh
  115796. * @param options defines the options used to create the mesh
  115797. * @param scene defines the hosting scene
  115798. * @returns the cylinder mesh
  115799. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  115800. */
  115801. static CreateCylinder(name: string, options: {
  115802. height?: number;
  115803. diameterTop?: number;
  115804. diameterBottom?: number;
  115805. diameter?: number;
  115806. tessellation?: number;
  115807. subdivisions?: number;
  115808. arc?: number;
  115809. faceColors?: Color4[];
  115810. faceUV?: Vector4[];
  115811. updatable?: boolean;
  115812. hasRings?: boolean;
  115813. enclose?: boolean;
  115814. cap?: number;
  115815. sideOrientation?: number;
  115816. frontUVs?: Vector4;
  115817. backUVs?: Vector4;
  115818. }, scene?: Nullable<Scene>): Mesh;
  115819. /**
  115820. * Creates a torus mesh
  115821. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  115822. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  115823. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  115824. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115825. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115826. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115827. * @param name defines the name of the mesh
  115828. * @param options defines the options used to create the mesh
  115829. * @param scene defines the hosting scene
  115830. * @returns the torus mesh
  115831. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  115832. */
  115833. static CreateTorus(name: string, options: {
  115834. diameter?: number;
  115835. thickness?: number;
  115836. tessellation?: number;
  115837. updatable?: boolean;
  115838. sideOrientation?: number;
  115839. frontUVs?: Vector4;
  115840. backUVs?: Vector4;
  115841. }, scene?: Nullable<Scene>): Mesh;
  115842. /**
  115843. * Creates a torus knot mesh
  115844. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  115845. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  115846. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  115847. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  115848. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115849. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115851. * @param name defines the name of the mesh
  115852. * @param options defines the options used to create the mesh
  115853. * @param scene defines the hosting scene
  115854. * @returns the torus knot mesh
  115855. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  115856. */
  115857. static CreateTorusKnot(name: string, options: {
  115858. radius?: number;
  115859. tube?: number;
  115860. radialSegments?: number;
  115861. tubularSegments?: number;
  115862. p?: number;
  115863. q?: number;
  115864. updatable?: boolean;
  115865. sideOrientation?: number;
  115866. frontUVs?: Vector4;
  115867. backUVs?: Vector4;
  115868. }, scene?: Nullable<Scene>): Mesh;
  115869. /**
  115870. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  115871. * * 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
  115872. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  115873. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  115874. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  115875. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  115876. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  115877. * * 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
  115878. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  115879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115880. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  115881. * @param name defines the name of the new line system
  115882. * @param options defines the options used to create the line system
  115883. * @param scene defines the hosting scene
  115884. * @returns a new line system mesh
  115885. */
  115886. static CreateLineSystem(name: string, options: {
  115887. lines: Vector3[][];
  115888. updatable?: boolean;
  115889. instance?: Nullable<LinesMesh>;
  115890. colors?: Nullable<Color4[][]>;
  115891. useVertexAlpha?: boolean;
  115892. }, scene: Nullable<Scene>): LinesMesh;
  115893. /**
  115894. * Creates a line mesh
  115895. * 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
  115896. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  115897. * * The parameter `points` is an array successive Vector3
  115898. * * 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
  115899. * * The optional parameter `colors` is an array of successive Color4, one per line point
  115900. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  115901. * * When updating an instance, remember that only point positions can change, not the number of points
  115902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115903. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  115904. * @param name defines the name of the new line system
  115905. * @param options defines the options used to create the line system
  115906. * @param scene defines the hosting scene
  115907. * @returns a new line mesh
  115908. */
  115909. static CreateLines(name: string, options: {
  115910. points: Vector3[];
  115911. updatable?: boolean;
  115912. instance?: Nullable<LinesMesh>;
  115913. colors?: Color4[];
  115914. useVertexAlpha?: boolean;
  115915. }, scene?: Nullable<Scene>): LinesMesh;
  115916. /**
  115917. * Creates a dashed line mesh
  115918. * * 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
  115919. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  115920. * * The parameter `points` is an array successive Vector3
  115921. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  115922. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  115923. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  115924. * * 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
  115925. * * When updating an instance, remember that only point positions can change, not the number of points
  115926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115927. * @param name defines the name of the mesh
  115928. * @param options defines the options used to create the mesh
  115929. * @param scene defines the hosting scene
  115930. * @returns the dashed line mesh
  115931. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  115932. */
  115933. static CreateDashedLines(name: string, options: {
  115934. points: Vector3[];
  115935. dashSize?: number;
  115936. gapSize?: number;
  115937. dashNb?: number;
  115938. updatable?: boolean;
  115939. instance?: LinesMesh;
  115940. }, scene?: Nullable<Scene>): LinesMesh;
  115941. /**
  115942. * 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.
  115943. * * 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.
  115944. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  115945. * * 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.
  115946. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  115947. * * 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
  115948. * * 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
  115949. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  115950. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115951. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115952. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  115953. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115954. * @param name defines the name of the mesh
  115955. * @param options defines the options used to create the mesh
  115956. * @param scene defines the hosting scene
  115957. * @returns the extruded shape mesh
  115958. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115959. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  115960. */
  115961. static ExtrudeShape(name: string, options: {
  115962. shape: Vector3[];
  115963. path: Vector3[];
  115964. scale?: number;
  115965. rotation?: number;
  115966. cap?: number;
  115967. updatable?: boolean;
  115968. sideOrientation?: number;
  115969. frontUVs?: Vector4;
  115970. backUVs?: Vector4;
  115971. instance?: Mesh;
  115972. invertUV?: boolean;
  115973. }, scene?: Nullable<Scene>): Mesh;
  115974. /**
  115975. * Creates an custom extruded shape mesh.
  115976. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  115977. * * 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.
  115978. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  115979. * * 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
  115980. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  115981. * * 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
  115982. * * It must returns a float value that will be the scale value applied to the shape on each path point
  115983. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  115984. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  115985. * * 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
  115986. * * 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
  115987. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  115988. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115989. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115990. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  115991. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115992. * @param name defines the name of the mesh
  115993. * @param options defines the options used to create the mesh
  115994. * @param scene defines the hosting scene
  115995. * @returns the custom extruded shape mesh
  115996. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  115997. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  115998. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  115999. */
  116000. static ExtrudeShapeCustom(name: string, options: {
  116001. shape: Vector3[];
  116002. path: Vector3[];
  116003. scaleFunction?: any;
  116004. rotationFunction?: any;
  116005. ribbonCloseArray?: boolean;
  116006. ribbonClosePath?: boolean;
  116007. cap?: number;
  116008. updatable?: boolean;
  116009. sideOrientation?: number;
  116010. frontUVs?: Vector4;
  116011. backUVs?: Vector4;
  116012. instance?: Mesh;
  116013. invertUV?: boolean;
  116014. }, scene?: Nullable<Scene>): Mesh;
  116015. /**
  116016. * Creates lathe mesh.
  116017. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  116018. * * 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
  116019. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  116020. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  116021. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  116022. * * 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
  116023. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  116024. * * 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
  116025. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116026. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116027. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116028. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116029. * @param name defines the name of the mesh
  116030. * @param options defines the options used to create the mesh
  116031. * @param scene defines the hosting scene
  116032. * @returns the lathe mesh
  116033. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  116034. */
  116035. static CreateLathe(name: string, options: {
  116036. shape: Vector3[];
  116037. radius?: number;
  116038. tessellation?: number;
  116039. clip?: number;
  116040. arc?: number;
  116041. closed?: boolean;
  116042. updatable?: boolean;
  116043. sideOrientation?: number;
  116044. frontUVs?: Vector4;
  116045. backUVs?: Vector4;
  116046. cap?: number;
  116047. invertUV?: boolean;
  116048. }, scene?: Nullable<Scene>): Mesh;
  116049. /**
  116050. * Creates a tiled plane mesh
  116051. * * You can set a limited pattern arrangement with the tiles
  116052. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116053. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116055. * @param name defines the name of the mesh
  116056. * @param options defines the options used to create the mesh
  116057. * @param scene defines the hosting scene
  116058. * @returns the plane mesh
  116059. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  116060. */
  116061. static CreateTiledPlane(name: string, options: {
  116062. pattern?: number;
  116063. tileSize?: number;
  116064. tileWidth?: number;
  116065. tileHeight?: number;
  116066. size?: number;
  116067. width?: number;
  116068. height?: number;
  116069. alignHorizontal?: number;
  116070. alignVertical?: number;
  116071. sideOrientation?: number;
  116072. frontUVs?: Vector4;
  116073. backUVs?: Vector4;
  116074. updatable?: boolean;
  116075. }, scene?: Nullable<Scene>): Mesh;
  116076. /**
  116077. * Creates a plane mesh
  116078. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  116079. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  116080. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  116081. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116082. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116083. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116084. * @param name defines the name of the mesh
  116085. * @param options defines the options used to create the mesh
  116086. * @param scene defines the hosting scene
  116087. * @returns the plane mesh
  116088. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  116089. */
  116090. static CreatePlane(name: string, options: {
  116091. size?: number;
  116092. width?: number;
  116093. height?: number;
  116094. sideOrientation?: number;
  116095. frontUVs?: Vector4;
  116096. backUVs?: Vector4;
  116097. updatable?: boolean;
  116098. sourcePlane?: Plane;
  116099. }, scene?: Nullable<Scene>): Mesh;
  116100. /**
  116101. * Creates a ground mesh
  116102. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  116103. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  116104. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116105. * @param name defines the name of the mesh
  116106. * @param options defines the options used to create the mesh
  116107. * @param scene defines the hosting scene
  116108. * @returns the ground mesh
  116109. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  116110. */
  116111. static CreateGround(name: string, options: {
  116112. width?: number;
  116113. height?: number;
  116114. subdivisions?: number;
  116115. subdivisionsX?: number;
  116116. subdivisionsY?: number;
  116117. updatable?: boolean;
  116118. }, scene?: Nullable<Scene>): Mesh;
  116119. /**
  116120. * Creates a tiled ground mesh
  116121. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  116122. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  116123. * * 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
  116124. * * 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
  116125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116126. * @param name defines the name of the mesh
  116127. * @param options defines the options used to create the mesh
  116128. * @param scene defines the hosting scene
  116129. * @returns the tiled ground mesh
  116130. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  116131. */
  116132. static CreateTiledGround(name: string, options: {
  116133. xmin: number;
  116134. zmin: number;
  116135. xmax: number;
  116136. zmax: number;
  116137. subdivisions?: {
  116138. w: number;
  116139. h: number;
  116140. };
  116141. precision?: {
  116142. w: number;
  116143. h: number;
  116144. };
  116145. updatable?: boolean;
  116146. }, scene?: Nullable<Scene>): Mesh;
  116147. /**
  116148. * Creates a ground mesh from a height map
  116149. * * The parameter `url` sets the URL of the height map image resource.
  116150. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  116151. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  116152. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  116153. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  116154. * * 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.
  116155. * * 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).
  116156. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  116157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  116158. * @param name defines the name of the mesh
  116159. * @param url defines the url to the height map
  116160. * @param options defines the options used to create the mesh
  116161. * @param scene defines the hosting scene
  116162. * @returns the ground mesh
  116163. * @see https://doc.babylonjs.com/babylon101/height_map
  116164. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  116165. */
  116166. static CreateGroundFromHeightMap(name: string, url: string, options: {
  116167. width?: number;
  116168. height?: number;
  116169. subdivisions?: number;
  116170. minHeight?: number;
  116171. maxHeight?: number;
  116172. colorFilter?: Color3;
  116173. alphaFilter?: number;
  116174. updatable?: boolean;
  116175. onReady?: (mesh: GroundMesh) => void;
  116176. }, scene?: Nullable<Scene>): GroundMesh;
  116177. /**
  116178. * Creates a polygon mesh
  116179. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  116180. * * 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
  116181. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  116182. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116183. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  116184. * * Remember you can only change the shape positions, not their number when updating a polygon
  116185. * @param name defines the name of the mesh
  116186. * @param options defines the options used to create the mesh
  116187. * @param scene defines the hosting scene
  116188. * @param earcutInjection can be used to inject your own earcut reference
  116189. * @returns the polygon mesh
  116190. */
  116191. static CreatePolygon(name: string, options: {
  116192. shape: Vector3[];
  116193. holes?: Vector3[][];
  116194. depth?: number;
  116195. faceUV?: Vector4[];
  116196. faceColors?: Color4[];
  116197. updatable?: boolean;
  116198. sideOrientation?: number;
  116199. frontUVs?: Vector4;
  116200. backUVs?: Vector4;
  116201. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  116202. /**
  116203. * Creates an extruded polygon mesh, with depth in the Y direction.
  116204. * * 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)
  116205. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  116206. * @param name defines the name of the mesh
  116207. * @param options defines the options used to create the mesh
  116208. * @param scene defines the hosting scene
  116209. * @param earcutInjection can be used to inject your own earcut reference
  116210. * @returns the polygon mesh
  116211. */
  116212. static ExtrudePolygon(name: string, options: {
  116213. shape: Vector3[];
  116214. holes?: Vector3[][];
  116215. depth?: number;
  116216. faceUV?: Vector4[];
  116217. faceColors?: Color4[];
  116218. updatable?: boolean;
  116219. sideOrientation?: number;
  116220. frontUVs?: Vector4;
  116221. backUVs?: Vector4;
  116222. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  116223. /**
  116224. * Creates a tube mesh.
  116225. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  116226. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  116227. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  116228. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  116229. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  116230. * * 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)
  116231. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  116232. * * 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
  116233. * * 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
  116234. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116235. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  116236. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  116237. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  116238. * @param name defines the name of the mesh
  116239. * @param options defines the options used to create the mesh
  116240. * @param scene defines the hosting scene
  116241. * @returns the tube mesh
  116242. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  116243. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  116244. */
  116245. static CreateTube(name: string, options: {
  116246. path: Vector3[];
  116247. radius?: number;
  116248. tessellation?: number;
  116249. radiusFunction?: {
  116250. (i: number, distance: number): number;
  116251. };
  116252. cap?: number;
  116253. arc?: number;
  116254. updatable?: boolean;
  116255. sideOrientation?: number;
  116256. frontUVs?: Vector4;
  116257. backUVs?: Vector4;
  116258. instance?: Mesh;
  116259. invertUV?: boolean;
  116260. }, scene?: Nullable<Scene>): Mesh;
  116261. /**
  116262. * Creates a polyhedron mesh
  116263. * * 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
  116264. * * The parameter `size` (positive float, default 1) sets the polygon size
  116265. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  116266. * * 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`
  116267. * * 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
  116268. * * 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)`)
  116269. * * 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
  116270. * * 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
  116271. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  116272. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  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 polyhedron mesh
  116278. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  116279. */
  116280. static CreatePolyhedron(name: string, options: {
  116281. type?: number;
  116282. size?: number;
  116283. sizeX?: number;
  116284. sizeY?: number;
  116285. sizeZ?: number;
  116286. custom?: any;
  116287. faceUV?: Vector4[];
  116288. faceColors?: Color4[];
  116289. flat?: boolean;
  116290. updatable?: boolean;
  116291. sideOrientation?: number;
  116292. frontUVs?: Vector4;
  116293. backUVs?: Vector4;
  116294. }, scene?: Nullable<Scene>): Mesh;
  116295. /**
  116296. * Creates a decal mesh.
  116297. * 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
  116298. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  116299. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  116300. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  116301. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  116302. * @param name defines the name of the mesh
  116303. * @param sourceMesh defines the mesh where the decal must be applied
  116304. * @param options defines the options used to create the mesh
  116305. * @param scene defines the hosting scene
  116306. * @returns the decal mesh
  116307. * @see https://doc.babylonjs.com/how_to/decals
  116308. */
  116309. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  116310. position?: Vector3;
  116311. normal?: Vector3;
  116312. size?: Vector3;
  116313. angle?: number;
  116314. }): Mesh;
  116315. }
  116316. }
  116317. declare module BABYLON {
  116318. /**
  116319. * A simplifier interface for future simplification implementations
  116320. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116321. */
  116322. export interface ISimplifier {
  116323. /**
  116324. * Simplification of a given mesh according to the given settings.
  116325. * Since this requires computation, it is assumed that the function runs async.
  116326. * @param settings The settings of the simplification, including quality and distance
  116327. * @param successCallback A callback that will be called after the mesh was simplified.
  116328. * @param errorCallback in case of an error, this callback will be called. optional.
  116329. */
  116330. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  116331. }
  116332. /**
  116333. * Expected simplification settings.
  116334. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  116335. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116336. */
  116337. export interface ISimplificationSettings {
  116338. /**
  116339. * Gets or sets the expected quality
  116340. */
  116341. quality: number;
  116342. /**
  116343. * Gets or sets the distance when this optimized version should be used
  116344. */
  116345. distance: number;
  116346. /**
  116347. * Gets an already optimized mesh
  116348. */
  116349. optimizeMesh?: boolean;
  116350. }
  116351. /**
  116352. * Class used to specify simplification options
  116353. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116354. */
  116355. export class SimplificationSettings implements ISimplificationSettings {
  116356. /** expected quality */
  116357. quality: number;
  116358. /** distance when this optimized version should be used */
  116359. distance: number;
  116360. /** already optimized mesh */
  116361. optimizeMesh?: boolean | undefined;
  116362. /**
  116363. * Creates a SimplificationSettings
  116364. * @param quality expected quality
  116365. * @param distance distance when this optimized version should be used
  116366. * @param optimizeMesh already optimized mesh
  116367. */
  116368. constructor(
  116369. /** expected quality */
  116370. quality: number,
  116371. /** distance when this optimized version should be used */
  116372. distance: number,
  116373. /** already optimized mesh */
  116374. optimizeMesh?: boolean | undefined);
  116375. }
  116376. /**
  116377. * Interface used to define a simplification task
  116378. */
  116379. export interface ISimplificationTask {
  116380. /**
  116381. * Array of settings
  116382. */
  116383. settings: Array<ISimplificationSettings>;
  116384. /**
  116385. * Simplification type
  116386. */
  116387. simplificationType: SimplificationType;
  116388. /**
  116389. * Mesh to simplify
  116390. */
  116391. mesh: Mesh;
  116392. /**
  116393. * Callback called on success
  116394. */
  116395. successCallback?: () => void;
  116396. /**
  116397. * Defines if parallel processing can be used
  116398. */
  116399. parallelProcessing: boolean;
  116400. }
  116401. /**
  116402. * Queue used to order the simplification tasks
  116403. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116404. */
  116405. export class SimplificationQueue {
  116406. private _simplificationArray;
  116407. /**
  116408. * Gets a boolean indicating that the process is still running
  116409. */
  116410. running: boolean;
  116411. /**
  116412. * Creates a new queue
  116413. */
  116414. constructor();
  116415. /**
  116416. * Adds a new simplification task
  116417. * @param task defines a task to add
  116418. */
  116419. addTask(task: ISimplificationTask): void;
  116420. /**
  116421. * Execute next task
  116422. */
  116423. executeNext(): void;
  116424. /**
  116425. * Execute a simplification task
  116426. * @param task defines the task to run
  116427. */
  116428. runSimplification(task: ISimplificationTask): void;
  116429. private getSimplifier;
  116430. }
  116431. /**
  116432. * The implemented types of simplification
  116433. * At the moment only Quadratic Error Decimation is implemented
  116434. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116435. */
  116436. export enum SimplificationType {
  116437. /** Quadratic error decimation */
  116438. QUADRATIC = 0
  116439. }
  116440. }
  116441. declare module BABYLON {
  116442. interface Scene {
  116443. /** @hidden (Backing field) */
  116444. _simplificationQueue: SimplificationQueue;
  116445. /**
  116446. * Gets or sets the simplification queue attached to the scene
  116447. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  116448. */
  116449. simplificationQueue: SimplificationQueue;
  116450. }
  116451. interface Mesh {
  116452. /**
  116453. * Simplify the mesh according to the given array of settings.
  116454. * Function will return immediately and will simplify async
  116455. * @param settings a collection of simplification settings
  116456. * @param parallelProcessing should all levels calculate parallel or one after the other
  116457. * @param simplificationType the type of simplification to run
  116458. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  116459. * @returns the current mesh
  116460. */
  116461. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  116462. }
  116463. /**
  116464. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  116465. * created in a scene
  116466. */
  116467. export class SimplicationQueueSceneComponent implements ISceneComponent {
  116468. /**
  116469. * The component name helpfull to identify the component in the list of scene components.
  116470. */
  116471. readonly name: string;
  116472. /**
  116473. * The scene the component belongs to.
  116474. */
  116475. scene: Scene;
  116476. /**
  116477. * Creates a new instance of the component for the given scene
  116478. * @param scene Defines the scene to register the component in
  116479. */
  116480. constructor(scene: Scene);
  116481. /**
  116482. * Registers the component in a given scene
  116483. */
  116484. register(): void;
  116485. /**
  116486. * Rebuilds the elements related to this component in case of
  116487. * context lost for instance.
  116488. */
  116489. rebuild(): void;
  116490. /**
  116491. * Disposes the component and the associated ressources
  116492. */
  116493. dispose(): void;
  116494. private _beforeCameraUpdate;
  116495. }
  116496. }
  116497. declare module BABYLON {
  116498. /**
  116499. * Class used to enable access to IndexedDB
  116500. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  116501. */
  116502. export class Database implements IOfflineProvider {
  116503. private _callbackManifestChecked;
  116504. private _currentSceneUrl;
  116505. private _db;
  116506. private _enableSceneOffline;
  116507. private _enableTexturesOffline;
  116508. private _manifestVersionFound;
  116509. private _mustUpdateRessources;
  116510. private _hasReachedQuota;
  116511. private _isSupported;
  116512. private _idbFactory;
  116513. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  116514. private static IsUASupportingBlobStorage;
  116515. /**
  116516. * Gets a boolean indicating if Database storate is enabled (off by default)
  116517. */
  116518. static IDBStorageEnabled: boolean;
  116519. /**
  116520. * Gets a boolean indicating if scene must be saved in the database
  116521. */
  116522. readonly enableSceneOffline: boolean;
  116523. /**
  116524. * Gets a boolean indicating if textures must be saved in the database
  116525. */
  116526. readonly enableTexturesOffline: boolean;
  116527. /**
  116528. * Creates a new Database
  116529. * @param urlToScene defines the url to load the scene
  116530. * @param callbackManifestChecked defines the callback to use when manifest is checked
  116531. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  116532. */
  116533. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  116534. private static _ParseURL;
  116535. private static _ReturnFullUrlLocation;
  116536. private _checkManifestFile;
  116537. /**
  116538. * Open the database and make it available
  116539. * @param successCallback defines the callback to call on success
  116540. * @param errorCallback defines the callback to call on error
  116541. */
  116542. open(successCallback: () => void, errorCallback: () => void): void;
  116543. /**
  116544. * Loads an image from the database
  116545. * @param url defines the url to load from
  116546. * @param image defines the target DOM image
  116547. */
  116548. loadImage(url: string, image: HTMLImageElement): void;
  116549. private _loadImageFromDBAsync;
  116550. private _saveImageIntoDBAsync;
  116551. private _checkVersionFromDB;
  116552. private _loadVersionFromDBAsync;
  116553. private _saveVersionIntoDBAsync;
  116554. /**
  116555. * Loads a file from database
  116556. * @param url defines the URL to load from
  116557. * @param sceneLoaded defines a callback to call on success
  116558. * @param progressCallBack defines a callback to call when progress changed
  116559. * @param errorCallback defines a callback to call on error
  116560. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  116561. */
  116562. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  116563. private _loadFileAsync;
  116564. private _saveFileAsync;
  116565. /**
  116566. * Validates if xhr data is correct
  116567. * @param xhr defines the request to validate
  116568. * @param dataType defines the expected data type
  116569. * @returns true if data is correct
  116570. */
  116571. private static _ValidateXHRData;
  116572. }
  116573. }
  116574. declare module BABYLON {
  116575. /** @hidden */
  116576. export var gpuUpdateParticlesPixelShader: {
  116577. name: string;
  116578. shader: string;
  116579. };
  116580. }
  116581. declare module BABYLON {
  116582. /** @hidden */
  116583. export var gpuUpdateParticlesVertexShader: {
  116584. name: string;
  116585. shader: string;
  116586. };
  116587. }
  116588. declare module BABYLON {
  116589. /** @hidden */
  116590. export var clipPlaneFragmentDeclaration2: {
  116591. name: string;
  116592. shader: string;
  116593. };
  116594. }
  116595. declare module BABYLON {
  116596. /** @hidden */
  116597. export var gpuRenderParticlesPixelShader: {
  116598. name: string;
  116599. shader: string;
  116600. };
  116601. }
  116602. declare module BABYLON {
  116603. /** @hidden */
  116604. export var clipPlaneVertexDeclaration2: {
  116605. name: string;
  116606. shader: string;
  116607. };
  116608. }
  116609. declare module BABYLON {
  116610. /** @hidden */
  116611. export var gpuRenderParticlesVertexShader: {
  116612. name: string;
  116613. shader: string;
  116614. };
  116615. }
  116616. declare module BABYLON {
  116617. /**
  116618. * This represents a GPU particle system in Babylon
  116619. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  116620. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  116621. */
  116622. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  116623. /**
  116624. * The layer mask we are rendering the particles through.
  116625. */
  116626. layerMask: number;
  116627. private _capacity;
  116628. private _activeCount;
  116629. private _currentActiveCount;
  116630. private _accumulatedCount;
  116631. private _renderEffect;
  116632. private _updateEffect;
  116633. private _buffer0;
  116634. private _buffer1;
  116635. private _spriteBuffer;
  116636. private _updateVAO;
  116637. private _renderVAO;
  116638. private _targetIndex;
  116639. private _sourceBuffer;
  116640. private _targetBuffer;
  116641. private _engine;
  116642. private _currentRenderId;
  116643. private _started;
  116644. private _stopped;
  116645. private _timeDelta;
  116646. private _randomTexture;
  116647. private _randomTexture2;
  116648. private _attributesStrideSize;
  116649. private _updateEffectOptions;
  116650. private _randomTextureSize;
  116651. private _actualFrame;
  116652. private readonly _rawTextureWidth;
  116653. /**
  116654. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  116655. */
  116656. static readonly IsSupported: boolean;
  116657. /**
  116658. * An event triggered when the system is disposed.
  116659. */
  116660. onDisposeObservable: Observable<GPUParticleSystem>;
  116661. /**
  116662. * Gets the maximum number of particles active at the same time.
  116663. * @returns The max number of active particles.
  116664. */
  116665. getCapacity(): number;
  116666. /**
  116667. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  116668. * to override the particles.
  116669. */
  116670. forceDepthWrite: boolean;
  116671. /**
  116672. * Gets or set the number of active particles
  116673. */
  116674. activeParticleCount: number;
  116675. private _preWarmDone;
  116676. /**
  116677. * Is this system ready to be used/rendered
  116678. * @return true if the system is ready
  116679. */
  116680. isReady(): boolean;
  116681. /**
  116682. * Gets if the system has been started. (Note: this will still be true after stop is called)
  116683. * @returns True if it has been started, otherwise false.
  116684. */
  116685. isStarted(): boolean;
  116686. /**
  116687. * Starts the particle system and begins to emit
  116688. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  116689. */
  116690. start(delay?: number): void;
  116691. /**
  116692. * Stops the particle system.
  116693. */
  116694. stop(): void;
  116695. /**
  116696. * Remove all active particles
  116697. */
  116698. reset(): void;
  116699. /**
  116700. * Returns the string "GPUParticleSystem"
  116701. * @returns a string containing the class name
  116702. */
  116703. getClassName(): string;
  116704. private _colorGradientsTexture;
  116705. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  116706. /**
  116707. * Adds a new color gradient
  116708. * @param gradient defines the gradient to use (between 0 and 1)
  116709. * @param color1 defines the color to affect to the specified gradient
  116710. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  116711. * @returns the current particle system
  116712. */
  116713. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  116714. /**
  116715. * Remove a specific color gradient
  116716. * @param gradient defines the gradient to remove
  116717. * @returns the current particle system
  116718. */
  116719. removeColorGradient(gradient: number): GPUParticleSystem;
  116720. private _angularSpeedGradientsTexture;
  116721. private _sizeGradientsTexture;
  116722. private _velocityGradientsTexture;
  116723. private _limitVelocityGradientsTexture;
  116724. private _dragGradientsTexture;
  116725. private _addFactorGradient;
  116726. /**
  116727. * Adds a new size gradient
  116728. * @param gradient defines the gradient to use (between 0 and 1)
  116729. * @param factor defines the size factor to affect to the specified gradient
  116730. * @returns the current particle system
  116731. */
  116732. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  116733. /**
  116734. * Remove a specific size gradient
  116735. * @param gradient defines the gradient to remove
  116736. * @returns the current particle system
  116737. */
  116738. removeSizeGradient(gradient: number): GPUParticleSystem;
  116739. /**
  116740. * Adds a new angular speed gradient
  116741. * @param gradient defines the gradient to use (between 0 and 1)
  116742. * @param factor defines the angular speed to affect to the specified gradient
  116743. * @returns the current particle system
  116744. */
  116745. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  116746. /**
  116747. * Remove a specific angular speed gradient
  116748. * @param gradient defines the gradient to remove
  116749. * @returns the current particle system
  116750. */
  116751. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  116752. /**
  116753. * Adds a new velocity gradient
  116754. * @param gradient defines the gradient to use (between 0 and 1)
  116755. * @param factor defines the velocity to affect to the specified gradient
  116756. * @returns the current particle system
  116757. */
  116758. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  116759. /**
  116760. * Remove a specific velocity gradient
  116761. * @param gradient defines the gradient to remove
  116762. * @returns the current particle system
  116763. */
  116764. removeVelocityGradient(gradient: number): GPUParticleSystem;
  116765. /**
  116766. * Adds a new limit velocity gradient
  116767. * @param gradient defines the gradient to use (between 0 and 1)
  116768. * @param factor defines the limit velocity value to affect to the specified gradient
  116769. * @returns the current particle system
  116770. */
  116771. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  116772. /**
  116773. * Remove a specific limit velocity gradient
  116774. * @param gradient defines the gradient to remove
  116775. * @returns the current particle system
  116776. */
  116777. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  116778. /**
  116779. * Adds a new drag gradient
  116780. * @param gradient defines the gradient to use (between 0 and 1)
  116781. * @param factor defines the drag value to affect to the specified gradient
  116782. * @returns the current particle system
  116783. */
  116784. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  116785. /**
  116786. * Remove a specific drag gradient
  116787. * @param gradient defines the gradient to remove
  116788. * @returns the current particle system
  116789. */
  116790. removeDragGradient(gradient: number): GPUParticleSystem;
  116791. /**
  116792. * Not supported by GPUParticleSystem
  116793. * @param gradient defines the gradient to use (between 0 and 1)
  116794. * @param factor defines the emit rate value to affect to the specified gradient
  116795. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  116796. * @returns the current particle system
  116797. */
  116798. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  116799. /**
  116800. * Not supported by GPUParticleSystem
  116801. * @param gradient defines the gradient to remove
  116802. * @returns the current particle system
  116803. */
  116804. removeEmitRateGradient(gradient: number): IParticleSystem;
  116805. /**
  116806. * Not supported by GPUParticleSystem
  116807. * @param gradient defines the gradient to use (between 0 and 1)
  116808. * @param factor defines the start size value to affect to the specified gradient
  116809. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  116810. * @returns the current particle system
  116811. */
  116812. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  116813. /**
  116814. * Not supported by GPUParticleSystem
  116815. * @param gradient defines the gradient to remove
  116816. * @returns the current particle system
  116817. */
  116818. removeStartSizeGradient(gradient: number): IParticleSystem;
  116819. /**
  116820. * Not supported by GPUParticleSystem
  116821. * @param gradient defines the gradient to use (between 0 and 1)
  116822. * @param min defines the color remap minimal range
  116823. * @param max defines the color remap maximal range
  116824. * @returns the current particle system
  116825. */
  116826. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  116827. /**
  116828. * Not supported by GPUParticleSystem
  116829. * @param gradient defines the gradient to remove
  116830. * @returns the current particle system
  116831. */
  116832. removeColorRemapGradient(): IParticleSystem;
  116833. /**
  116834. * Not supported by GPUParticleSystem
  116835. * @param gradient defines the gradient to use (between 0 and 1)
  116836. * @param min defines the alpha remap minimal range
  116837. * @param max defines the alpha remap maximal range
  116838. * @returns the current particle system
  116839. */
  116840. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  116841. /**
  116842. * Not supported by GPUParticleSystem
  116843. * @param gradient defines the gradient to remove
  116844. * @returns the current particle system
  116845. */
  116846. removeAlphaRemapGradient(): IParticleSystem;
  116847. /**
  116848. * Not supported by GPUParticleSystem
  116849. * @param gradient defines the gradient to use (between 0 and 1)
  116850. * @param color defines the color to affect to the specified gradient
  116851. * @returns the current particle system
  116852. */
  116853. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  116854. /**
  116855. * Not supported by GPUParticleSystem
  116856. * @param gradient defines the gradient to remove
  116857. * @returns the current particle system
  116858. */
  116859. removeRampGradient(): IParticleSystem;
  116860. /**
  116861. * Not supported by GPUParticleSystem
  116862. * @returns the list of ramp gradients
  116863. */
  116864. getRampGradients(): Nullable<Array<Color3Gradient>>;
  116865. /**
  116866. * Not supported by GPUParticleSystem
  116867. * Gets or sets a boolean indicating that ramp gradients must be used
  116868. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  116869. */
  116870. useRampGradients: boolean;
  116871. /**
  116872. * Not supported by GPUParticleSystem
  116873. * @param gradient defines the gradient to use (between 0 and 1)
  116874. * @param factor defines the life time factor to affect to the specified gradient
  116875. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  116876. * @returns the current particle system
  116877. */
  116878. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  116879. /**
  116880. * Not supported by GPUParticleSystem
  116881. * @param gradient defines the gradient to remove
  116882. * @returns the current particle system
  116883. */
  116884. removeLifeTimeGradient(gradient: number): IParticleSystem;
  116885. /**
  116886. * Instantiates a GPU particle system.
  116887. * 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.
  116888. * @param name The name of the particle system
  116889. * @param options The options used to create the system
  116890. * @param scene The scene the particle system belongs to
  116891. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  116892. */
  116893. constructor(name: string, options: Partial<{
  116894. capacity: number;
  116895. randomTextureSize: number;
  116896. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  116897. protected _reset(): void;
  116898. private _createUpdateVAO;
  116899. private _createRenderVAO;
  116900. private _initialize;
  116901. /** @hidden */
  116902. _recreateUpdateEffect(): void;
  116903. /** @hidden */
  116904. _recreateRenderEffect(): void;
  116905. /**
  116906. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  116907. * @param preWarm defines if we are in the pre-warmimg phase
  116908. */
  116909. animate(preWarm?: boolean): void;
  116910. private _createFactorGradientTexture;
  116911. private _createSizeGradientTexture;
  116912. private _createAngularSpeedGradientTexture;
  116913. private _createVelocityGradientTexture;
  116914. private _createLimitVelocityGradientTexture;
  116915. private _createDragGradientTexture;
  116916. private _createColorGradientTexture;
  116917. /**
  116918. * Renders the particle system in its current state
  116919. * @param preWarm defines if the system should only update the particles but not render them
  116920. * @returns the current number of particles
  116921. */
  116922. render(preWarm?: boolean): number;
  116923. /**
  116924. * Rebuilds the particle system
  116925. */
  116926. rebuild(): void;
  116927. private _releaseBuffers;
  116928. private _releaseVAOs;
  116929. /**
  116930. * Disposes the particle system and free the associated resources
  116931. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  116932. */
  116933. dispose(disposeTexture?: boolean): void;
  116934. /**
  116935. * Clones the particle system.
  116936. * @param name The name of the cloned object
  116937. * @param newEmitter The new emitter to use
  116938. * @returns the cloned particle system
  116939. */
  116940. clone(name: string, newEmitter: any): GPUParticleSystem;
  116941. /**
  116942. * Serializes the particle system to a JSON object.
  116943. * @returns the JSON object
  116944. */
  116945. serialize(): any;
  116946. /**
  116947. * Parses a JSON object to create a GPU particle system.
  116948. * @param parsedParticleSystem The JSON object to parse
  116949. * @param scene The scene to create the particle system in
  116950. * @param rootUrl The root url to use to load external dependencies like texture
  116951. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  116952. * @returns the parsed GPU particle system
  116953. */
  116954. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  116955. }
  116956. }
  116957. declare module BABYLON {
  116958. /**
  116959. * Represents a set of particle systems working together to create a specific effect
  116960. */
  116961. export class ParticleSystemSet implements IDisposable {
  116962. private _emitterCreationOptions;
  116963. private _emitterNode;
  116964. /**
  116965. * Gets the particle system list
  116966. */
  116967. systems: IParticleSystem[];
  116968. /**
  116969. * Gets the emitter node used with this set
  116970. */
  116971. readonly emitterNode: Nullable<TransformNode>;
  116972. /**
  116973. * Creates a new emitter mesh as a sphere
  116974. * @param options defines the options used to create the sphere
  116975. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  116976. * @param scene defines the hosting scene
  116977. */
  116978. setEmitterAsSphere(options: {
  116979. diameter: number;
  116980. segments: number;
  116981. color: Color3;
  116982. }, renderingGroupId: number, scene: Scene): void;
  116983. /**
  116984. * Starts all particle systems of the set
  116985. * @param emitter defines an optional mesh to use as emitter for the particle systems
  116986. */
  116987. start(emitter?: AbstractMesh): void;
  116988. /**
  116989. * Release all associated resources
  116990. */
  116991. dispose(): void;
  116992. /**
  116993. * Serialize the set into a JSON compatible object
  116994. * @returns a JSON compatible representation of the set
  116995. */
  116996. serialize(): any;
  116997. /**
  116998. * Parse a new ParticleSystemSet from a serialized source
  116999. * @param data defines a JSON compatible representation of the set
  117000. * @param scene defines the hosting scene
  117001. * @param gpu defines if we want GPU particles or CPU particles
  117002. * @returns a new ParticleSystemSet
  117003. */
  117004. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  117005. }
  117006. }
  117007. declare module BABYLON {
  117008. /**
  117009. * This class is made for on one-liner static method to help creating particle system set.
  117010. */
  117011. export class ParticleHelper {
  117012. /**
  117013. * Gets or sets base Assets URL
  117014. */
  117015. static BaseAssetsUrl: string;
  117016. /**
  117017. * Create a default particle system that you can tweak
  117018. * @param emitter defines the emitter to use
  117019. * @param capacity defines the system capacity (default is 500 particles)
  117020. * @param scene defines the hosting scene
  117021. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  117022. * @returns the new Particle system
  117023. */
  117024. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  117025. /**
  117026. * This is the main static method (one-liner) of this helper to create different particle systems
  117027. * @param type This string represents the type to the particle system to create
  117028. * @param scene The scene where the particle system should live
  117029. * @param gpu If the system will use gpu
  117030. * @returns the ParticleSystemSet created
  117031. */
  117032. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  117033. /**
  117034. * Static function used to export a particle system to a ParticleSystemSet variable.
  117035. * Please note that the emitter shape is not exported
  117036. * @param systems defines the particle systems to export
  117037. * @returns the created particle system set
  117038. */
  117039. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  117040. }
  117041. }
  117042. declare module BABYLON {
  117043. interface Engine {
  117044. /**
  117045. * Create an effect to use with particle systems.
  117046. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  117047. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  117048. * @param uniformsNames defines a list of attribute names
  117049. * @param samplers defines an array of string used to represent textures
  117050. * @param defines defines the string containing the defines to use to compile the shaders
  117051. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  117052. * @param onCompiled defines a function to call when the effect creation is successful
  117053. * @param onError defines a function to call when the effect creation has failed
  117054. * @returns the new Effect
  117055. */
  117056. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  117057. }
  117058. interface Mesh {
  117059. /**
  117060. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  117061. * @returns an array of IParticleSystem
  117062. */
  117063. getEmittedParticleSystems(): IParticleSystem[];
  117064. /**
  117065. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  117066. * @returns an array of IParticleSystem
  117067. */
  117068. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  117069. }
  117070. /**
  117071. * @hidden
  117072. */
  117073. export var _IDoNeedToBeInTheBuild: number;
  117074. }
  117075. declare module BABYLON {
  117076. interface Scene {
  117077. /** @hidden (Backing field) */
  117078. _physicsEngine: Nullable<IPhysicsEngine>;
  117079. /**
  117080. * Gets the current physics engine
  117081. * @returns a IPhysicsEngine or null if none attached
  117082. */
  117083. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  117084. /**
  117085. * Enables physics to the current scene
  117086. * @param gravity defines the scene's gravity for the physics engine
  117087. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  117088. * @return a boolean indicating if the physics engine was initialized
  117089. */
  117090. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  117091. /**
  117092. * Disables and disposes the physics engine associated with the scene
  117093. */
  117094. disablePhysicsEngine(): void;
  117095. /**
  117096. * Gets a boolean indicating if there is an active physics engine
  117097. * @returns a boolean indicating if there is an active physics engine
  117098. */
  117099. isPhysicsEnabled(): boolean;
  117100. /**
  117101. * Deletes a physics compound impostor
  117102. * @param compound defines the compound to delete
  117103. */
  117104. deleteCompoundImpostor(compound: any): void;
  117105. /**
  117106. * An event triggered when physic simulation is about to be run
  117107. */
  117108. onBeforePhysicsObservable: Observable<Scene>;
  117109. /**
  117110. * An event triggered when physic simulation has been done
  117111. */
  117112. onAfterPhysicsObservable: Observable<Scene>;
  117113. }
  117114. interface AbstractMesh {
  117115. /** @hidden */
  117116. _physicsImpostor: Nullable<PhysicsImpostor>;
  117117. /**
  117118. * Gets or sets impostor used for physic simulation
  117119. * @see http://doc.babylonjs.com/features/physics_engine
  117120. */
  117121. physicsImpostor: Nullable<PhysicsImpostor>;
  117122. /**
  117123. * Gets the current physics impostor
  117124. * @see http://doc.babylonjs.com/features/physics_engine
  117125. * @returns a physics impostor or null
  117126. */
  117127. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  117128. /** Apply a physic impulse to the mesh
  117129. * @param force defines the force to apply
  117130. * @param contactPoint defines where to apply the force
  117131. * @returns the current mesh
  117132. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  117133. */
  117134. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  117135. /**
  117136. * Creates a physic joint between two meshes
  117137. * @param otherMesh defines the other mesh to use
  117138. * @param pivot1 defines the pivot to use on this mesh
  117139. * @param pivot2 defines the pivot to use on the other mesh
  117140. * @param options defines additional options (can be plugin dependent)
  117141. * @returns the current mesh
  117142. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  117143. */
  117144. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  117145. /** @hidden */
  117146. _disposePhysicsObserver: Nullable<Observer<Node>>;
  117147. }
  117148. /**
  117149. * Defines the physics engine scene component responsible to manage a physics engine
  117150. */
  117151. export class PhysicsEngineSceneComponent implements ISceneComponent {
  117152. /**
  117153. * The component name helpful to identify the component in the list of scene components.
  117154. */
  117155. readonly name: string;
  117156. /**
  117157. * The scene the component belongs to.
  117158. */
  117159. scene: Scene;
  117160. /**
  117161. * Creates a new instance of the component for the given scene
  117162. * @param scene Defines the scene to register the component in
  117163. */
  117164. constructor(scene: Scene);
  117165. /**
  117166. * Registers the component in a given scene
  117167. */
  117168. register(): void;
  117169. /**
  117170. * Rebuilds the elements related to this component in case of
  117171. * context lost for instance.
  117172. */
  117173. rebuild(): void;
  117174. /**
  117175. * Disposes the component and the associated ressources
  117176. */
  117177. dispose(): void;
  117178. }
  117179. }
  117180. declare module BABYLON {
  117181. /**
  117182. * A helper for physics simulations
  117183. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117184. */
  117185. export class PhysicsHelper {
  117186. private _scene;
  117187. private _physicsEngine;
  117188. /**
  117189. * Initializes the Physics helper
  117190. * @param scene Babylon.js scene
  117191. */
  117192. constructor(scene: Scene);
  117193. /**
  117194. * Applies a radial explosion impulse
  117195. * @param origin the origin of the explosion
  117196. * @param radiusOrEventOptions the radius or the options of radial explosion
  117197. * @param strength the explosion strength
  117198. * @param falloff possible options: Constant & Linear. Defaults to Constant
  117199. * @returns A physics radial explosion event, or null
  117200. */
  117201. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  117202. /**
  117203. * Applies a radial explosion force
  117204. * @param origin the origin of the explosion
  117205. * @param radiusOrEventOptions the radius or the options of radial explosion
  117206. * @param strength the explosion strength
  117207. * @param falloff possible options: Constant & Linear. Defaults to Constant
  117208. * @returns A physics radial explosion event, or null
  117209. */
  117210. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  117211. /**
  117212. * Creates a gravitational field
  117213. * @param origin the origin of the explosion
  117214. * @param radiusOrEventOptions the radius or the options of radial explosion
  117215. * @param strength the explosion strength
  117216. * @param falloff possible options: Constant & Linear. Defaults to Constant
  117217. * @returns A physics gravitational field event, or null
  117218. */
  117219. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  117220. /**
  117221. * Creates a physics updraft event
  117222. * @param origin the origin of the updraft
  117223. * @param radiusOrEventOptions the radius or the options of the updraft
  117224. * @param strength the strength of the updraft
  117225. * @param height the height of the updraft
  117226. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  117227. * @returns A physics updraft event, or null
  117228. */
  117229. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  117230. /**
  117231. * Creates a physics vortex event
  117232. * @param origin the of the vortex
  117233. * @param radiusOrEventOptions the radius or the options of the vortex
  117234. * @param strength the strength of the vortex
  117235. * @param height the height of the vortex
  117236. * @returns a Physics vortex event, or null
  117237. * A physics vortex event or null
  117238. */
  117239. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  117240. }
  117241. /**
  117242. * Represents a physics radial explosion event
  117243. */
  117244. class PhysicsRadialExplosionEvent {
  117245. private _scene;
  117246. private _options;
  117247. private _sphere;
  117248. private _dataFetched;
  117249. /**
  117250. * Initializes a radial explosioin event
  117251. * @param _scene BabylonJS scene
  117252. * @param _options The options for the vortex event
  117253. */
  117254. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  117255. /**
  117256. * Returns the data related to the radial explosion event (sphere).
  117257. * @returns The radial explosion event data
  117258. */
  117259. getData(): PhysicsRadialExplosionEventData;
  117260. /**
  117261. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  117262. * @param impostor A physics imposter
  117263. * @param origin the origin of the explosion
  117264. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  117265. */
  117266. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  117267. /**
  117268. * Triggers affecterd impostors callbacks
  117269. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  117270. */
  117271. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  117272. /**
  117273. * Disposes the sphere.
  117274. * @param force Specifies if the sphere should be disposed by force
  117275. */
  117276. dispose(force?: boolean): void;
  117277. /*** Helpers ***/
  117278. private _prepareSphere;
  117279. private _intersectsWithSphere;
  117280. }
  117281. /**
  117282. * Represents a gravitational field event
  117283. */
  117284. class PhysicsGravitationalFieldEvent {
  117285. private _physicsHelper;
  117286. private _scene;
  117287. private _origin;
  117288. private _options;
  117289. private _tickCallback;
  117290. private _sphere;
  117291. private _dataFetched;
  117292. /**
  117293. * Initializes the physics gravitational field event
  117294. * @param _physicsHelper A physics helper
  117295. * @param _scene BabylonJS scene
  117296. * @param _origin The origin position of the gravitational field event
  117297. * @param _options The options for the vortex event
  117298. */
  117299. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  117300. /**
  117301. * Returns the data related to the gravitational field event (sphere).
  117302. * @returns A gravitational field event
  117303. */
  117304. getData(): PhysicsGravitationalFieldEventData;
  117305. /**
  117306. * Enables the gravitational field.
  117307. */
  117308. enable(): void;
  117309. /**
  117310. * Disables the gravitational field.
  117311. */
  117312. disable(): void;
  117313. /**
  117314. * Disposes the sphere.
  117315. * @param force The force to dispose from the gravitational field event
  117316. */
  117317. dispose(force?: boolean): void;
  117318. private _tick;
  117319. }
  117320. /**
  117321. * Represents a physics updraft event
  117322. */
  117323. class PhysicsUpdraftEvent {
  117324. private _scene;
  117325. private _origin;
  117326. private _options;
  117327. private _physicsEngine;
  117328. private _originTop;
  117329. private _originDirection;
  117330. private _tickCallback;
  117331. private _cylinder;
  117332. private _cylinderPosition;
  117333. private _dataFetched;
  117334. /**
  117335. * Initializes the physics updraft event
  117336. * @param _scene BabylonJS scene
  117337. * @param _origin The origin position of the updraft
  117338. * @param _options The options for the updraft event
  117339. */
  117340. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  117341. /**
  117342. * Returns the data related to the updraft event (cylinder).
  117343. * @returns A physics updraft event
  117344. */
  117345. getData(): PhysicsUpdraftEventData;
  117346. /**
  117347. * Enables the updraft.
  117348. */
  117349. enable(): void;
  117350. /**
  117351. * Disables the updraft.
  117352. */
  117353. disable(): void;
  117354. /**
  117355. * Disposes the cylinder.
  117356. * @param force Specifies if the updraft should be disposed by force
  117357. */
  117358. dispose(force?: boolean): void;
  117359. private getImpostorHitData;
  117360. private _tick;
  117361. /*** Helpers ***/
  117362. private _prepareCylinder;
  117363. private _intersectsWithCylinder;
  117364. }
  117365. /**
  117366. * Represents a physics vortex event
  117367. */
  117368. class PhysicsVortexEvent {
  117369. private _scene;
  117370. private _origin;
  117371. private _options;
  117372. private _physicsEngine;
  117373. private _originTop;
  117374. private _tickCallback;
  117375. private _cylinder;
  117376. private _cylinderPosition;
  117377. private _dataFetched;
  117378. /**
  117379. * Initializes the physics vortex event
  117380. * @param _scene The BabylonJS scene
  117381. * @param _origin The origin position of the vortex
  117382. * @param _options The options for the vortex event
  117383. */
  117384. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  117385. /**
  117386. * Returns the data related to the vortex event (cylinder).
  117387. * @returns The physics vortex event data
  117388. */
  117389. getData(): PhysicsVortexEventData;
  117390. /**
  117391. * Enables the vortex.
  117392. */
  117393. enable(): void;
  117394. /**
  117395. * Disables the cortex.
  117396. */
  117397. disable(): void;
  117398. /**
  117399. * Disposes the sphere.
  117400. * @param force
  117401. */
  117402. dispose(force?: boolean): void;
  117403. private getImpostorHitData;
  117404. private _tick;
  117405. /*** Helpers ***/
  117406. private _prepareCylinder;
  117407. private _intersectsWithCylinder;
  117408. }
  117409. /**
  117410. * Options fot the radial explosion event
  117411. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117412. */
  117413. export class PhysicsRadialExplosionEventOptions {
  117414. /**
  117415. * The radius of the sphere for the radial explosion.
  117416. */
  117417. radius: number;
  117418. /**
  117419. * The strenth of the explosion.
  117420. */
  117421. strength: number;
  117422. /**
  117423. * The strenght of the force in correspondence to the distance of the affected object
  117424. */
  117425. falloff: PhysicsRadialImpulseFalloff;
  117426. /**
  117427. * Sphere options for the radial explosion.
  117428. */
  117429. sphere: {
  117430. segments: number;
  117431. diameter: number;
  117432. };
  117433. /**
  117434. * Sphere options for the radial explosion.
  117435. */
  117436. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  117437. }
  117438. /**
  117439. * Options fot the updraft event
  117440. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117441. */
  117442. export class PhysicsUpdraftEventOptions {
  117443. /**
  117444. * The radius of the cylinder for the vortex
  117445. */
  117446. radius: number;
  117447. /**
  117448. * The strenth of the updraft.
  117449. */
  117450. strength: number;
  117451. /**
  117452. * The height of the cylinder for the updraft.
  117453. */
  117454. height: number;
  117455. /**
  117456. * The mode for the the updraft.
  117457. */
  117458. updraftMode: PhysicsUpdraftMode;
  117459. }
  117460. /**
  117461. * Options fot the vortex event
  117462. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117463. */
  117464. export class PhysicsVortexEventOptions {
  117465. /**
  117466. * The radius of the cylinder for the vortex
  117467. */
  117468. radius: number;
  117469. /**
  117470. * The strenth of the vortex.
  117471. */
  117472. strength: number;
  117473. /**
  117474. * The height of the cylinder for the vortex.
  117475. */
  117476. height: number;
  117477. /**
  117478. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  117479. */
  117480. centripetalForceThreshold: number;
  117481. /**
  117482. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  117483. */
  117484. centripetalForceMultiplier: number;
  117485. /**
  117486. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  117487. */
  117488. centrifugalForceMultiplier: number;
  117489. /**
  117490. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  117491. */
  117492. updraftForceMultiplier: number;
  117493. }
  117494. /**
  117495. * The strenght of the force in correspondence to the distance of the affected object
  117496. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117497. */
  117498. export enum PhysicsRadialImpulseFalloff {
  117499. /** Defines that impulse is constant in strength across it's whole radius */
  117500. Constant = 0,
  117501. /** Defines that impulse gets weaker if it's further from the origin */
  117502. Linear = 1
  117503. }
  117504. /**
  117505. * The strength of the force in correspondence to the distance of the affected object
  117506. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117507. */
  117508. export enum PhysicsUpdraftMode {
  117509. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  117510. Center = 0,
  117511. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  117512. Perpendicular = 1
  117513. }
  117514. /**
  117515. * Interface for a physics hit data
  117516. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117517. */
  117518. export interface PhysicsHitData {
  117519. /**
  117520. * The force applied at the contact point
  117521. */
  117522. force: Vector3;
  117523. /**
  117524. * The contact point
  117525. */
  117526. contactPoint: Vector3;
  117527. /**
  117528. * The distance from the origin to the contact point
  117529. */
  117530. distanceFromOrigin: number;
  117531. }
  117532. /**
  117533. * Interface for radial explosion event data
  117534. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117535. */
  117536. export interface PhysicsRadialExplosionEventData {
  117537. /**
  117538. * A sphere used for the radial explosion event
  117539. */
  117540. sphere: Mesh;
  117541. }
  117542. /**
  117543. * Interface for gravitational field event data
  117544. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117545. */
  117546. export interface PhysicsGravitationalFieldEventData {
  117547. /**
  117548. * A sphere mesh used for the gravitational field event
  117549. */
  117550. sphere: Mesh;
  117551. }
  117552. /**
  117553. * Interface for updraft event data
  117554. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117555. */
  117556. export interface PhysicsUpdraftEventData {
  117557. /**
  117558. * A cylinder used for the updraft event
  117559. */
  117560. cylinder: Mesh;
  117561. }
  117562. /**
  117563. * Interface for vortex event data
  117564. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117565. */
  117566. export interface PhysicsVortexEventData {
  117567. /**
  117568. * A cylinder used for the vortex event
  117569. */
  117570. cylinder: Mesh;
  117571. }
  117572. /**
  117573. * Interface for an affected physics impostor
  117574. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  117575. */
  117576. export interface PhysicsAffectedImpostorWithData {
  117577. /**
  117578. * The impostor affected by the effect
  117579. */
  117580. impostor: PhysicsImpostor;
  117581. /**
  117582. * The data about the hit/horce from the explosion
  117583. */
  117584. hitData: PhysicsHitData;
  117585. }
  117586. }
  117587. declare module BABYLON {
  117588. /** @hidden */
  117589. export var blackAndWhitePixelShader: {
  117590. name: string;
  117591. shader: string;
  117592. };
  117593. }
  117594. declare module BABYLON {
  117595. /**
  117596. * Post process used to render in black and white
  117597. */
  117598. export class BlackAndWhitePostProcess extends PostProcess {
  117599. /**
  117600. * Linear about to convert he result to black and white (default: 1)
  117601. */
  117602. degree: number;
  117603. /**
  117604. * Creates a black and white post process
  117605. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  117606. * @param name The name of the effect.
  117607. * @param options The required width/height ratio to downsize to before computing the render pass.
  117608. * @param camera The camera to apply the render pass to.
  117609. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117610. * @param engine The engine which the post process will be applied. (default: current engine)
  117611. * @param reusable If the post process can be reused on the same frame. (default: false)
  117612. */
  117613. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  117614. }
  117615. }
  117616. declare module BABYLON {
  117617. /**
  117618. * This represents a set of one or more post processes in Babylon.
  117619. * A post process can be used to apply a shader to a texture after it is rendered.
  117620. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  117621. */
  117622. export class PostProcessRenderEffect {
  117623. private _postProcesses;
  117624. private _getPostProcesses;
  117625. private _singleInstance;
  117626. private _cameras;
  117627. private _indicesForCamera;
  117628. /**
  117629. * Name of the effect
  117630. * @hidden
  117631. */
  117632. _name: string;
  117633. /**
  117634. * Instantiates a post process render effect.
  117635. * A post process can be used to apply a shader to a texture after it is rendered.
  117636. * @param engine The engine the effect is tied to
  117637. * @param name The name of the effect
  117638. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  117639. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  117640. */
  117641. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  117642. /**
  117643. * Checks if all the post processes in the effect are supported.
  117644. */
  117645. readonly isSupported: boolean;
  117646. /**
  117647. * Updates the current state of the effect
  117648. * @hidden
  117649. */
  117650. _update(): void;
  117651. /**
  117652. * Attaches the effect on cameras
  117653. * @param cameras The camera to attach to.
  117654. * @hidden
  117655. */
  117656. _attachCameras(cameras: Camera): void;
  117657. /**
  117658. * Attaches the effect on cameras
  117659. * @param cameras The camera to attach to.
  117660. * @hidden
  117661. */
  117662. _attachCameras(cameras: Camera[]): void;
  117663. /**
  117664. * Detaches the effect on cameras
  117665. * @param cameras The camera to detatch from.
  117666. * @hidden
  117667. */
  117668. _detachCameras(cameras: Camera): void;
  117669. /**
  117670. * Detatches the effect on cameras
  117671. * @param cameras The camera to detatch from.
  117672. * @hidden
  117673. */
  117674. _detachCameras(cameras: Camera[]): void;
  117675. /**
  117676. * Enables the effect on given cameras
  117677. * @param cameras The camera to enable.
  117678. * @hidden
  117679. */
  117680. _enable(cameras: Camera): void;
  117681. /**
  117682. * Enables the effect on given cameras
  117683. * @param cameras The camera to enable.
  117684. * @hidden
  117685. */
  117686. _enable(cameras: Nullable<Camera[]>): void;
  117687. /**
  117688. * Disables the effect on the given cameras
  117689. * @param cameras The camera to disable.
  117690. * @hidden
  117691. */
  117692. _disable(cameras: Camera): void;
  117693. /**
  117694. * Disables the effect on the given cameras
  117695. * @param cameras The camera to disable.
  117696. * @hidden
  117697. */
  117698. _disable(cameras: Nullable<Camera[]>): void;
  117699. /**
  117700. * Gets a list of the post processes contained in the effect.
  117701. * @param camera The camera to get the post processes on.
  117702. * @returns The list of the post processes in the effect.
  117703. */
  117704. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  117705. }
  117706. }
  117707. declare module BABYLON {
  117708. /** @hidden */
  117709. export var extractHighlightsPixelShader: {
  117710. name: string;
  117711. shader: string;
  117712. };
  117713. }
  117714. declare module BABYLON {
  117715. /**
  117716. * 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.
  117717. */
  117718. export class ExtractHighlightsPostProcess extends PostProcess {
  117719. /**
  117720. * The luminance threshold, pixels below this value will be set to black.
  117721. */
  117722. threshold: number;
  117723. /** @hidden */
  117724. _exposure: number;
  117725. /**
  117726. * Post process which has the input texture to be used when performing highlight extraction
  117727. * @hidden
  117728. */
  117729. _inputPostProcess: Nullable<PostProcess>;
  117730. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117731. }
  117732. }
  117733. declare module BABYLON {
  117734. /** @hidden */
  117735. export var bloomMergePixelShader: {
  117736. name: string;
  117737. shader: string;
  117738. };
  117739. }
  117740. declare module BABYLON {
  117741. /**
  117742. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  117743. */
  117744. export class BloomMergePostProcess extends PostProcess {
  117745. /** Weight of the bloom to be added to the original input. */
  117746. weight: number;
  117747. /**
  117748. * Creates a new instance of @see BloomMergePostProcess
  117749. * @param name The name of the effect.
  117750. * @param originalFromInput Post process which's input will be used for the merge.
  117751. * @param blurred Blurred highlights post process which's output will be used.
  117752. * @param weight Weight of the bloom to be added to the original input.
  117753. * @param options The required width/height ratio to downsize to before computing the render pass.
  117754. * @param camera The camera to apply the render pass to.
  117755. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117756. * @param engine The engine which the post process will be applied. (default: current engine)
  117757. * @param reusable If the post process can be reused on the same frame. (default: false)
  117758. * @param textureType Type of textures used when performing the post process. (default: 0)
  117759. * @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)
  117760. */
  117761. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  117762. /** Weight of the bloom to be added to the original input. */
  117763. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117764. }
  117765. }
  117766. declare module BABYLON {
  117767. /**
  117768. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  117769. */
  117770. export class BloomEffect extends PostProcessRenderEffect {
  117771. private bloomScale;
  117772. /**
  117773. * @hidden Internal
  117774. */
  117775. _effects: Array<PostProcess>;
  117776. /**
  117777. * @hidden Internal
  117778. */
  117779. _downscale: ExtractHighlightsPostProcess;
  117780. private _blurX;
  117781. private _blurY;
  117782. private _merge;
  117783. /**
  117784. * The luminance threshold to find bright areas of the image to bloom.
  117785. */
  117786. threshold: number;
  117787. /**
  117788. * The strength of the bloom.
  117789. */
  117790. weight: number;
  117791. /**
  117792. * Specifies the size of the bloom blur kernel, relative to the final output size
  117793. */
  117794. kernel: number;
  117795. /**
  117796. * Creates a new instance of @see BloomEffect
  117797. * @param scene The scene the effect belongs to.
  117798. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  117799. * @param bloomKernel The size of the kernel to be used when applying the blur.
  117800. * @param bloomWeight The the strength of bloom.
  117801. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  117802. * @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)
  117803. */
  117804. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  117805. /**
  117806. * Disposes each of the internal effects for a given camera.
  117807. * @param camera The camera to dispose the effect on.
  117808. */
  117809. disposeEffects(camera: Camera): void;
  117810. /**
  117811. * @hidden Internal
  117812. */
  117813. _updateEffects(): void;
  117814. /**
  117815. * Internal
  117816. * @returns if all the contained post processes are ready.
  117817. * @hidden
  117818. */
  117819. _isReady(): boolean;
  117820. }
  117821. }
  117822. declare module BABYLON {
  117823. /** @hidden */
  117824. export var chromaticAberrationPixelShader: {
  117825. name: string;
  117826. shader: string;
  117827. };
  117828. }
  117829. declare module BABYLON {
  117830. /**
  117831. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  117832. */
  117833. export class ChromaticAberrationPostProcess extends PostProcess {
  117834. /**
  117835. * The amount of seperation of rgb channels (default: 30)
  117836. */
  117837. aberrationAmount: number;
  117838. /**
  117839. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  117840. */
  117841. radialIntensity: number;
  117842. /**
  117843. * 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))
  117844. */
  117845. direction: Vector2;
  117846. /**
  117847. * 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))
  117848. */
  117849. centerPosition: Vector2;
  117850. /**
  117851. * Creates a new instance ChromaticAberrationPostProcess
  117852. * @param name The name of the effect.
  117853. * @param screenWidth The width of the screen to apply the effect on.
  117854. * @param screenHeight The height of the screen to apply the effect on.
  117855. * @param options The required width/height ratio to downsize to before computing the render pass.
  117856. * @param camera The camera to apply the render pass to.
  117857. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117858. * @param engine The engine which the post process will be applied. (default: current engine)
  117859. * @param reusable If the post process can be reused on the same frame. (default: false)
  117860. * @param textureType Type of textures used when performing the post process. (default: 0)
  117861. * @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)
  117862. */
  117863. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117864. }
  117865. }
  117866. declare module BABYLON {
  117867. /** @hidden */
  117868. export var circleOfConfusionPixelShader: {
  117869. name: string;
  117870. shader: string;
  117871. };
  117872. }
  117873. declare module BABYLON {
  117874. /**
  117875. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  117876. */
  117877. export class CircleOfConfusionPostProcess extends PostProcess {
  117878. /**
  117879. * 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.
  117880. */
  117881. lensSize: number;
  117882. /**
  117883. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  117884. */
  117885. fStop: number;
  117886. /**
  117887. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  117888. */
  117889. focusDistance: number;
  117890. /**
  117891. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  117892. */
  117893. focalLength: number;
  117894. private _depthTexture;
  117895. /**
  117896. * Creates a new instance CircleOfConfusionPostProcess
  117897. * @param name The name of the effect.
  117898. * @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.
  117899. * @param options The required width/height ratio to downsize to before computing the render pass.
  117900. * @param camera The camera to apply the render pass to.
  117901. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117902. * @param engine The engine which the post process will be applied. (default: current engine)
  117903. * @param reusable If the post process can be reused on the same frame. (default: false)
  117904. * @param textureType Type of textures used when performing the post process. (default: 0)
  117905. * @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)
  117906. */
  117907. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117908. /**
  117909. * 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.
  117910. */
  117911. depthTexture: RenderTargetTexture;
  117912. }
  117913. }
  117914. declare module BABYLON {
  117915. /** @hidden */
  117916. export var colorCorrectionPixelShader: {
  117917. name: string;
  117918. shader: string;
  117919. };
  117920. }
  117921. declare module BABYLON {
  117922. /**
  117923. *
  117924. * This post-process allows the modification of rendered colors by using
  117925. * a 'look-up table' (LUT). This effect is also called Color Grading.
  117926. *
  117927. * The object needs to be provided an url to a texture containing the color
  117928. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  117929. * Use an image editing software to tweak the LUT to match your needs.
  117930. *
  117931. * For an example of a color LUT, see here:
  117932. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  117933. * For explanations on color grading, see here:
  117934. * @see http://udn.epicgames.com/Three/ColorGrading.html
  117935. *
  117936. */
  117937. export class ColorCorrectionPostProcess extends PostProcess {
  117938. private _colorTableTexture;
  117939. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  117940. }
  117941. }
  117942. declare module BABYLON {
  117943. /** @hidden */
  117944. export var convolutionPixelShader: {
  117945. name: string;
  117946. shader: string;
  117947. };
  117948. }
  117949. declare module BABYLON {
  117950. /**
  117951. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  117952. * input texture to perform effects such as edge detection or sharpening
  117953. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  117954. */
  117955. export class ConvolutionPostProcess extends PostProcess {
  117956. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  117957. kernel: number[];
  117958. /**
  117959. * Creates a new instance ConvolutionPostProcess
  117960. * @param name The name of the effect.
  117961. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  117962. * @param options The required width/height ratio to downsize to before computing the render pass.
  117963. * @param camera The camera to apply the render pass to.
  117964. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117965. * @param engine The engine which the post process will be applied. (default: current engine)
  117966. * @param reusable If the post process can be reused on the same frame. (default: false)
  117967. * @param textureType Type of textures used when performing the post process. (default: 0)
  117968. */
  117969. constructor(name: string,
  117970. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  117971. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  117972. /**
  117973. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117974. */
  117975. static EdgeDetect0Kernel: number[];
  117976. /**
  117977. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117978. */
  117979. static EdgeDetect1Kernel: number[];
  117980. /**
  117981. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117982. */
  117983. static EdgeDetect2Kernel: number[];
  117984. /**
  117985. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117986. */
  117987. static SharpenKernel: number[];
  117988. /**
  117989. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117990. */
  117991. static EmbossKernel: number[];
  117992. /**
  117993. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117994. */
  117995. static GaussianKernel: number[];
  117996. }
  117997. }
  117998. declare module BABYLON {
  117999. /**
  118000. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  118001. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  118002. * based on samples that have a large difference in distance than the center pixel.
  118003. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  118004. */
  118005. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  118006. direction: Vector2;
  118007. /**
  118008. * Creates a new instance CircleOfConfusionPostProcess
  118009. * @param name The name of the effect.
  118010. * @param scene The scene the effect belongs to.
  118011. * @param direction The direction the blur should be applied.
  118012. * @param kernel The size of the kernel used to blur.
  118013. * @param options The required width/height ratio to downsize to before computing the render pass.
  118014. * @param camera The camera to apply the render pass to.
  118015. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  118016. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  118017. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118018. * @param engine The engine which the post process will be applied. (default: current engine)
  118019. * @param reusable If the post process can be reused on the same frame. (default: false)
  118020. * @param textureType Type of textures used when performing the post process. (default: 0)
  118021. * @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)
  118022. */
  118023. 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);
  118024. }
  118025. }
  118026. declare module BABYLON {
  118027. /** @hidden */
  118028. export var depthOfFieldMergePixelShader: {
  118029. name: string;
  118030. shader: string;
  118031. };
  118032. }
  118033. declare module BABYLON {
  118034. /**
  118035. * Options to be set when merging outputs from the default pipeline.
  118036. */
  118037. export class DepthOfFieldMergePostProcessOptions {
  118038. /**
  118039. * The original image to merge on top of
  118040. */
  118041. originalFromInput: PostProcess;
  118042. /**
  118043. * Parameters to perform the merge of the depth of field effect
  118044. */
  118045. depthOfField?: {
  118046. circleOfConfusion: PostProcess;
  118047. blurSteps: Array<PostProcess>;
  118048. };
  118049. /**
  118050. * Parameters to perform the merge of bloom effect
  118051. */
  118052. bloom?: {
  118053. blurred: PostProcess;
  118054. weight: number;
  118055. };
  118056. }
  118057. /**
  118058. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  118059. */
  118060. export class DepthOfFieldMergePostProcess extends PostProcess {
  118061. private blurSteps;
  118062. /**
  118063. * Creates a new instance of DepthOfFieldMergePostProcess
  118064. * @param name The name of the effect.
  118065. * @param originalFromInput Post process which's input will be used for the merge.
  118066. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  118067. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  118068. * @param options The required width/height ratio to downsize to before computing the render pass.
  118069. * @param camera The camera to apply the render pass to.
  118070. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118071. * @param engine The engine which the post process will be applied. (default: current engine)
  118072. * @param reusable If the post process can be reused on the same frame. (default: false)
  118073. * @param textureType Type of textures used when performing the post process. (default: 0)
  118074. * @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)
  118075. */
  118076. 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);
  118077. /**
  118078. * Updates the effect with the current post process compile time values and recompiles the shader.
  118079. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  118080. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  118081. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  118082. * @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
  118083. * @param onCompiled Called when the shader has been compiled.
  118084. * @param onError Called if there is an error when compiling a shader.
  118085. */
  118086. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  118087. }
  118088. }
  118089. declare module BABYLON {
  118090. /**
  118091. * Specifies the level of max blur that should be applied when using the depth of field effect
  118092. */
  118093. export enum DepthOfFieldEffectBlurLevel {
  118094. /**
  118095. * Subtle blur
  118096. */
  118097. Low = 0,
  118098. /**
  118099. * Medium blur
  118100. */
  118101. Medium = 1,
  118102. /**
  118103. * Large blur
  118104. */
  118105. High = 2
  118106. }
  118107. /**
  118108. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  118109. */
  118110. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  118111. private _circleOfConfusion;
  118112. /**
  118113. * @hidden Internal, blurs from high to low
  118114. */
  118115. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  118116. private _depthOfFieldBlurY;
  118117. private _dofMerge;
  118118. /**
  118119. * @hidden Internal post processes in depth of field effect
  118120. */
  118121. _effects: Array<PostProcess>;
  118122. /**
  118123. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  118124. */
  118125. focalLength: number;
  118126. /**
  118127. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  118128. */
  118129. fStop: number;
  118130. /**
  118131. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  118132. */
  118133. focusDistance: number;
  118134. /**
  118135. * 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.
  118136. */
  118137. lensSize: number;
  118138. /**
  118139. * Creates a new instance DepthOfFieldEffect
  118140. * @param scene The scene the effect belongs to.
  118141. * @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.
  118142. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  118143. * @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)
  118144. */
  118145. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  118146. /**
  118147. * Get the current class name of the current effet
  118148. * @returns "DepthOfFieldEffect"
  118149. */
  118150. getClassName(): string;
  118151. /**
  118152. * 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.
  118153. */
  118154. depthTexture: RenderTargetTexture;
  118155. /**
  118156. * Disposes each of the internal effects for a given camera.
  118157. * @param camera The camera to dispose the effect on.
  118158. */
  118159. disposeEffects(camera: Camera): void;
  118160. /**
  118161. * @hidden Internal
  118162. */
  118163. _updateEffects(): void;
  118164. /**
  118165. * Internal
  118166. * @returns if all the contained post processes are ready.
  118167. * @hidden
  118168. */
  118169. _isReady(): boolean;
  118170. }
  118171. }
  118172. declare module BABYLON {
  118173. /** @hidden */
  118174. export var displayPassPixelShader: {
  118175. name: string;
  118176. shader: string;
  118177. };
  118178. }
  118179. declare module BABYLON {
  118180. /**
  118181. * DisplayPassPostProcess which produces an output the same as it's input
  118182. */
  118183. export class DisplayPassPostProcess extends PostProcess {
  118184. /**
  118185. * Creates the DisplayPassPostProcess
  118186. * @param name The name of the effect.
  118187. * @param options The required width/height ratio to downsize to before computing the render pass.
  118188. * @param camera The camera to apply the render pass to.
  118189. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118190. * @param engine The engine which the post process will be applied. (default: current engine)
  118191. * @param reusable If the post process can be reused on the same frame. (default: false)
  118192. */
  118193. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118194. }
  118195. }
  118196. declare module BABYLON {
  118197. /** @hidden */
  118198. export var filterPixelShader: {
  118199. name: string;
  118200. shader: string;
  118201. };
  118202. }
  118203. declare module BABYLON {
  118204. /**
  118205. * Applies a kernel filter to the image
  118206. */
  118207. export class FilterPostProcess extends PostProcess {
  118208. /** The matrix to be applied to the image */
  118209. kernelMatrix: Matrix;
  118210. /**
  118211. *
  118212. * @param name The name of the effect.
  118213. * @param kernelMatrix The matrix to be applied to the image
  118214. * @param options The required width/height ratio to downsize to before computing the render pass.
  118215. * @param camera The camera to apply the render pass to.
  118216. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118217. * @param engine The engine which the post process will be applied. (default: current engine)
  118218. * @param reusable If the post process can be reused on the same frame. (default: false)
  118219. */
  118220. constructor(name: string,
  118221. /** The matrix to be applied to the image */
  118222. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118223. }
  118224. }
  118225. declare module BABYLON {
  118226. /** @hidden */
  118227. export var fxaaPixelShader: {
  118228. name: string;
  118229. shader: string;
  118230. };
  118231. }
  118232. declare module BABYLON {
  118233. /** @hidden */
  118234. export var fxaaVertexShader: {
  118235. name: string;
  118236. shader: string;
  118237. };
  118238. }
  118239. declare module BABYLON {
  118240. /**
  118241. * Fxaa post process
  118242. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  118243. */
  118244. export class FxaaPostProcess extends PostProcess {
  118245. /** @hidden */
  118246. texelWidth: number;
  118247. /** @hidden */
  118248. texelHeight: number;
  118249. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  118250. private _getDefines;
  118251. }
  118252. }
  118253. declare module BABYLON {
  118254. /** @hidden */
  118255. export var grainPixelShader: {
  118256. name: string;
  118257. shader: string;
  118258. };
  118259. }
  118260. declare module BABYLON {
  118261. /**
  118262. * The GrainPostProcess adds noise to the image at mid luminance levels
  118263. */
  118264. export class GrainPostProcess extends PostProcess {
  118265. /**
  118266. * The intensity of the grain added (default: 30)
  118267. */
  118268. intensity: number;
  118269. /**
  118270. * If the grain should be randomized on every frame
  118271. */
  118272. animated: boolean;
  118273. /**
  118274. * Creates a new instance of @see GrainPostProcess
  118275. * @param name The name of the effect.
  118276. * @param options The required width/height ratio to downsize to before computing the render pass.
  118277. * @param camera The camera to apply the render pass to.
  118278. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118279. * @param engine The engine which the post process will be applied. (default: current engine)
  118280. * @param reusable If the post process can be reused on the same frame. (default: false)
  118281. * @param textureType Type of textures used when performing the post process. (default: 0)
  118282. * @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)
  118283. */
  118284. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118285. }
  118286. }
  118287. declare module BABYLON {
  118288. /** @hidden */
  118289. export var highlightsPixelShader: {
  118290. name: string;
  118291. shader: string;
  118292. };
  118293. }
  118294. declare module BABYLON {
  118295. /**
  118296. * Extracts highlights from the image
  118297. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  118298. */
  118299. export class HighlightsPostProcess extends PostProcess {
  118300. /**
  118301. * Extracts highlights from the image
  118302. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  118303. * @param name The name of the effect.
  118304. * @param options The required width/height ratio to downsize to before computing the render pass.
  118305. * @param camera The camera to apply the render pass to.
  118306. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118307. * @param engine The engine which the post process will be applied. (default: current engine)
  118308. * @param reusable If the post process can be reused on the same frame. (default: false)
  118309. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  118310. */
  118311. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  118312. }
  118313. }
  118314. declare module BABYLON {
  118315. /** @hidden */
  118316. export var mrtFragmentDeclaration: {
  118317. name: string;
  118318. shader: string;
  118319. };
  118320. }
  118321. declare module BABYLON {
  118322. /** @hidden */
  118323. export var geometryPixelShader: {
  118324. name: string;
  118325. shader: string;
  118326. };
  118327. }
  118328. declare module BABYLON {
  118329. /** @hidden */
  118330. export var geometryVertexShader: {
  118331. name: string;
  118332. shader: string;
  118333. };
  118334. }
  118335. declare module BABYLON {
  118336. /** @hidden */
  118337. interface ISavedTransformationMatrix {
  118338. world: Matrix;
  118339. viewProjection: Matrix;
  118340. }
  118341. /**
  118342. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  118343. */
  118344. export class GeometryBufferRenderer {
  118345. /**
  118346. * Constant used to retrieve the position texture index in the G-Buffer textures array
  118347. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  118348. */
  118349. static readonly POSITION_TEXTURE_TYPE: number;
  118350. /**
  118351. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  118352. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  118353. */
  118354. static readonly VELOCITY_TEXTURE_TYPE: number;
  118355. /**
  118356. * Dictionary used to store the previous transformation matrices of each rendered mesh
  118357. * in order to compute objects velocities when enableVelocity is set to "true"
  118358. * @hidden
  118359. */
  118360. _previousTransformationMatrices: {
  118361. [index: number]: ISavedTransformationMatrix;
  118362. };
  118363. /**
  118364. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  118365. * in order to compute objects velocities when enableVelocity is set to "true"
  118366. * @hidden
  118367. */
  118368. _previousBonesTransformationMatrices: {
  118369. [index: number]: Float32Array;
  118370. };
  118371. /**
  118372. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  118373. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  118374. */
  118375. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  118376. private _scene;
  118377. private _multiRenderTarget;
  118378. private _ratio;
  118379. private _enablePosition;
  118380. private _enableVelocity;
  118381. private _positionIndex;
  118382. private _velocityIndex;
  118383. protected _effect: Effect;
  118384. protected _cachedDefines: string;
  118385. /**
  118386. * Set the render list (meshes to be rendered) used in the G buffer.
  118387. */
  118388. renderList: Mesh[];
  118389. /**
  118390. * Gets wether or not G buffer are supported by the running hardware.
  118391. * This requires draw buffer supports
  118392. */
  118393. readonly isSupported: boolean;
  118394. /**
  118395. * Returns the index of the given texture type in the G-Buffer textures array
  118396. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  118397. * @returns the index of the given texture type in the G-Buffer textures array
  118398. */
  118399. getTextureIndex(textureType: number): number;
  118400. /**
  118401. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  118402. */
  118403. /**
  118404. * Sets whether or not objects positions are enabled for the G buffer.
  118405. */
  118406. enablePosition: boolean;
  118407. /**
  118408. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  118409. */
  118410. /**
  118411. * Sets wether or not objects velocities are enabled for the G buffer.
  118412. */
  118413. enableVelocity: boolean;
  118414. /**
  118415. * Gets the scene associated with the buffer.
  118416. */
  118417. readonly scene: Scene;
  118418. /**
  118419. * Gets the ratio used by the buffer during its creation.
  118420. * How big is the buffer related to the main canvas.
  118421. */
  118422. readonly ratio: number;
  118423. /** @hidden */
  118424. static _SceneComponentInitialization: (scene: Scene) => void;
  118425. /**
  118426. * Creates a new G Buffer for the scene
  118427. * @param scene The scene the buffer belongs to
  118428. * @param ratio How big is the buffer related to the main canvas.
  118429. */
  118430. constructor(scene: Scene, ratio?: number);
  118431. /**
  118432. * Checks wether everything is ready to render a submesh to the G buffer.
  118433. * @param subMesh the submesh to check readiness for
  118434. * @param useInstances is the mesh drawn using instance or not
  118435. * @returns true if ready otherwise false
  118436. */
  118437. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118438. /**
  118439. * Gets the current underlying G Buffer.
  118440. * @returns the buffer
  118441. */
  118442. getGBuffer(): MultiRenderTarget;
  118443. /**
  118444. * Gets the number of samples used to render the buffer (anti aliasing).
  118445. */
  118446. /**
  118447. * Sets the number of samples used to render the buffer (anti aliasing).
  118448. */
  118449. samples: number;
  118450. /**
  118451. * Disposes the renderer and frees up associated resources.
  118452. */
  118453. dispose(): void;
  118454. protected _createRenderTargets(): void;
  118455. private _copyBonesTransformationMatrices;
  118456. }
  118457. }
  118458. declare module BABYLON {
  118459. interface Scene {
  118460. /** @hidden (Backing field) */
  118461. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  118462. /**
  118463. * Gets or Sets the current geometry buffer associated to the scene.
  118464. */
  118465. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  118466. /**
  118467. * Enables a GeometryBufferRender and associates it with the scene
  118468. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  118469. * @returns the GeometryBufferRenderer
  118470. */
  118471. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  118472. /**
  118473. * Disables the GeometryBufferRender associated with the scene
  118474. */
  118475. disableGeometryBufferRenderer(): void;
  118476. }
  118477. /**
  118478. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  118479. * in several rendering techniques.
  118480. */
  118481. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  118482. /**
  118483. * The component name helpful to identify the component in the list of scene components.
  118484. */
  118485. readonly name: string;
  118486. /**
  118487. * The scene the component belongs to.
  118488. */
  118489. scene: Scene;
  118490. /**
  118491. * Creates a new instance of the component for the given scene
  118492. * @param scene Defines the scene to register the component in
  118493. */
  118494. constructor(scene: Scene);
  118495. /**
  118496. * Registers the component in a given scene
  118497. */
  118498. register(): void;
  118499. /**
  118500. * Rebuilds the elements related to this component in case of
  118501. * context lost for instance.
  118502. */
  118503. rebuild(): void;
  118504. /**
  118505. * Disposes the component and the associated ressources
  118506. */
  118507. dispose(): void;
  118508. private _gatherRenderTargets;
  118509. }
  118510. }
  118511. declare module BABYLON {
  118512. /** @hidden */
  118513. export var motionBlurPixelShader: {
  118514. name: string;
  118515. shader: string;
  118516. };
  118517. }
  118518. declare module BABYLON {
  118519. /**
  118520. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  118521. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  118522. * As an example, all you have to do is to create the post-process:
  118523. * var mb = new BABYLON.MotionBlurPostProcess(
  118524. * 'mb', // The name of the effect.
  118525. * scene, // The scene containing the objects to blur according to their velocity.
  118526. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  118527. * camera // The camera to apply the render pass to.
  118528. * );
  118529. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  118530. */
  118531. export class MotionBlurPostProcess extends PostProcess {
  118532. /**
  118533. * Defines how much the image is blurred by the movement. Default value is equal to 1
  118534. */
  118535. motionStrength: number;
  118536. /**
  118537. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  118538. */
  118539. /**
  118540. * Sets the number of iterations to be used for motion blur quality
  118541. */
  118542. motionBlurSamples: number;
  118543. private _motionBlurSamples;
  118544. private _geometryBufferRenderer;
  118545. /**
  118546. * Creates a new instance MotionBlurPostProcess
  118547. * @param name The name of the effect.
  118548. * @param scene The scene containing the objects to blur according to their velocity.
  118549. * @param options The required width/height ratio to downsize to before computing the render pass.
  118550. * @param camera The camera to apply the render pass to.
  118551. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118552. * @param engine The engine which the post process will be applied. (default: current engine)
  118553. * @param reusable If the post process can be reused on the same frame. (default: false)
  118554. * @param textureType Type of textures used when performing the post process. (default: 0)
  118555. * @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)
  118556. */
  118557. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118558. /**
  118559. * Excludes the given skinned mesh from computing bones velocities.
  118560. * 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.
  118561. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  118562. */
  118563. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  118564. /**
  118565. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  118566. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  118567. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  118568. */
  118569. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  118570. /**
  118571. * Disposes the post process.
  118572. * @param camera The camera to dispose the post process on.
  118573. */
  118574. dispose(camera?: Camera): void;
  118575. }
  118576. }
  118577. declare module BABYLON {
  118578. /** @hidden */
  118579. export var refractionPixelShader: {
  118580. name: string;
  118581. shader: string;
  118582. };
  118583. }
  118584. declare module BABYLON {
  118585. /**
  118586. * Post process which applies a refractin texture
  118587. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  118588. */
  118589. export class RefractionPostProcess extends PostProcess {
  118590. /** the base color of the refraction (used to taint the rendering) */
  118591. color: Color3;
  118592. /** simulated refraction depth */
  118593. depth: number;
  118594. /** the coefficient of the base color (0 to remove base color tainting) */
  118595. colorLevel: number;
  118596. private _refTexture;
  118597. private _ownRefractionTexture;
  118598. /**
  118599. * Gets or sets the refraction texture
  118600. * Please note that you are responsible for disposing the texture if you set it manually
  118601. */
  118602. refractionTexture: Texture;
  118603. /**
  118604. * Initializes the RefractionPostProcess
  118605. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  118606. * @param name The name of the effect.
  118607. * @param refractionTextureUrl Url of the refraction texture to use
  118608. * @param color the base color of the refraction (used to taint the rendering)
  118609. * @param depth simulated refraction depth
  118610. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  118611. * @param camera The camera to apply the render pass to.
  118612. * @param options The required width/height ratio to downsize to before computing the render pass.
  118613. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118614. * @param engine The engine which the post process will be applied. (default: current engine)
  118615. * @param reusable If the post process can be reused on the same frame. (default: false)
  118616. */
  118617. constructor(name: string, refractionTextureUrl: string,
  118618. /** the base color of the refraction (used to taint the rendering) */
  118619. color: Color3,
  118620. /** simulated refraction depth */
  118621. depth: number,
  118622. /** the coefficient of the base color (0 to remove base color tainting) */
  118623. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  118624. /**
  118625. * Disposes of the post process
  118626. * @param camera Camera to dispose post process on
  118627. */
  118628. dispose(camera: Camera): void;
  118629. }
  118630. }
  118631. declare module BABYLON {
  118632. /** @hidden */
  118633. export var sharpenPixelShader: {
  118634. name: string;
  118635. shader: string;
  118636. };
  118637. }
  118638. declare module BABYLON {
  118639. /**
  118640. * The SharpenPostProcess applies a sharpen kernel to every pixel
  118641. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  118642. */
  118643. export class SharpenPostProcess extends PostProcess {
  118644. /**
  118645. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  118646. */
  118647. colorAmount: number;
  118648. /**
  118649. * How much sharpness should be applied (default: 0.3)
  118650. */
  118651. edgeAmount: number;
  118652. /**
  118653. * Creates a new instance ConvolutionPostProcess
  118654. * @param name The name of the effect.
  118655. * @param options The required width/height ratio to downsize to before computing the render pass.
  118656. * @param camera The camera to apply the render pass to.
  118657. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118658. * @param engine The engine which the post process will be applied. (default: current engine)
  118659. * @param reusable If the post process can be reused on the same frame. (default: false)
  118660. * @param textureType Type of textures used when performing the post process. (default: 0)
  118661. * @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)
  118662. */
  118663. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  118664. }
  118665. }
  118666. declare module BABYLON {
  118667. /**
  118668. * PostProcessRenderPipeline
  118669. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118670. */
  118671. export class PostProcessRenderPipeline {
  118672. private engine;
  118673. private _renderEffects;
  118674. private _renderEffectsForIsolatedPass;
  118675. /**
  118676. * List of inspectable custom properties (used by the Inspector)
  118677. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  118678. */
  118679. inspectableCustomProperties: IInspectable[];
  118680. /**
  118681. * @hidden
  118682. */
  118683. protected _cameras: Camera[];
  118684. /** @hidden */
  118685. _name: string;
  118686. /**
  118687. * Gets pipeline name
  118688. */
  118689. readonly name: string;
  118690. /**
  118691. * Initializes a PostProcessRenderPipeline
  118692. * @param engine engine to add the pipeline to
  118693. * @param name name of the pipeline
  118694. */
  118695. constructor(engine: Engine, name: string);
  118696. /**
  118697. * Gets the class name
  118698. * @returns "PostProcessRenderPipeline"
  118699. */
  118700. getClassName(): string;
  118701. /**
  118702. * If all the render effects in the pipeline are supported
  118703. */
  118704. readonly isSupported: boolean;
  118705. /**
  118706. * Adds an effect to the pipeline
  118707. * @param renderEffect the effect to add
  118708. */
  118709. addEffect(renderEffect: PostProcessRenderEffect): void;
  118710. /** @hidden */
  118711. _rebuild(): void;
  118712. /** @hidden */
  118713. _enableEffect(renderEffectName: string, cameras: Camera): void;
  118714. /** @hidden */
  118715. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  118716. /** @hidden */
  118717. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  118718. /** @hidden */
  118719. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  118720. /** @hidden */
  118721. _attachCameras(cameras: Camera, unique: boolean): void;
  118722. /** @hidden */
  118723. _attachCameras(cameras: Camera[], unique: boolean): void;
  118724. /** @hidden */
  118725. _detachCameras(cameras: Camera): void;
  118726. /** @hidden */
  118727. _detachCameras(cameras: Nullable<Camera[]>): void;
  118728. /** @hidden */
  118729. _update(): void;
  118730. /** @hidden */
  118731. _reset(): void;
  118732. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  118733. /**
  118734. * Disposes of the pipeline
  118735. */
  118736. dispose(): void;
  118737. }
  118738. }
  118739. declare module BABYLON {
  118740. /**
  118741. * PostProcessRenderPipelineManager class
  118742. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118743. */
  118744. export class PostProcessRenderPipelineManager {
  118745. private _renderPipelines;
  118746. /**
  118747. * Initializes a PostProcessRenderPipelineManager
  118748. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118749. */
  118750. constructor();
  118751. /**
  118752. * Gets the list of supported render pipelines
  118753. */
  118754. readonly supportedPipelines: PostProcessRenderPipeline[];
  118755. /**
  118756. * Adds a pipeline to the manager
  118757. * @param renderPipeline The pipeline to add
  118758. */
  118759. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  118760. /**
  118761. * Attaches a camera to the pipeline
  118762. * @param renderPipelineName The name of the pipeline to attach to
  118763. * @param cameras the camera to attach
  118764. * @param unique if the camera can be attached multiple times to the pipeline
  118765. */
  118766. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  118767. /**
  118768. * Detaches a camera from the pipeline
  118769. * @param renderPipelineName The name of the pipeline to detach from
  118770. * @param cameras the camera to detach
  118771. */
  118772. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  118773. /**
  118774. * Enables an effect by name on a pipeline
  118775. * @param renderPipelineName the name of the pipeline to enable the effect in
  118776. * @param renderEffectName the name of the effect to enable
  118777. * @param cameras the cameras that the effect should be enabled on
  118778. */
  118779. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  118780. /**
  118781. * Disables an effect by name on a pipeline
  118782. * @param renderPipelineName the name of the pipeline to disable the effect in
  118783. * @param renderEffectName the name of the effect to disable
  118784. * @param cameras the cameras that the effect should be disabled on
  118785. */
  118786. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  118787. /**
  118788. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  118789. */
  118790. update(): void;
  118791. /** @hidden */
  118792. _rebuild(): void;
  118793. /**
  118794. * Disposes of the manager and pipelines
  118795. */
  118796. dispose(): void;
  118797. }
  118798. }
  118799. declare module BABYLON {
  118800. interface Scene {
  118801. /** @hidden (Backing field) */
  118802. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  118803. /**
  118804. * Gets the postprocess render pipeline manager
  118805. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  118806. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  118807. */
  118808. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  118809. }
  118810. /**
  118811. * Defines the Render Pipeline scene component responsible to rendering pipelines
  118812. */
  118813. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  118814. /**
  118815. * The component name helpfull to identify the component in the list of scene components.
  118816. */
  118817. readonly name: string;
  118818. /**
  118819. * The scene the component belongs to.
  118820. */
  118821. scene: Scene;
  118822. /**
  118823. * Creates a new instance of the component for the given scene
  118824. * @param scene Defines the scene to register the component in
  118825. */
  118826. constructor(scene: Scene);
  118827. /**
  118828. * Registers the component in a given scene
  118829. */
  118830. register(): void;
  118831. /**
  118832. * Rebuilds the elements related to this component in case of
  118833. * context lost for instance.
  118834. */
  118835. rebuild(): void;
  118836. /**
  118837. * Disposes the component and the associated ressources
  118838. */
  118839. dispose(): void;
  118840. private _gatherRenderTargets;
  118841. }
  118842. }
  118843. declare module BABYLON {
  118844. /**
  118845. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  118846. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  118847. */
  118848. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  118849. private _scene;
  118850. private _camerasToBeAttached;
  118851. /**
  118852. * ID of the sharpen post process,
  118853. */
  118854. private readonly SharpenPostProcessId;
  118855. /**
  118856. * @ignore
  118857. * ID of the image processing post process;
  118858. */
  118859. readonly ImageProcessingPostProcessId: string;
  118860. /**
  118861. * @ignore
  118862. * ID of the Fast Approximate Anti-Aliasing post process;
  118863. */
  118864. readonly FxaaPostProcessId: string;
  118865. /**
  118866. * ID of the chromatic aberration post process,
  118867. */
  118868. private readonly ChromaticAberrationPostProcessId;
  118869. /**
  118870. * ID of the grain post process
  118871. */
  118872. private readonly GrainPostProcessId;
  118873. /**
  118874. * Sharpen post process which will apply a sharpen convolution to enhance edges
  118875. */
  118876. sharpen: SharpenPostProcess;
  118877. private _sharpenEffect;
  118878. private bloom;
  118879. /**
  118880. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  118881. */
  118882. depthOfField: DepthOfFieldEffect;
  118883. /**
  118884. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  118885. */
  118886. fxaa: FxaaPostProcess;
  118887. /**
  118888. * Image post processing pass used to perform operations such as tone mapping or color grading.
  118889. */
  118890. imageProcessing: ImageProcessingPostProcess;
  118891. /**
  118892. * Chromatic aberration post process which will shift rgb colors in the image
  118893. */
  118894. chromaticAberration: ChromaticAberrationPostProcess;
  118895. private _chromaticAberrationEffect;
  118896. /**
  118897. * Grain post process which add noise to the image
  118898. */
  118899. grain: GrainPostProcess;
  118900. private _grainEffect;
  118901. /**
  118902. * Glow post process which adds a glow to emissive areas of the image
  118903. */
  118904. private _glowLayer;
  118905. /**
  118906. * Animations which can be used to tweak settings over a period of time
  118907. */
  118908. animations: Animation[];
  118909. private _imageProcessingConfigurationObserver;
  118910. private _sharpenEnabled;
  118911. private _bloomEnabled;
  118912. private _depthOfFieldEnabled;
  118913. private _depthOfFieldBlurLevel;
  118914. private _fxaaEnabled;
  118915. private _imageProcessingEnabled;
  118916. private _defaultPipelineTextureType;
  118917. private _bloomScale;
  118918. private _chromaticAberrationEnabled;
  118919. private _grainEnabled;
  118920. private _buildAllowed;
  118921. /**
  118922. * Gets active scene
  118923. */
  118924. readonly scene: Scene;
  118925. /**
  118926. * Enable or disable the sharpen process from the pipeline
  118927. */
  118928. sharpenEnabled: boolean;
  118929. private _resizeObserver;
  118930. private _hardwareScaleLevel;
  118931. private _bloomKernel;
  118932. /**
  118933. * Specifies the size of the bloom blur kernel, relative to the final output size
  118934. */
  118935. bloomKernel: number;
  118936. /**
  118937. * Specifies the weight of the bloom in the final rendering
  118938. */
  118939. private _bloomWeight;
  118940. /**
  118941. * Specifies the luma threshold for the area that will be blurred by the bloom
  118942. */
  118943. private _bloomThreshold;
  118944. private _hdr;
  118945. /**
  118946. * The strength of the bloom.
  118947. */
  118948. bloomWeight: number;
  118949. /**
  118950. * The strength of the bloom.
  118951. */
  118952. bloomThreshold: number;
  118953. /**
  118954. * The scale of the bloom, lower value will provide better performance.
  118955. */
  118956. bloomScale: number;
  118957. /**
  118958. * Enable or disable the bloom from the pipeline
  118959. */
  118960. bloomEnabled: boolean;
  118961. private _rebuildBloom;
  118962. /**
  118963. * If the depth of field is enabled.
  118964. */
  118965. depthOfFieldEnabled: boolean;
  118966. /**
  118967. * Blur level of the depth of field effect. (Higher blur will effect performance)
  118968. */
  118969. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  118970. /**
  118971. * If the anti aliasing is enabled.
  118972. */
  118973. fxaaEnabled: boolean;
  118974. private _samples;
  118975. /**
  118976. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  118977. */
  118978. samples: number;
  118979. /**
  118980. * If image processing is enabled.
  118981. */
  118982. imageProcessingEnabled: boolean;
  118983. /**
  118984. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  118985. */
  118986. glowLayerEnabled: boolean;
  118987. /**
  118988. * Gets the glow layer (or null if not defined)
  118989. */
  118990. readonly glowLayer: Nullable<GlowLayer>;
  118991. /**
  118992. * Enable or disable the chromaticAberration process from the pipeline
  118993. */
  118994. chromaticAberrationEnabled: boolean;
  118995. /**
  118996. * Enable or disable the grain process from the pipeline
  118997. */
  118998. grainEnabled: boolean;
  118999. /**
  119000. * @constructor
  119001. * @param name - The rendering pipeline name (default: "")
  119002. * @param hdr - If high dynamic range textures should be used (default: true)
  119003. * @param scene - The scene linked to this pipeline (default: the last created scene)
  119004. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  119005. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  119006. */
  119007. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  119008. /**
  119009. * Get the class name
  119010. * @returns "DefaultRenderingPipeline"
  119011. */
  119012. getClassName(): string;
  119013. /**
  119014. * Force the compilation of the entire pipeline.
  119015. */
  119016. prepare(): void;
  119017. private _hasCleared;
  119018. private _prevPostProcess;
  119019. private _prevPrevPostProcess;
  119020. private _setAutoClearAndTextureSharing;
  119021. private _depthOfFieldSceneObserver;
  119022. private _buildPipeline;
  119023. private _disposePostProcesses;
  119024. /**
  119025. * Adds a camera to the pipeline
  119026. * @param camera the camera to be added
  119027. */
  119028. addCamera(camera: Camera): void;
  119029. /**
  119030. * Removes a camera from the pipeline
  119031. * @param camera the camera to remove
  119032. */
  119033. removeCamera(camera: Camera): void;
  119034. /**
  119035. * Dispose of the pipeline and stop all post processes
  119036. */
  119037. dispose(): void;
  119038. /**
  119039. * Serialize the rendering pipeline (Used when exporting)
  119040. * @returns the serialized object
  119041. */
  119042. serialize(): any;
  119043. /**
  119044. * Parse the serialized pipeline
  119045. * @param source Source pipeline.
  119046. * @param scene The scene to load the pipeline to.
  119047. * @param rootUrl The URL of the serialized pipeline.
  119048. * @returns An instantiated pipeline from the serialized object.
  119049. */
  119050. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  119051. }
  119052. }
  119053. declare module BABYLON {
  119054. /** @hidden */
  119055. export var lensHighlightsPixelShader: {
  119056. name: string;
  119057. shader: string;
  119058. };
  119059. }
  119060. declare module BABYLON {
  119061. /** @hidden */
  119062. export var depthOfFieldPixelShader: {
  119063. name: string;
  119064. shader: string;
  119065. };
  119066. }
  119067. declare module BABYLON {
  119068. /**
  119069. * BABYLON.JS Chromatic Aberration GLSL Shader
  119070. * Author: Olivier Guyot
  119071. * Separates very slightly R, G and B colors on the edges of the screen
  119072. * Inspired by Francois Tarlier & Martins Upitis
  119073. */
  119074. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  119075. /**
  119076. * @ignore
  119077. * The chromatic aberration PostProcess id in the pipeline
  119078. */
  119079. LensChromaticAberrationEffect: string;
  119080. /**
  119081. * @ignore
  119082. * The highlights enhancing PostProcess id in the pipeline
  119083. */
  119084. HighlightsEnhancingEffect: string;
  119085. /**
  119086. * @ignore
  119087. * The depth-of-field PostProcess id in the pipeline
  119088. */
  119089. LensDepthOfFieldEffect: string;
  119090. private _scene;
  119091. private _depthTexture;
  119092. private _grainTexture;
  119093. private _chromaticAberrationPostProcess;
  119094. private _highlightsPostProcess;
  119095. private _depthOfFieldPostProcess;
  119096. private _edgeBlur;
  119097. private _grainAmount;
  119098. private _chromaticAberration;
  119099. private _distortion;
  119100. private _highlightsGain;
  119101. private _highlightsThreshold;
  119102. private _dofDistance;
  119103. private _dofAperture;
  119104. private _dofDarken;
  119105. private _dofPentagon;
  119106. private _blurNoise;
  119107. /**
  119108. * @constructor
  119109. *
  119110. * Effect parameters are as follow:
  119111. * {
  119112. * chromatic_aberration: number; // from 0 to x (1 for realism)
  119113. * edge_blur: number; // from 0 to x (1 for realism)
  119114. * distortion: number; // from 0 to x (1 for realism)
  119115. * grain_amount: number; // from 0 to 1
  119116. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  119117. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  119118. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  119119. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  119120. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  119121. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  119122. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  119123. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  119124. * }
  119125. * Note: if an effect parameter is unset, effect is disabled
  119126. *
  119127. * @param name The rendering pipeline name
  119128. * @param parameters - An object containing all parameters (see above)
  119129. * @param scene The scene linked to this pipeline
  119130. * @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)
  119131. * @param cameras The array of cameras that the rendering pipeline will be attached to
  119132. */
  119133. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  119134. /**
  119135. * Get the class name
  119136. * @returns "LensRenderingPipeline"
  119137. */
  119138. getClassName(): string;
  119139. /**
  119140. * Gets associated scene
  119141. */
  119142. readonly scene: Scene;
  119143. /**
  119144. * Gets or sets the edge blur
  119145. */
  119146. edgeBlur: number;
  119147. /**
  119148. * Gets or sets the grain amount
  119149. */
  119150. grainAmount: number;
  119151. /**
  119152. * Gets or sets the chromatic aberration amount
  119153. */
  119154. chromaticAberration: number;
  119155. /**
  119156. * Gets or sets the depth of field aperture
  119157. */
  119158. dofAperture: number;
  119159. /**
  119160. * Gets or sets the edge distortion
  119161. */
  119162. edgeDistortion: number;
  119163. /**
  119164. * Gets or sets the depth of field distortion
  119165. */
  119166. dofDistortion: number;
  119167. /**
  119168. * Gets or sets the darken out of focus amount
  119169. */
  119170. darkenOutOfFocus: number;
  119171. /**
  119172. * Gets or sets a boolean indicating if blur noise is enabled
  119173. */
  119174. blurNoise: boolean;
  119175. /**
  119176. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  119177. */
  119178. pentagonBokeh: boolean;
  119179. /**
  119180. * Gets or sets the highlight grain amount
  119181. */
  119182. highlightsGain: number;
  119183. /**
  119184. * Gets or sets the highlight threshold
  119185. */
  119186. highlightsThreshold: number;
  119187. /**
  119188. * Sets the amount of blur at the edges
  119189. * @param amount blur amount
  119190. */
  119191. setEdgeBlur(amount: number): void;
  119192. /**
  119193. * Sets edge blur to 0
  119194. */
  119195. disableEdgeBlur(): void;
  119196. /**
  119197. * Sets the amout of grain
  119198. * @param amount Amount of grain
  119199. */
  119200. setGrainAmount(amount: number): void;
  119201. /**
  119202. * Set grain amount to 0
  119203. */
  119204. disableGrain(): void;
  119205. /**
  119206. * Sets the chromatic aberration amount
  119207. * @param amount amount of chromatic aberration
  119208. */
  119209. setChromaticAberration(amount: number): void;
  119210. /**
  119211. * Sets chromatic aberration amount to 0
  119212. */
  119213. disableChromaticAberration(): void;
  119214. /**
  119215. * Sets the EdgeDistortion amount
  119216. * @param amount amount of EdgeDistortion
  119217. */
  119218. setEdgeDistortion(amount: number): void;
  119219. /**
  119220. * Sets edge distortion to 0
  119221. */
  119222. disableEdgeDistortion(): void;
  119223. /**
  119224. * Sets the FocusDistance amount
  119225. * @param amount amount of FocusDistance
  119226. */
  119227. setFocusDistance(amount: number): void;
  119228. /**
  119229. * Disables depth of field
  119230. */
  119231. disableDepthOfField(): void;
  119232. /**
  119233. * Sets the Aperture amount
  119234. * @param amount amount of Aperture
  119235. */
  119236. setAperture(amount: number): void;
  119237. /**
  119238. * Sets the DarkenOutOfFocus amount
  119239. * @param amount amount of DarkenOutOfFocus
  119240. */
  119241. setDarkenOutOfFocus(amount: number): void;
  119242. private _pentagonBokehIsEnabled;
  119243. /**
  119244. * Creates a pentagon bokeh effect
  119245. */
  119246. enablePentagonBokeh(): void;
  119247. /**
  119248. * Disables the pentagon bokeh effect
  119249. */
  119250. disablePentagonBokeh(): void;
  119251. /**
  119252. * Enables noise blur
  119253. */
  119254. enableNoiseBlur(): void;
  119255. /**
  119256. * Disables noise blur
  119257. */
  119258. disableNoiseBlur(): void;
  119259. /**
  119260. * Sets the HighlightsGain amount
  119261. * @param amount amount of HighlightsGain
  119262. */
  119263. setHighlightsGain(amount: number): void;
  119264. /**
  119265. * Sets the HighlightsThreshold amount
  119266. * @param amount amount of HighlightsThreshold
  119267. */
  119268. setHighlightsThreshold(amount: number): void;
  119269. /**
  119270. * Disables highlights
  119271. */
  119272. disableHighlights(): void;
  119273. /**
  119274. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  119275. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  119276. */
  119277. dispose(disableDepthRender?: boolean): void;
  119278. private _createChromaticAberrationPostProcess;
  119279. private _createHighlightsPostProcess;
  119280. private _createDepthOfFieldPostProcess;
  119281. private _createGrainTexture;
  119282. }
  119283. }
  119284. declare module BABYLON {
  119285. /** @hidden */
  119286. export var ssao2PixelShader: {
  119287. name: string;
  119288. shader: string;
  119289. };
  119290. }
  119291. declare module BABYLON {
  119292. /** @hidden */
  119293. export var ssaoCombinePixelShader: {
  119294. name: string;
  119295. shader: string;
  119296. };
  119297. }
  119298. declare module BABYLON {
  119299. /**
  119300. * Render pipeline to produce ssao effect
  119301. */
  119302. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  119303. /**
  119304. * @ignore
  119305. * The PassPostProcess id in the pipeline that contains the original scene color
  119306. */
  119307. SSAOOriginalSceneColorEffect: string;
  119308. /**
  119309. * @ignore
  119310. * The SSAO PostProcess id in the pipeline
  119311. */
  119312. SSAORenderEffect: string;
  119313. /**
  119314. * @ignore
  119315. * The horizontal blur PostProcess id in the pipeline
  119316. */
  119317. SSAOBlurHRenderEffect: string;
  119318. /**
  119319. * @ignore
  119320. * The vertical blur PostProcess id in the pipeline
  119321. */
  119322. SSAOBlurVRenderEffect: string;
  119323. /**
  119324. * @ignore
  119325. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  119326. */
  119327. SSAOCombineRenderEffect: string;
  119328. /**
  119329. * The output strength of the SSAO post-process. Default value is 1.0.
  119330. */
  119331. totalStrength: number;
  119332. /**
  119333. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  119334. */
  119335. maxZ: number;
  119336. /**
  119337. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  119338. */
  119339. minZAspect: number;
  119340. private _samples;
  119341. /**
  119342. * Number of samples used for the SSAO calculations. Default value is 8
  119343. */
  119344. samples: number;
  119345. private _textureSamples;
  119346. /**
  119347. * Number of samples to use for antialiasing
  119348. */
  119349. textureSamples: number;
  119350. /**
  119351. * Ratio object used for SSAO ratio and blur ratio
  119352. */
  119353. private _ratio;
  119354. /**
  119355. * Dynamically generated sphere sampler.
  119356. */
  119357. private _sampleSphere;
  119358. /**
  119359. * Blur filter offsets
  119360. */
  119361. private _samplerOffsets;
  119362. private _expensiveBlur;
  119363. /**
  119364. * If bilateral blur should be used
  119365. */
  119366. expensiveBlur: boolean;
  119367. /**
  119368. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  119369. */
  119370. radius: number;
  119371. /**
  119372. * The base color of the SSAO post-process
  119373. * The final result is "base + ssao" between [0, 1]
  119374. */
  119375. base: number;
  119376. /**
  119377. * Support test.
  119378. */
  119379. static readonly IsSupported: boolean;
  119380. private _scene;
  119381. private _depthTexture;
  119382. private _normalTexture;
  119383. private _randomTexture;
  119384. private _originalColorPostProcess;
  119385. private _ssaoPostProcess;
  119386. private _blurHPostProcess;
  119387. private _blurVPostProcess;
  119388. private _ssaoCombinePostProcess;
  119389. private _firstUpdate;
  119390. /**
  119391. * Gets active scene
  119392. */
  119393. readonly scene: Scene;
  119394. /**
  119395. * @constructor
  119396. * @param name The rendering pipeline name
  119397. * @param scene The scene linked to this pipeline
  119398. * @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 }
  119399. * @param cameras The array of cameras that the rendering pipeline will be attached to
  119400. */
  119401. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  119402. /**
  119403. * Get the class name
  119404. * @returns "SSAO2RenderingPipeline"
  119405. */
  119406. getClassName(): string;
  119407. /**
  119408. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  119409. */
  119410. dispose(disableGeometryBufferRenderer?: boolean): void;
  119411. private _createBlurPostProcess;
  119412. /** @hidden */
  119413. _rebuild(): void;
  119414. private _bits;
  119415. private _radicalInverse_VdC;
  119416. private _hammersley;
  119417. private _hemisphereSample_uniform;
  119418. private _generateHemisphere;
  119419. private _createSSAOPostProcess;
  119420. private _createSSAOCombinePostProcess;
  119421. private _createRandomTexture;
  119422. /**
  119423. * Serialize the rendering pipeline (Used when exporting)
  119424. * @returns the serialized object
  119425. */
  119426. serialize(): any;
  119427. /**
  119428. * Parse the serialized pipeline
  119429. * @param source Source pipeline.
  119430. * @param scene The scene to load the pipeline to.
  119431. * @param rootUrl The URL of the serialized pipeline.
  119432. * @returns An instantiated pipeline from the serialized object.
  119433. */
  119434. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  119435. }
  119436. }
  119437. declare module BABYLON {
  119438. /** @hidden */
  119439. export var ssaoPixelShader: {
  119440. name: string;
  119441. shader: string;
  119442. };
  119443. }
  119444. declare module BABYLON {
  119445. /**
  119446. * Render pipeline to produce ssao effect
  119447. */
  119448. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  119449. /**
  119450. * @ignore
  119451. * The PassPostProcess id in the pipeline that contains the original scene color
  119452. */
  119453. SSAOOriginalSceneColorEffect: string;
  119454. /**
  119455. * @ignore
  119456. * The SSAO PostProcess id in the pipeline
  119457. */
  119458. SSAORenderEffect: string;
  119459. /**
  119460. * @ignore
  119461. * The horizontal blur PostProcess id in the pipeline
  119462. */
  119463. SSAOBlurHRenderEffect: string;
  119464. /**
  119465. * @ignore
  119466. * The vertical blur PostProcess id in the pipeline
  119467. */
  119468. SSAOBlurVRenderEffect: string;
  119469. /**
  119470. * @ignore
  119471. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  119472. */
  119473. SSAOCombineRenderEffect: string;
  119474. /**
  119475. * The output strength of the SSAO post-process. Default value is 1.0.
  119476. */
  119477. totalStrength: number;
  119478. /**
  119479. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  119480. */
  119481. radius: number;
  119482. /**
  119483. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  119484. * Must not be equal to fallOff and superior to fallOff.
  119485. * Default value is 0.0075
  119486. */
  119487. area: number;
  119488. /**
  119489. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  119490. * Must not be equal to area and inferior to area.
  119491. * Default value is 0.000001
  119492. */
  119493. fallOff: number;
  119494. /**
  119495. * The base color of the SSAO post-process
  119496. * The final result is "base + ssao" between [0, 1]
  119497. */
  119498. base: number;
  119499. private _scene;
  119500. private _depthTexture;
  119501. private _randomTexture;
  119502. private _originalColorPostProcess;
  119503. private _ssaoPostProcess;
  119504. private _blurHPostProcess;
  119505. private _blurVPostProcess;
  119506. private _ssaoCombinePostProcess;
  119507. private _firstUpdate;
  119508. /**
  119509. * Gets active scene
  119510. */
  119511. readonly scene: Scene;
  119512. /**
  119513. * @constructor
  119514. * @param name - The rendering pipeline name
  119515. * @param scene - The scene linked to this pipeline
  119516. * @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 }
  119517. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  119518. */
  119519. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  119520. /**
  119521. * Get the class name
  119522. * @returns "SSAORenderingPipeline"
  119523. */
  119524. getClassName(): string;
  119525. /**
  119526. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  119527. */
  119528. dispose(disableDepthRender?: boolean): void;
  119529. private _createBlurPostProcess;
  119530. /** @hidden */
  119531. _rebuild(): void;
  119532. private _createSSAOPostProcess;
  119533. private _createSSAOCombinePostProcess;
  119534. private _createRandomTexture;
  119535. }
  119536. }
  119537. declare module BABYLON {
  119538. /** @hidden */
  119539. export var standardPixelShader: {
  119540. name: string;
  119541. shader: string;
  119542. };
  119543. }
  119544. declare module BABYLON {
  119545. /**
  119546. * Standard rendering pipeline
  119547. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  119548. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  119549. */
  119550. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  119551. /**
  119552. * Public members
  119553. */
  119554. /**
  119555. * Post-process which contains the original scene color before the pipeline applies all the effects
  119556. */
  119557. originalPostProcess: Nullable<PostProcess>;
  119558. /**
  119559. * Post-process used to down scale an image x4
  119560. */
  119561. downSampleX4PostProcess: Nullable<PostProcess>;
  119562. /**
  119563. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  119564. */
  119565. brightPassPostProcess: Nullable<PostProcess>;
  119566. /**
  119567. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  119568. */
  119569. blurHPostProcesses: PostProcess[];
  119570. /**
  119571. * Post-process array storing all the vertical blur post-processes used by the pipeline
  119572. */
  119573. blurVPostProcesses: PostProcess[];
  119574. /**
  119575. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  119576. */
  119577. textureAdderPostProcess: Nullable<PostProcess>;
  119578. /**
  119579. * Post-process used to create volumetric lighting effect
  119580. */
  119581. volumetricLightPostProcess: Nullable<PostProcess>;
  119582. /**
  119583. * Post-process used to smooth the previous volumetric light post-process on the X axis
  119584. */
  119585. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  119586. /**
  119587. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  119588. */
  119589. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  119590. /**
  119591. * Post-process used to merge the volumetric light effect and the real scene color
  119592. */
  119593. volumetricLightMergePostProces: Nullable<PostProcess>;
  119594. /**
  119595. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  119596. */
  119597. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  119598. /**
  119599. * Base post-process used to calculate the average luminance of the final image for HDR
  119600. */
  119601. luminancePostProcess: Nullable<PostProcess>;
  119602. /**
  119603. * Post-processes used to create down sample post-processes in order to get
  119604. * the average luminance of the final image for HDR
  119605. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  119606. */
  119607. luminanceDownSamplePostProcesses: PostProcess[];
  119608. /**
  119609. * Post-process used to create a HDR effect (light adaptation)
  119610. */
  119611. hdrPostProcess: Nullable<PostProcess>;
  119612. /**
  119613. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  119614. */
  119615. textureAdderFinalPostProcess: Nullable<PostProcess>;
  119616. /**
  119617. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  119618. */
  119619. lensFlareFinalPostProcess: Nullable<PostProcess>;
  119620. /**
  119621. * Post-process used to merge the final HDR post-process and the real scene color
  119622. */
  119623. hdrFinalPostProcess: Nullable<PostProcess>;
  119624. /**
  119625. * Post-process used to create a lens flare effect
  119626. */
  119627. lensFlarePostProcess: Nullable<PostProcess>;
  119628. /**
  119629. * Post-process that merges the result of the lens flare post-process and the real scene color
  119630. */
  119631. lensFlareComposePostProcess: Nullable<PostProcess>;
  119632. /**
  119633. * Post-process used to create a motion blur effect
  119634. */
  119635. motionBlurPostProcess: Nullable<PostProcess>;
  119636. /**
  119637. * Post-process used to create a depth of field effect
  119638. */
  119639. depthOfFieldPostProcess: Nullable<PostProcess>;
  119640. /**
  119641. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  119642. */
  119643. fxaaPostProcess: Nullable<FxaaPostProcess>;
  119644. /**
  119645. * Represents the brightness threshold in order to configure the illuminated surfaces
  119646. */
  119647. brightThreshold: number;
  119648. /**
  119649. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  119650. */
  119651. blurWidth: number;
  119652. /**
  119653. * Sets if the blur for highlighted surfaces must be only horizontal
  119654. */
  119655. horizontalBlur: boolean;
  119656. /**
  119657. * Gets the overall exposure used by the pipeline
  119658. */
  119659. /**
  119660. * Sets the overall exposure used by the pipeline
  119661. */
  119662. exposure: number;
  119663. /**
  119664. * Texture used typically to simulate "dirty" on camera lens
  119665. */
  119666. lensTexture: Nullable<Texture>;
  119667. /**
  119668. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  119669. */
  119670. volumetricLightCoefficient: number;
  119671. /**
  119672. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  119673. */
  119674. volumetricLightPower: number;
  119675. /**
  119676. * Used the set the blur intensity to smooth the volumetric lights
  119677. */
  119678. volumetricLightBlurScale: number;
  119679. /**
  119680. * Light (spot or directional) used to generate the volumetric lights rays
  119681. * The source light must have a shadow generate so the pipeline can get its
  119682. * depth map
  119683. */
  119684. sourceLight: Nullable<SpotLight | DirectionalLight>;
  119685. /**
  119686. * For eye adaptation, represents the minimum luminance the eye can see
  119687. */
  119688. hdrMinimumLuminance: number;
  119689. /**
  119690. * For eye adaptation, represents the decrease luminance speed
  119691. */
  119692. hdrDecreaseRate: number;
  119693. /**
  119694. * For eye adaptation, represents the increase luminance speed
  119695. */
  119696. hdrIncreaseRate: number;
  119697. /**
  119698. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  119699. */
  119700. /**
  119701. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  119702. */
  119703. hdrAutoExposure: boolean;
  119704. /**
  119705. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  119706. */
  119707. lensColorTexture: Nullable<Texture>;
  119708. /**
  119709. * The overall strengh for the lens flare effect
  119710. */
  119711. lensFlareStrength: number;
  119712. /**
  119713. * Dispersion coefficient for lens flare ghosts
  119714. */
  119715. lensFlareGhostDispersal: number;
  119716. /**
  119717. * Main lens flare halo width
  119718. */
  119719. lensFlareHaloWidth: number;
  119720. /**
  119721. * Based on the lens distortion effect, defines how much the lens flare result
  119722. * is distorted
  119723. */
  119724. lensFlareDistortionStrength: number;
  119725. /**
  119726. * Lens star texture must be used to simulate rays on the flares and is available
  119727. * in the documentation
  119728. */
  119729. lensStarTexture: Nullable<Texture>;
  119730. /**
  119731. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  119732. * flare effect by taking account of the dirt texture
  119733. */
  119734. lensFlareDirtTexture: Nullable<Texture>;
  119735. /**
  119736. * Represents the focal length for the depth of field effect
  119737. */
  119738. depthOfFieldDistance: number;
  119739. /**
  119740. * Represents the blur intensity for the blurred part of the depth of field effect
  119741. */
  119742. depthOfFieldBlurWidth: number;
  119743. /**
  119744. * Gets how much the image is blurred by the movement while using the motion blur post-process
  119745. */
  119746. /**
  119747. * Sets how much the image is blurred by the movement while using the motion blur post-process
  119748. */
  119749. motionStrength: number;
  119750. /**
  119751. * Gets wether or not the motion blur post-process is object based or screen based.
  119752. */
  119753. /**
  119754. * Sets wether or not the motion blur post-process should be object based or screen based
  119755. */
  119756. objectBasedMotionBlur: boolean;
  119757. /**
  119758. * List of animations for the pipeline (IAnimatable implementation)
  119759. */
  119760. animations: Animation[];
  119761. /**
  119762. * Private members
  119763. */
  119764. private _scene;
  119765. private _currentDepthOfFieldSource;
  119766. private _basePostProcess;
  119767. private _fixedExposure;
  119768. private _currentExposure;
  119769. private _hdrAutoExposure;
  119770. private _hdrCurrentLuminance;
  119771. private _motionStrength;
  119772. private _isObjectBasedMotionBlur;
  119773. private _floatTextureType;
  119774. private _ratio;
  119775. private _bloomEnabled;
  119776. private _depthOfFieldEnabled;
  119777. private _vlsEnabled;
  119778. private _lensFlareEnabled;
  119779. private _hdrEnabled;
  119780. private _motionBlurEnabled;
  119781. private _fxaaEnabled;
  119782. private _motionBlurSamples;
  119783. private _volumetricLightStepsCount;
  119784. private _samples;
  119785. /**
  119786. * @ignore
  119787. * Specifies if the bloom pipeline is enabled
  119788. */
  119789. BloomEnabled: boolean;
  119790. /**
  119791. * @ignore
  119792. * Specifies if the depth of field pipeline is enabed
  119793. */
  119794. DepthOfFieldEnabled: boolean;
  119795. /**
  119796. * @ignore
  119797. * Specifies if the lens flare pipeline is enabed
  119798. */
  119799. LensFlareEnabled: boolean;
  119800. /**
  119801. * @ignore
  119802. * Specifies if the HDR pipeline is enabled
  119803. */
  119804. HDREnabled: boolean;
  119805. /**
  119806. * @ignore
  119807. * Specifies if the volumetric lights scattering effect is enabled
  119808. */
  119809. VLSEnabled: boolean;
  119810. /**
  119811. * @ignore
  119812. * Specifies if the motion blur effect is enabled
  119813. */
  119814. MotionBlurEnabled: boolean;
  119815. /**
  119816. * Specifies if anti-aliasing is enabled
  119817. */
  119818. fxaaEnabled: boolean;
  119819. /**
  119820. * Specifies the number of steps used to calculate the volumetric lights
  119821. * Typically in interval [50, 200]
  119822. */
  119823. volumetricLightStepsCount: number;
  119824. /**
  119825. * Specifies the number of samples used for the motion blur effect
  119826. * Typically in interval [16, 64]
  119827. */
  119828. motionBlurSamples: number;
  119829. /**
  119830. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  119831. */
  119832. samples: number;
  119833. /**
  119834. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  119835. * @constructor
  119836. * @param name The rendering pipeline name
  119837. * @param scene The scene linked to this pipeline
  119838. * @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)
  119839. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  119840. * @param cameras The array of cameras that the rendering pipeline will be attached to
  119841. */
  119842. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  119843. private _buildPipeline;
  119844. private _createDownSampleX4PostProcess;
  119845. private _createBrightPassPostProcess;
  119846. private _createBlurPostProcesses;
  119847. private _createTextureAdderPostProcess;
  119848. private _createVolumetricLightPostProcess;
  119849. private _createLuminancePostProcesses;
  119850. private _createHdrPostProcess;
  119851. private _createLensFlarePostProcess;
  119852. private _createDepthOfFieldPostProcess;
  119853. private _createMotionBlurPostProcess;
  119854. private _getDepthTexture;
  119855. private _disposePostProcesses;
  119856. /**
  119857. * Dispose of the pipeline and stop all post processes
  119858. */
  119859. dispose(): void;
  119860. /**
  119861. * Serialize the rendering pipeline (Used when exporting)
  119862. * @returns the serialized object
  119863. */
  119864. serialize(): any;
  119865. /**
  119866. * Parse the serialized pipeline
  119867. * @param source Source pipeline.
  119868. * @param scene The scene to load the pipeline to.
  119869. * @param rootUrl The URL of the serialized pipeline.
  119870. * @returns An instantiated pipeline from the serialized object.
  119871. */
  119872. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  119873. /**
  119874. * Luminance steps
  119875. */
  119876. static LuminanceSteps: number;
  119877. }
  119878. }
  119879. declare module BABYLON {
  119880. /** @hidden */
  119881. export var tonemapPixelShader: {
  119882. name: string;
  119883. shader: string;
  119884. };
  119885. }
  119886. declare module BABYLON {
  119887. /** Defines operator used for tonemapping */
  119888. export enum TonemappingOperator {
  119889. /** Hable */
  119890. Hable = 0,
  119891. /** Reinhard */
  119892. Reinhard = 1,
  119893. /** HejiDawson */
  119894. HejiDawson = 2,
  119895. /** Photographic */
  119896. Photographic = 3
  119897. }
  119898. /**
  119899. * Defines a post process to apply tone mapping
  119900. */
  119901. export class TonemapPostProcess extends PostProcess {
  119902. private _operator;
  119903. /** Defines the required exposure adjustement */
  119904. exposureAdjustment: number;
  119905. /**
  119906. * Creates a new TonemapPostProcess
  119907. * @param name defines the name of the postprocess
  119908. * @param _operator defines the operator to use
  119909. * @param exposureAdjustment defines the required exposure adjustement
  119910. * @param camera defines the camera to use (can be null)
  119911. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  119912. * @param engine defines the hosting engine (can be ignore if camera is set)
  119913. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  119914. */
  119915. constructor(name: string, _operator: TonemappingOperator,
  119916. /** Defines the required exposure adjustement */
  119917. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  119918. }
  119919. }
  119920. declare module BABYLON {
  119921. /** @hidden */
  119922. export var depthVertexShader: {
  119923. name: string;
  119924. shader: string;
  119925. };
  119926. }
  119927. declare module BABYLON {
  119928. /** @hidden */
  119929. export var volumetricLightScatteringPixelShader: {
  119930. name: string;
  119931. shader: string;
  119932. };
  119933. }
  119934. declare module BABYLON {
  119935. /** @hidden */
  119936. export var volumetricLightScatteringPassPixelShader: {
  119937. name: string;
  119938. shader: string;
  119939. };
  119940. }
  119941. declare module BABYLON {
  119942. /**
  119943. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  119944. */
  119945. export class VolumetricLightScatteringPostProcess extends PostProcess {
  119946. private _volumetricLightScatteringPass;
  119947. private _volumetricLightScatteringRTT;
  119948. private _viewPort;
  119949. private _screenCoordinates;
  119950. private _cachedDefines;
  119951. /**
  119952. * If not undefined, the mesh position is computed from the attached node position
  119953. */
  119954. attachedNode: {
  119955. position: Vector3;
  119956. };
  119957. /**
  119958. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  119959. */
  119960. customMeshPosition: Vector3;
  119961. /**
  119962. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  119963. */
  119964. useCustomMeshPosition: boolean;
  119965. /**
  119966. * If the post-process should inverse the light scattering direction
  119967. */
  119968. invert: boolean;
  119969. /**
  119970. * The internal mesh used by the post-process
  119971. */
  119972. mesh: Mesh;
  119973. /**
  119974. * @hidden
  119975. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  119976. */
  119977. useDiffuseColor: boolean;
  119978. /**
  119979. * Array containing the excluded meshes not rendered in the internal pass
  119980. */
  119981. excludedMeshes: AbstractMesh[];
  119982. /**
  119983. * Controls the overall intensity of the post-process
  119984. */
  119985. exposure: number;
  119986. /**
  119987. * Dissipates each sample's contribution in range [0, 1]
  119988. */
  119989. decay: number;
  119990. /**
  119991. * Controls the overall intensity of each sample
  119992. */
  119993. weight: number;
  119994. /**
  119995. * Controls the density of each sample
  119996. */
  119997. density: number;
  119998. /**
  119999. * @constructor
  120000. * @param name The post-process name
  120001. * @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)
  120002. * @param camera The camera that the post-process will be attached to
  120003. * @param mesh The mesh used to create the light scattering
  120004. * @param samples The post-process quality, default 100
  120005. * @param samplingModeThe post-process filtering mode
  120006. * @param engine The babylon engine
  120007. * @param reusable If the post-process is reusable
  120008. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  120009. */
  120010. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  120011. /**
  120012. * Returns the string "VolumetricLightScatteringPostProcess"
  120013. * @returns "VolumetricLightScatteringPostProcess"
  120014. */
  120015. getClassName(): string;
  120016. private _isReady;
  120017. /**
  120018. * Sets the new light position for light scattering effect
  120019. * @param position The new custom light position
  120020. */
  120021. setCustomMeshPosition(position: Vector3): void;
  120022. /**
  120023. * Returns the light position for light scattering effect
  120024. * @return Vector3 The custom light position
  120025. */
  120026. getCustomMeshPosition(): Vector3;
  120027. /**
  120028. * Disposes the internal assets and detaches the post-process from the camera
  120029. */
  120030. dispose(camera: Camera): void;
  120031. /**
  120032. * Returns the render target texture used by the post-process
  120033. * @return the render target texture used by the post-process
  120034. */
  120035. getPass(): RenderTargetTexture;
  120036. private _meshExcluded;
  120037. private _createPass;
  120038. private _updateMeshScreenCoordinates;
  120039. /**
  120040. * Creates a default mesh for the Volumeric Light Scattering post-process
  120041. * @param name The mesh name
  120042. * @param scene The scene where to create the mesh
  120043. * @return the default mesh
  120044. */
  120045. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  120046. }
  120047. }
  120048. declare module BABYLON {
  120049. interface Scene {
  120050. /** @hidden (Backing field) */
  120051. _boundingBoxRenderer: BoundingBoxRenderer;
  120052. /** @hidden (Backing field) */
  120053. _forceShowBoundingBoxes: boolean;
  120054. /**
  120055. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  120056. */
  120057. forceShowBoundingBoxes: boolean;
  120058. /**
  120059. * Gets the bounding box renderer associated with the scene
  120060. * @returns a BoundingBoxRenderer
  120061. */
  120062. getBoundingBoxRenderer(): BoundingBoxRenderer;
  120063. }
  120064. interface AbstractMesh {
  120065. /** @hidden (Backing field) */
  120066. _showBoundingBox: boolean;
  120067. /**
  120068. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  120069. */
  120070. showBoundingBox: boolean;
  120071. }
  120072. /**
  120073. * Component responsible of rendering the bounding box of the meshes in a scene.
  120074. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  120075. */
  120076. export class BoundingBoxRenderer implements ISceneComponent {
  120077. /**
  120078. * The component name helpfull to identify the component in the list of scene components.
  120079. */
  120080. readonly name: string;
  120081. /**
  120082. * The scene the component belongs to.
  120083. */
  120084. scene: Scene;
  120085. /**
  120086. * Color of the bounding box lines placed in front of an object
  120087. */
  120088. frontColor: Color3;
  120089. /**
  120090. * Color of the bounding box lines placed behind an object
  120091. */
  120092. backColor: Color3;
  120093. /**
  120094. * Defines if the renderer should show the back lines or not
  120095. */
  120096. showBackLines: boolean;
  120097. /**
  120098. * @hidden
  120099. */
  120100. renderList: SmartArray<BoundingBox>;
  120101. private _colorShader;
  120102. private _vertexBuffers;
  120103. private _indexBuffer;
  120104. private _fillIndexBuffer;
  120105. private _fillIndexData;
  120106. /**
  120107. * Instantiates a new bounding box renderer in a scene.
  120108. * @param scene the scene the renderer renders in
  120109. */
  120110. constructor(scene: Scene);
  120111. /**
  120112. * Registers the component in a given scene
  120113. */
  120114. register(): void;
  120115. private _evaluateSubMesh;
  120116. private _activeMesh;
  120117. private _prepareRessources;
  120118. private _createIndexBuffer;
  120119. /**
  120120. * Rebuilds the elements related to this component in case of
  120121. * context lost for instance.
  120122. */
  120123. rebuild(): void;
  120124. /**
  120125. * @hidden
  120126. */
  120127. reset(): void;
  120128. /**
  120129. * Render the bounding boxes of a specific rendering group
  120130. * @param renderingGroupId defines the rendering group to render
  120131. */
  120132. render(renderingGroupId: number): void;
  120133. /**
  120134. * In case of occlusion queries, we can render the occlusion bounding box through this method
  120135. * @param mesh Define the mesh to render the occlusion bounding box for
  120136. */
  120137. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  120138. /**
  120139. * Dispose and release the resources attached to this renderer.
  120140. */
  120141. dispose(): void;
  120142. }
  120143. }
  120144. declare module BABYLON {
  120145. /** @hidden */
  120146. export var depthPixelShader: {
  120147. name: string;
  120148. shader: string;
  120149. };
  120150. }
  120151. declare module BABYLON {
  120152. /**
  120153. * This represents a depth renderer in Babylon.
  120154. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  120155. */
  120156. export class DepthRenderer {
  120157. private _scene;
  120158. private _depthMap;
  120159. private _effect;
  120160. private _cachedDefines;
  120161. private _camera;
  120162. /**
  120163. * Specifiess that the depth renderer will only be used within
  120164. * the camera it is created for.
  120165. * This can help forcing its rendering during the camera processing.
  120166. */
  120167. useOnlyInActiveCamera: boolean;
  120168. /** @hidden */
  120169. static _SceneComponentInitialization: (scene: Scene) => void;
  120170. /**
  120171. * Instantiates a depth renderer
  120172. * @param scene The scene the renderer belongs to
  120173. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  120174. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  120175. */
  120176. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  120177. /**
  120178. * Creates the depth rendering effect and checks if the effect is ready.
  120179. * @param subMesh The submesh to be used to render the depth map of
  120180. * @param useInstances If multiple world instances should be used
  120181. * @returns if the depth renderer is ready to render the depth map
  120182. */
  120183. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  120184. /**
  120185. * Gets the texture which the depth map will be written to.
  120186. * @returns The depth map texture
  120187. */
  120188. getDepthMap(): RenderTargetTexture;
  120189. /**
  120190. * Disposes of the depth renderer.
  120191. */
  120192. dispose(): void;
  120193. }
  120194. }
  120195. declare module BABYLON {
  120196. interface Scene {
  120197. /** @hidden (Backing field) */
  120198. _depthRenderer: {
  120199. [id: string]: DepthRenderer;
  120200. };
  120201. /**
  120202. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  120203. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  120204. * @returns the created depth renderer
  120205. */
  120206. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  120207. /**
  120208. * Disables a depth renderer for a given camera
  120209. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  120210. */
  120211. disableDepthRenderer(camera?: Nullable<Camera>): void;
  120212. }
  120213. /**
  120214. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  120215. * in several rendering techniques.
  120216. */
  120217. export class DepthRendererSceneComponent implements ISceneComponent {
  120218. /**
  120219. * The component name helpfull to identify the component in the list of scene components.
  120220. */
  120221. readonly name: string;
  120222. /**
  120223. * The scene the component belongs to.
  120224. */
  120225. scene: Scene;
  120226. /**
  120227. * Creates a new instance of the component for the given scene
  120228. * @param scene Defines the scene to register the component in
  120229. */
  120230. constructor(scene: Scene);
  120231. /**
  120232. * Registers the component in a given scene
  120233. */
  120234. register(): void;
  120235. /**
  120236. * Rebuilds the elements related to this component in case of
  120237. * context lost for instance.
  120238. */
  120239. rebuild(): void;
  120240. /**
  120241. * Disposes the component and the associated ressources
  120242. */
  120243. dispose(): void;
  120244. private _gatherRenderTargets;
  120245. private _gatherActiveCameraRenderTargets;
  120246. }
  120247. }
  120248. declare module BABYLON {
  120249. /** @hidden */
  120250. export var outlinePixelShader: {
  120251. name: string;
  120252. shader: string;
  120253. };
  120254. }
  120255. declare module BABYLON {
  120256. /** @hidden */
  120257. export var outlineVertexShader: {
  120258. name: string;
  120259. shader: string;
  120260. };
  120261. }
  120262. declare module BABYLON {
  120263. interface Scene {
  120264. /** @hidden */
  120265. _outlineRenderer: OutlineRenderer;
  120266. /**
  120267. * Gets the outline renderer associated with the scene
  120268. * @returns a OutlineRenderer
  120269. */
  120270. getOutlineRenderer(): OutlineRenderer;
  120271. }
  120272. interface AbstractMesh {
  120273. /** @hidden (Backing field) */
  120274. _renderOutline: boolean;
  120275. /**
  120276. * Gets or sets a boolean indicating if the outline must be rendered as well
  120277. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  120278. */
  120279. renderOutline: boolean;
  120280. /** @hidden (Backing field) */
  120281. _renderOverlay: boolean;
  120282. /**
  120283. * Gets or sets a boolean indicating if the overlay must be rendered as well
  120284. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  120285. */
  120286. renderOverlay: boolean;
  120287. }
  120288. /**
  120289. * This class is responsible to draw bothe outline/overlay of meshes.
  120290. * It should not be used directly but through the available method on mesh.
  120291. */
  120292. export class OutlineRenderer implements ISceneComponent {
  120293. /**
  120294. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  120295. */
  120296. private static _StencilReference;
  120297. /**
  120298. * The name of the component. Each component must have a unique name.
  120299. */
  120300. name: string;
  120301. /**
  120302. * The scene the component belongs to.
  120303. */
  120304. scene: Scene;
  120305. /**
  120306. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  120307. */
  120308. zOffset: number;
  120309. private _engine;
  120310. private _effect;
  120311. private _cachedDefines;
  120312. private _savedDepthWrite;
  120313. /**
  120314. * Instantiates a new outline renderer. (There could be only one per scene).
  120315. * @param scene Defines the scene it belongs to
  120316. */
  120317. constructor(scene: Scene);
  120318. /**
  120319. * Register the component to one instance of a scene.
  120320. */
  120321. register(): void;
  120322. /**
  120323. * Rebuilds the elements related to this component in case of
  120324. * context lost for instance.
  120325. */
  120326. rebuild(): void;
  120327. /**
  120328. * Disposes the component and the associated ressources.
  120329. */
  120330. dispose(): void;
  120331. /**
  120332. * Renders the outline in the canvas.
  120333. * @param subMesh Defines the sumesh to render
  120334. * @param batch Defines the batch of meshes in case of instances
  120335. * @param useOverlay Defines if the rendering is for the overlay or the outline
  120336. */
  120337. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  120338. /**
  120339. * Returns whether or not the outline renderer is ready for a given submesh.
  120340. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  120341. * @param subMesh Defines the submesh to check readyness for
  120342. * @param useInstances Defines wheter wee are trying to render instances or not
  120343. * @returns true if ready otherwise false
  120344. */
  120345. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  120346. private _beforeRenderingMesh;
  120347. private _afterRenderingMesh;
  120348. }
  120349. }
  120350. declare module BABYLON {
  120351. /**
  120352. * Defines the list of states available for a task inside a AssetsManager
  120353. */
  120354. export enum AssetTaskState {
  120355. /**
  120356. * Initialization
  120357. */
  120358. INIT = 0,
  120359. /**
  120360. * Running
  120361. */
  120362. RUNNING = 1,
  120363. /**
  120364. * Done
  120365. */
  120366. DONE = 2,
  120367. /**
  120368. * Error
  120369. */
  120370. ERROR = 3
  120371. }
  120372. /**
  120373. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  120374. */
  120375. export abstract class AbstractAssetTask {
  120376. /**
  120377. * Task name
  120378. */ name: string;
  120379. /**
  120380. * Callback called when the task is successful
  120381. */
  120382. onSuccess: (task: any) => void;
  120383. /**
  120384. * Callback called when the task is not successful
  120385. */
  120386. onError: (task: any, message?: string, exception?: any) => void;
  120387. /**
  120388. * Creates a new AssetsManager
  120389. * @param name defines the name of the task
  120390. */
  120391. constructor(
  120392. /**
  120393. * Task name
  120394. */ name: string);
  120395. private _isCompleted;
  120396. private _taskState;
  120397. private _errorObject;
  120398. /**
  120399. * Get if the task is completed
  120400. */
  120401. readonly isCompleted: boolean;
  120402. /**
  120403. * Gets the current state of the task
  120404. */
  120405. readonly taskState: AssetTaskState;
  120406. /**
  120407. * Gets the current error object (if task is in error)
  120408. */
  120409. readonly errorObject: {
  120410. message?: string;
  120411. exception?: any;
  120412. };
  120413. /**
  120414. * Internal only
  120415. * @hidden
  120416. */
  120417. _setErrorObject(message?: string, exception?: any): void;
  120418. /**
  120419. * Execute the current task
  120420. * @param scene defines the scene where you want your assets to be loaded
  120421. * @param onSuccess is a callback called when the task is successfully executed
  120422. * @param onError is a callback called if an error occurs
  120423. */
  120424. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120425. /**
  120426. * Execute the current task
  120427. * @param scene defines the scene where you want your assets to be loaded
  120428. * @param onSuccess is a callback called when the task is successfully executed
  120429. * @param onError is a callback called if an error occurs
  120430. */
  120431. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120432. /**
  120433. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  120434. * This can be used with failed tasks that have the reason for failure fixed.
  120435. */
  120436. reset(): void;
  120437. private onErrorCallback;
  120438. private onDoneCallback;
  120439. }
  120440. /**
  120441. * Define the interface used by progress events raised during assets loading
  120442. */
  120443. export interface IAssetsProgressEvent {
  120444. /**
  120445. * Defines the number of remaining tasks to process
  120446. */
  120447. remainingCount: number;
  120448. /**
  120449. * Defines the total number of tasks
  120450. */
  120451. totalCount: number;
  120452. /**
  120453. * Defines the task that was just processed
  120454. */
  120455. task: AbstractAssetTask;
  120456. }
  120457. /**
  120458. * Class used to share progress information about assets loading
  120459. */
  120460. export class AssetsProgressEvent implements IAssetsProgressEvent {
  120461. /**
  120462. * Defines the number of remaining tasks to process
  120463. */
  120464. remainingCount: number;
  120465. /**
  120466. * Defines the total number of tasks
  120467. */
  120468. totalCount: number;
  120469. /**
  120470. * Defines the task that was just processed
  120471. */
  120472. task: AbstractAssetTask;
  120473. /**
  120474. * Creates a AssetsProgressEvent
  120475. * @param remainingCount defines the number of remaining tasks to process
  120476. * @param totalCount defines the total number of tasks
  120477. * @param task defines the task that was just processed
  120478. */
  120479. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  120480. }
  120481. /**
  120482. * Define a task used by AssetsManager to load meshes
  120483. */
  120484. export class MeshAssetTask extends AbstractAssetTask {
  120485. /**
  120486. * Defines the name of the task
  120487. */
  120488. name: string;
  120489. /**
  120490. * Defines the list of mesh's names you want to load
  120491. */
  120492. meshesNames: any;
  120493. /**
  120494. * Defines the root url to use as a base to load your meshes and associated resources
  120495. */
  120496. rootUrl: string;
  120497. /**
  120498. * Defines the filename of the scene to load from
  120499. */
  120500. sceneFilename: string;
  120501. /**
  120502. * Gets the list of loaded meshes
  120503. */
  120504. loadedMeshes: Array<AbstractMesh>;
  120505. /**
  120506. * Gets the list of loaded particle systems
  120507. */
  120508. loadedParticleSystems: Array<IParticleSystem>;
  120509. /**
  120510. * Gets the list of loaded skeletons
  120511. */
  120512. loadedSkeletons: Array<Skeleton>;
  120513. /**
  120514. * Gets the list of loaded animation groups
  120515. */
  120516. loadedAnimationGroups: Array<AnimationGroup>;
  120517. /**
  120518. * Callback called when the task is successful
  120519. */
  120520. onSuccess: (task: MeshAssetTask) => void;
  120521. /**
  120522. * Callback called when the task is successful
  120523. */
  120524. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  120525. /**
  120526. * Creates a new MeshAssetTask
  120527. * @param name defines the name of the task
  120528. * @param meshesNames defines the list of mesh's names you want to load
  120529. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  120530. * @param sceneFilename defines the filename of the scene to load from
  120531. */
  120532. constructor(
  120533. /**
  120534. * Defines the name of the task
  120535. */
  120536. name: string,
  120537. /**
  120538. * Defines the list of mesh's names you want to load
  120539. */
  120540. meshesNames: any,
  120541. /**
  120542. * Defines the root url to use as a base to load your meshes and associated resources
  120543. */
  120544. rootUrl: string,
  120545. /**
  120546. * Defines the filename of the scene to load from
  120547. */
  120548. sceneFilename: string);
  120549. /**
  120550. * Execute the current task
  120551. * @param scene defines the scene where you want your assets to be loaded
  120552. * @param onSuccess is a callback called when the task is successfully executed
  120553. * @param onError is a callback called if an error occurs
  120554. */
  120555. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120556. }
  120557. /**
  120558. * Define a task used by AssetsManager to load text content
  120559. */
  120560. export class TextFileAssetTask extends AbstractAssetTask {
  120561. /**
  120562. * Defines the name of the task
  120563. */
  120564. name: string;
  120565. /**
  120566. * Defines the location of the file to load
  120567. */
  120568. url: string;
  120569. /**
  120570. * Gets the loaded text string
  120571. */
  120572. text: string;
  120573. /**
  120574. * Callback called when the task is successful
  120575. */
  120576. onSuccess: (task: TextFileAssetTask) => void;
  120577. /**
  120578. * Callback called when the task is successful
  120579. */
  120580. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  120581. /**
  120582. * Creates a new TextFileAssetTask object
  120583. * @param name defines the name of the task
  120584. * @param url defines the location of the file to load
  120585. */
  120586. constructor(
  120587. /**
  120588. * Defines the name of the task
  120589. */
  120590. name: string,
  120591. /**
  120592. * Defines the location of the file to load
  120593. */
  120594. url: string);
  120595. /**
  120596. * Execute the current task
  120597. * @param scene defines the scene where you want your assets to be loaded
  120598. * @param onSuccess is a callback called when the task is successfully executed
  120599. * @param onError is a callback called if an error occurs
  120600. */
  120601. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120602. }
  120603. /**
  120604. * Define a task used by AssetsManager to load binary data
  120605. */
  120606. export class BinaryFileAssetTask extends AbstractAssetTask {
  120607. /**
  120608. * Defines the name of the task
  120609. */
  120610. name: string;
  120611. /**
  120612. * Defines the location of the file to load
  120613. */
  120614. url: string;
  120615. /**
  120616. * Gets the lodaded data (as an array buffer)
  120617. */
  120618. data: ArrayBuffer;
  120619. /**
  120620. * Callback called when the task is successful
  120621. */
  120622. onSuccess: (task: BinaryFileAssetTask) => void;
  120623. /**
  120624. * Callback called when the task is successful
  120625. */
  120626. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  120627. /**
  120628. * Creates a new BinaryFileAssetTask object
  120629. * @param name defines the name of the new task
  120630. * @param url defines the location of the file to load
  120631. */
  120632. constructor(
  120633. /**
  120634. * Defines the name of the task
  120635. */
  120636. name: string,
  120637. /**
  120638. * Defines the location of the file to load
  120639. */
  120640. url: string);
  120641. /**
  120642. * Execute the current task
  120643. * @param scene defines the scene where you want your assets to be loaded
  120644. * @param onSuccess is a callback called when the task is successfully executed
  120645. * @param onError is a callback called if an error occurs
  120646. */
  120647. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120648. }
  120649. /**
  120650. * Define a task used by AssetsManager to load images
  120651. */
  120652. export class ImageAssetTask extends AbstractAssetTask {
  120653. /**
  120654. * Defines the name of the task
  120655. */
  120656. name: string;
  120657. /**
  120658. * Defines the location of the image to load
  120659. */
  120660. url: string;
  120661. /**
  120662. * Gets the loaded images
  120663. */
  120664. image: HTMLImageElement;
  120665. /**
  120666. * Callback called when the task is successful
  120667. */
  120668. onSuccess: (task: ImageAssetTask) => void;
  120669. /**
  120670. * Callback called when the task is successful
  120671. */
  120672. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  120673. /**
  120674. * Creates a new ImageAssetTask
  120675. * @param name defines the name of the task
  120676. * @param url defines the location of the image to load
  120677. */
  120678. constructor(
  120679. /**
  120680. * Defines the name of the task
  120681. */
  120682. name: string,
  120683. /**
  120684. * Defines the location of the image to load
  120685. */
  120686. url: string);
  120687. /**
  120688. * Execute the current task
  120689. * @param scene defines the scene where you want your assets to be loaded
  120690. * @param onSuccess is a callback called when the task is successfully executed
  120691. * @param onError is a callback called if an error occurs
  120692. */
  120693. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120694. }
  120695. /**
  120696. * Defines the interface used by texture loading tasks
  120697. */
  120698. export interface ITextureAssetTask<TEX extends BaseTexture> {
  120699. /**
  120700. * Gets the loaded texture
  120701. */
  120702. texture: TEX;
  120703. }
  120704. /**
  120705. * Define a task used by AssetsManager to load 2D textures
  120706. */
  120707. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  120708. /**
  120709. * Defines the name of the task
  120710. */
  120711. name: string;
  120712. /**
  120713. * Defines the location of the file to load
  120714. */
  120715. url: string;
  120716. /**
  120717. * Defines if mipmap should not be generated (default is false)
  120718. */
  120719. noMipmap?: boolean | undefined;
  120720. /**
  120721. * Defines if texture must be inverted on Y axis (default is false)
  120722. */
  120723. invertY?: boolean | undefined;
  120724. /**
  120725. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  120726. */
  120727. samplingMode: number;
  120728. /**
  120729. * Gets the loaded texture
  120730. */
  120731. texture: Texture;
  120732. /**
  120733. * Callback called when the task is successful
  120734. */
  120735. onSuccess: (task: TextureAssetTask) => void;
  120736. /**
  120737. * Callback called when the task is successful
  120738. */
  120739. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  120740. /**
  120741. * Creates a new TextureAssetTask object
  120742. * @param name defines the name of the task
  120743. * @param url defines the location of the file to load
  120744. * @param noMipmap defines if mipmap should not be generated (default is false)
  120745. * @param invertY defines if texture must be inverted on Y axis (default is false)
  120746. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  120747. */
  120748. constructor(
  120749. /**
  120750. * Defines the name of the task
  120751. */
  120752. name: string,
  120753. /**
  120754. * Defines the location of the file to load
  120755. */
  120756. url: string,
  120757. /**
  120758. * Defines if mipmap should not be generated (default is false)
  120759. */
  120760. noMipmap?: boolean | undefined,
  120761. /**
  120762. * Defines if texture must be inverted on Y axis (default is false)
  120763. */
  120764. invertY?: boolean | undefined,
  120765. /**
  120766. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  120767. */
  120768. samplingMode?: number);
  120769. /**
  120770. * Execute the current task
  120771. * @param scene defines the scene where you want your assets to be loaded
  120772. * @param onSuccess is a callback called when the task is successfully executed
  120773. * @param onError is a callback called if an error occurs
  120774. */
  120775. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120776. }
  120777. /**
  120778. * Define a task used by AssetsManager to load cube textures
  120779. */
  120780. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  120781. /**
  120782. * Defines the name of the task
  120783. */
  120784. name: string;
  120785. /**
  120786. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  120787. */
  120788. url: string;
  120789. /**
  120790. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  120791. */
  120792. extensions?: string[] | undefined;
  120793. /**
  120794. * Defines if mipmaps should not be generated (default is false)
  120795. */
  120796. noMipmap?: boolean | undefined;
  120797. /**
  120798. * Defines the explicit list of files (undefined by default)
  120799. */
  120800. files?: string[] | undefined;
  120801. /**
  120802. * Gets the loaded texture
  120803. */
  120804. texture: CubeTexture;
  120805. /**
  120806. * Callback called when the task is successful
  120807. */
  120808. onSuccess: (task: CubeTextureAssetTask) => void;
  120809. /**
  120810. * Callback called when the task is successful
  120811. */
  120812. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  120813. /**
  120814. * Creates a new CubeTextureAssetTask
  120815. * @param name defines the name of the task
  120816. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  120817. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  120818. * @param noMipmap defines if mipmaps should not be generated (default is false)
  120819. * @param files defines the explicit list of files (undefined by default)
  120820. */
  120821. constructor(
  120822. /**
  120823. * Defines the name of the task
  120824. */
  120825. name: string,
  120826. /**
  120827. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  120828. */
  120829. url: string,
  120830. /**
  120831. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  120832. */
  120833. extensions?: string[] | undefined,
  120834. /**
  120835. * Defines if mipmaps should not be generated (default is false)
  120836. */
  120837. noMipmap?: boolean | undefined,
  120838. /**
  120839. * Defines the explicit list of files (undefined by default)
  120840. */
  120841. files?: string[] | undefined);
  120842. /**
  120843. * Execute the current task
  120844. * @param scene defines the scene where you want your assets to be loaded
  120845. * @param onSuccess is a callback called when the task is successfully executed
  120846. * @param onError is a callback called if an error occurs
  120847. */
  120848. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120849. }
  120850. /**
  120851. * Define a task used by AssetsManager to load HDR cube textures
  120852. */
  120853. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  120854. /**
  120855. * Defines the name of the task
  120856. */
  120857. name: string;
  120858. /**
  120859. * Defines the location of the file to load
  120860. */
  120861. url: string;
  120862. /**
  120863. * Defines the desired size (the more it increases the longer the generation will be)
  120864. */
  120865. size: number;
  120866. /**
  120867. * Defines if mipmaps should not be generated (default is false)
  120868. */
  120869. noMipmap: boolean;
  120870. /**
  120871. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  120872. */
  120873. generateHarmonics: boolean;
  120874. /**
  120875. * 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)
  120876. */
  120877. gammaSpace: boolean;
  120878. /**
  120879. * Internal Use Only
  120880. */
  120881. reserved: boolean;
  120882. /**
  120883. * Gets the loaded texture
  120884. */
  120885. texture: HDRCubeTexture;
  120886. /**
  120887. * Callback called when the task is successful
  120888. */
  120889. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  120890. /**
  120891. * Callback called when the task is successful
  120892. */
  120893. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  120894. /**
  120895. * Creates a new HDRCubeTextureAssetTask object
  120896. * @param name defines the name of the task
  120897. * @param url defines the location of the file to load
  120898. * @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.
  120899. * @param noMipmap defines if mipmaps should not be generated (default is false)
  120900. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  120901. * @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)
  120902. * @param reserved Internal use only
  120903. */
  120904. constructor(
  120905. /**
  120906. * Defines the name of the task
  120907. */
  120908. name: string,
  120909. /**
  120910. * Defines the location of the file to load
  120911. */
  120912. url: string,
  120913. /**
  120914. * Defines the desired size (the more it increases the longer the generation will be)
  120915. */
  120916. size: number,
  120917. /**
  120918. * Defines if mipmaps should not be generated (default is false)
  120919. */
  120920. noMipmap?: boolean,
  120921. /**
  120922. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  120923. */
  120924. generateHarmonics?: boolean,
  120925. /**
  120926. * 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)
  120927. */
  120928. gammaSpace?: boolean,
  120929. /**
  120930. * Internal Use Only
  120931. */
  120932. reserved?: boolean);
  120933. /**
  120934. * Execute the current task
  120935. * @param scene defines the scene where you want your assets to be loaded
  120936. * @param onSuccess is a callback called when the task is successfully executed
  120937. * @param onError is a callback called if an error occurs
  120938. */
  120939. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  120940. }
  120941. /**
  120942. * Define a task used by AssetsManager to load Equirectangular cube textures
  120943. */
  120944. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  120945. /**
  120946. * Defines the name of the task
  120947. */
  120948. name: string;
  120949. /**
  120950. * Defines the location of the file to load
  120951. */
  120952. url: string;
  120953. /**
  120954. * Defines the desired size (the more it increases the longer the generation will be)
  120955. */
  120956. size: number;
  120957. /**
  120958. * Defines if mipmaps should not be generated (default is false)
  120959. */
  120960. noMipmap: boolean;
  120961. /**
  120962. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  120963. * but the standard material would require them in Gamma space) (default is true)
  120964. */
  120965. gammaSpace: boolean;
  120966. /**
  120967. * Gets the loaded texture
  120968. */
  120969. texture: EquiRectangularCubeTexture;
  120970. /**
  120971. * Callback called when the task is successful
  120972. */
  120973. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  120974. /**
  120975. * Callback called when the task is successful
  120976. */
  120977. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  120978. /**
  120979. * Creates a new EquiRectangularCubeTextureAssetTask object
  120980. * @param name defines the name of the task
  120981. * @param url defines the location of the file to load
  120982. * @param size defines the desired size (the more it increases the longer the generation will be)
  120983. * If the size is omitted this implies you are using a preprocessed cubemap.
  120984. * @param noMipmap defines if mipmaps should not be generated (default is false)
  120985. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  120986. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  120987. * (default is true)
  120988. */
  120989. constructor(
  120990. /**
  120991. * Defines the name of the task
  120992. */
  120993. name: string,
  120994. /**
  120995. * Defines the location of the file to load
  120996. */
  120997. url: string,
  120998. /**
  120999. * Defines the desired size (the more it increases the longer the generation will be)
  121000. */
  121001. size: number,
  121002. /**
  121003. * Defines if mipmaps should not be generated (default is false)
  121004. */
  121005. noMipmap?: boolean,
  121006. /**
  121007. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  121008. * but the standard material would require them in Gamma space) (default is true)
  121009. */
  121010. gammaSpace?: boolean);
  121011. /**
  121012. * Execute the current task
  121013. * @param scene defines the scene where you want your assets to be loaded
  121014. * @param onSuccess is a callback called when the task is successfully executed
  121015. * @param onError is a callback called if an error occurs
  121016. */
  121017. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  121018. }
  121019. /**
  121020. * This class can be used to easily import assets into a scene
  121021. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  121022. */
  121023. export class AssetsManager {
  121024. private _scene;
  121025. private _isLoading;
  121026. protected _tasks: AbstractAssetTask[];
  121027. protected _waitingTasksCount: number;
  121028. protected _totalTasksCount: number;
  121029. /**
  121030. * Callback called when all tasks are processed
  121031. */
  121032. onFinish: (tasks: AbstractAssetTask[]) => void;
  121033. /**
  121034. * Callback called when a task is successful
  121035. */
  121036. onTaskSuccess: (task: AbstractAssetTask) => void;
  121037. /**
  121038. * Callback called when a task had an error
  121039. */
  121040. onTaskError: (task: AbstractAssetTask) => void;
  121041. /**
  121042. * Callback called when a task is done (whatever the result is)
  121043. */
  121044. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  121045. /**
  121046. * Observable called when all tasks are processed
  121047. */
  121048. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  121049. /**
  121050. * Observable called when a task had an error
  121051. */
  121052. onTaskErrorObservable: Observable<AbstractAssetTask>;
  121053. /**
  121054. * Observable called when all tasks were executed
  121055. */
  121056. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  121057. /**
  121058. * Observable called when a task is done (whatever the result is)
  121059. */
  121060. onProgressObservable: Observable<IAssetsProgressEvent>;
  121061. /**
  121062. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  121063. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121064. */
  121065. useDefaultLoadingScreen: boolean;
  121066. /**
  121067. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  121068. * when all assets have been downloaded.
  121069. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  121070. */
  121071. autoHideLoadingUI: boolean;
  121072. /**
  121073. * Creates a new AssetsManager
  121074. * @param scene defines the scene to work on
  121075. */
  121076. constructor(scene: Scene);
  121077. /**
  121078. * Add a MeshAssetTask to the list of active tasks
  121079. * @param taskName defines the name of the new task
  121080. * @param meshesNames defines the name of meshes to load
  121081. * @param rootUrl defines the root url to use to locate files
  121082. * @param sceneFilename defines the filename of the scene file
  121083. * @returns a new MeshAssetTask object
  121084. */
  121085. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  121086. /**
  121087. * Add a TextFileAssetTask to the list of active tasks
  121088. * @param taskName defines the name of the new task
  121089. * @param url defines the url of the file to load
  121090. * @returns a new TextFileAssetTask object
  121091. */
  121092. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  121093. /**
  121094. * Add a BinaryFileAssetTask to the list of active tasks
  121095. * @param taskName defines the name of the new task
  121096. * @param url defines the url of the file to load
  121097. * @returns a new BinaryFileAssetTask object
  121098. */
  121099. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  121100. /**
  121101. * Add a ImageAssetTask to the list of active tasks
  121102. * @param taskName defines the name of the new task
  121103. * @param url defines the url of the file to load
  121104. * @returns a new ImageAssetTask object
  121105. */
  121106. addImageTask(taskName: string, url: string): ImageAssetTask;
  121107. /**
  121108. * Add a TextureAssetTask to the list of active tasks
  121109. * @param taskName defines the name of the new task
  121110. * @param url defines the url of the file to load
  121111. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  121112. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  121113. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  121114. * @returns a new TextureAssetTask object
  121115. */
  121116. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  121117. /**
  121118. * Add a CubeTextureAssetTask to the list of active tasks
  121119. * @param taskName defines the name of the new task
  121120. * @param url defines the url of the file to load
  121121. * @param extensions defines the extension to use to load the cube map (can be null)
  121122. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  121123. * @param files defines the list of files to load (can be null)
  121124. * @returns a new CubeTextureAssetTask object
  121125. */
  121126. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  121127. /**
  121128. *
  121129. * Add a HDRCubeTextureAssetTask to the list of active tasks
  121130. * @param taskName defines the name of the new task
  121131. * @param url defines the url of the file to load
  121132. * @param size defines the size you want for the cubemap (can be null)
  121133. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  121134. * @param generateHarmonics defines if you want to automatically generate (true by default)
  121135. * @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)
  121136. * @param reserved Internal use only
  121137. * @returns a new HDRCubeTextureAssetTask object
  121138. */
  121139. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  121140. /**
  121141. *
  121142. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  121143. * @param taskName defines the name of the new task
  121144. * @param url defines the url of the file to load
  121145. * @param size defines the size you want for the cubemap (can be null)
  121146. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  121147. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  121148. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  121149. * @returns a new EquiRectangularCubeTextureAssetTask object
  121150. */
  121151. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  121152. /**
  121153. * Remove a task from the assets manager.
  121154. * @param task the task to remove
  121155. */
  121156. removeTask(task: AbstractAssetTask): void;
  121157. private _decreaseWaitingTasksCount;
  121158. private _runTask;
  121159. /**
  121160. * Reset the AssetsManager and remove all tasks
  121161. * @return the current instance of the AssetsManager
  121162. */
  121163. reset(): AssetsManager;
  121164. /**
  121165. * Start the loading process
  121166. * @return the current instance of the AssetsManager
  121167. */
  121168. load(): AssetsManager;
  121169. /**
  121170. * Start the loading process as an async operation
  121171. * @return a promise returning the list of failed tasks
  121172. */
  121173. loadAsync(): Promise<void>;
  121174. }
  121175. }
  121176. declare module BABYLON {
  121177. /**
  121178. * Wrapper class for promise with external resolve and reject.
  121179. */
  121180. export class Deferred<T> {
  121181. /**
  121182. * The promise associated with this deferred object.
  121183. */
  121184. readonly promise: Promise<T>;
  121185. private _resolve;
  121186. private _reject;
  121187. /**
  121188. * The resolve method of the promise associated with this deferred object.
  121189. */
  121190. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  121191. /**
  121192. * The reject method of the promise associated with this deferred object.
  121193. */
  121194. readonly reject: (reason?: any) => void;
  121195. /**
  121196. * Constructor for this deferred object.
  121197. */
  121198. constructor();
  121199. }
  121200. }
  121201. declare module BABYLON {
  121202. /**
  121203. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  121204. */
  121205. export class MeshExploder {
  121206. private _centerMesh;
  121207. private _meshes;
  121208. private _meshesOrigins;
  121209. private _toCenterVectors;
  121210. private _scaledDirection;
  121211. private _newPosition;
  121212. private _centerPosition;
  121213. /**
  121214. * Explodes meshes from a center mesh.
  121215. * @param meshes The meshes to explode.
  121216. * @param centerMesh The mesh to be center of explosion.
  121217. */
  121218. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  121219. private _setCenterMesh;
  121220. /**
  121221. * Get class name
  121222. * @returns "MeshExploder"
  121223. */
  121224. getClassName(): string;
  121225. /**
  121226. * "Exploded meshes"
  121227. * @returns Array of meshes with the centerMesh at index 0.
  121228. */
  121229. getMeshes(): Array<Mesh>;
  121230. /**
  121231. * Explodes meshes giving a specific direction
  121232. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  121233. */
  121234. explode(direction?: number): void;
  121235. }
  121236. }
  121237. declare module BABYLON {
  121238. /**
  121239. * Class used to help managing file picking and drag'n'drop
  121240. */
  121241. export class FilesInput {
  121242. /**
  121243. * List of files ready to be loaded
  121244. */
  121245. static readonly FilesToLoad: {
  121246. [key: string]: File;
  121247. };
  121248. /**
  121249. * Callback called when a file is processed
  121250. */
  121251. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  121252. private _engine;
  121253. private _currentScene;
  121254. private _sceneLoadedCallback;
  121255. private _progressCallback;
  121256. private _additionalRenderLoopLogicCallback;
  121257. private _textureLoadingCallback;
  121258. private _startingProcessingFilesCallback;
  121259. private _onReloadCallback;
  121260. private _errorCallback;
  121261. private _elementToMonitor;
  121262. private _sceneFileToLoad;
  121263. private _filesToLoad;
  121264. /**
  121265. * Creates a new FilesInput
  121266. * @param engine defines the rendering engine
  121267. * @param scene defines the hosting scene
  121268. * @param sceneLoadedCallback callback called when scene is loaded
  121269. * @param progressCallback callback called to track progress
  121270. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  121271. * @param textureLoadingCallback callback called when a texture is loading
  121272. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  121273. * @param onReloadCallback callback called when a reload is requested
  121274. * @param errorCallback callback call if an error occurs
  121275. */
  121276. 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);
  121277. private _dragEnterHandler;
  121278. private _dragOverHandler;
  121279. private _dropHandler;
  121280. /**
  121281. * Calls this function to listen to drag'n'drop events on a specific DOM element
  121282. * @param elementToMonitor defines the DOM element to track
  121283. */
  121284. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  121285. /**
  121286. * Release all associated resources
  121287. */
  121288. dispose(): void;
  121289. private renderFunction;
  121290. private drag;
  121291. private drop;
  121292. private _traverseFolder;
  121293. private _processFiles;
  121294. /**
  121295. * Load files from a drop event
  121296. * @param event defines the drop event to use as source
  121297. */
  121298. loadFiles(event: any): void;
  121299. private _processReload;
  121300. /**
  121301. * Reload the current scene from the loaded files
  121302. */
  121303. reload(): void;
  121304. }
  121305. }
  121306. declare module BABYLON {
  121307. /**
  121308. * Defines the root class used to create scene optimization to use with SceneOptimizer
  121309. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121310. */
  121311. export class SceneOptimization {
  121312. /**
  121313. * Defines the priority of this optimization (0 by default which means first in the list)
  121314. */
  121315. priority: number;
  121316. /**
  121317. * Gets a string describing the action executed by the current optimization
  121318. * @returns description string
  121319. */
  121320. getDescription(): string;
  121321. /**
  121322. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121323. * @param scene defines the current scene where to apply this optimization
  121324. * @param optimizer defines the current optimizer
  121325. * @returns true if everything that can be done was applied
  121326. */
  121327. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121328. /**
  121329. * Creates the SceneOptimization object
  121330. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121331. * @param desc defines the description associated with the optimization
  121332. */
  121333. constructor(
  121334. /**
  121335. * Defines the priority of this optimization (0 by default which means first in the list)
  121336. */
  121337. priority?: number);
  121338. }
  121339. /**
  121340. * Defines an optimization used to reduce the size of render target textures
  121341. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121342. */
  121343. export class TextureOptimization extends SceneOptimization {
  121344. /**
  121345. * Defines the priority of this optimization (0 by default which means first in the list)
  121346. */
  121347. priority: number;
  121348. /**
  121349. * 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
  121350. */
  121351. maximumSize: number;
  121352. /**
  121353. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  121354. */
  121355. step: number;
  121356. /**
  121357. * Gets a string describing the action executed by the current optimization
  121358. * @returns description string
  121359. */
  121360. getDescription(): string;
  121361. /**
  121362. * Creates the TextureOptimization object
  121363. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121364. * @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
  121365. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  121366. */
  121367. constructor(
  121368. /**
  121369. * Defines the priority of this optimization (0 by default which means first in the list)
  121370. */
  121371. priority?: number,
  121372. /**
  121373. * 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
  121374. */
  121375. maximumSize?: number,
  121376. /**
  121377. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  121378. */
  121379. step?: number);
  121380. /**
  121381. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121382. * @param scene defines the current scene where to apply this optimization
  121383. * @param optimizer defines the current optimizer
  121384. * @returns true if everything that can be done was applied
  121385. */
  121386. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121387. }
  121388. /**
  121389. * Defines an optimization used to increase or decrease the rendering resolution
  121390. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121391. */
  121392. export class HardwareScalingOptimization extends SceneOptimization {
  121393. /**
  121394. * Defines the priority of this optimization (0 by default which means first in the list)
  121395. */
  121396. priority: number;
  121397. /**
  121398. * Defines the maximum scale to use (2 by default)
  121399. */
  121400. maximumScale: number;
  121401. /**
  121402. * Defines the step to use between two passes (0.5 by default)
  121403. */
  121404. step: number;
  121405. private _currentScale;
  121406. private _directionOffset;
  121407. /**
  121408. * Gets a string describing the action executed by the current optimization
  121409. * @return description string
  121410. */
  121411. getDescription(): string;
  121412. /**
  121413. * Creates the HardwareScalingOptimization object
  121414. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121415. * @param maximumScale defines the maximum scale to use (2 by default)
  121416. * @param step defines the step to use between two passes (0.5 by default)
  121417. */
  121418. constructor(
  121419. /**
  121420. * Defines the priority of this optimization (0 by default which means first in the list)
  121421. */
  121422. priority?: number,
  121423. /**
  121424. * Defines the maximum scale to use (2 by default)
  121425. */
  121426. maximumScale?: number,
  121427. /**
  121428. * Defines the step to use between two passes (0.5 by default)
  121429. */
  121430. step?: number);
  121431. /**
  121432. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121433. * @param scene defines the current scene where to apply this optimization
  121434. * @param optimizer defines the current optimizer
  121435. * @returns true if everything that can be done was applied
  121436. */
  121437. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121438. }
  121439. /**
  121440. * Defines an optimization used to remove shadows
  121441. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121442. */
  121443. export class ShadowsOptimization extends SceneOptimization {
  121444. /**
  121445. * Gets a string describing the action executed by the current optimization
  121446. * @return description string
  121447. */
  121448. getDescription(): string;
  121449. /**
  121450. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121451. * @param scene defines the current scene where to apply this optimization
  121452. * @param optimizer defines the current optimizer
  121453. * @returns true if everything that can be done was applied
  121454. */
  121455. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121456. }
  121457. /**
  121458. * Defines an optimization used to turn post-processes off
  121459. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121460. */
  121461. export class PostProcessesOptimization extends SceneOptimization {
  121462. /**
  121463. * Gets a string describing the action executed by the current optimization
  121464. * @return description string
  121465. */
  121466. getDescription(): string;
  121467. /**
  121468. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121469. * @param scene defines the current scene where to apply this optimization
  121470. * @param optimizer defines the current optimizer
  121471. * @returns true if everything that can be done was applied
  121472. */
  121473. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121474. }
  121475. /**
  121476. * Defines an optimization used to turn lens flares off
  121477. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121478. */
  121479. export class LensFlaresOptimization extends SceneOptimization {
  121480. /**
  121481. * Gets a string describing the action executed by the current optimization
  121482. * @return description string
  121483. */
  121484. getDescription(): string;
  121485. /**
  121486. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121487. * @param scene defines the current scene where to apply this optimization
  121488. * @param optimizer defines the current optimizer
  121489. * @returns true if everything that can be done was applied
  121490. */
  121491. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121492. }
  121493. /**
  121494. * Defines an optimization based on user defined callback.
  121495. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121496. */
  121497. export class CustomOptimization extends SceneOptimization {
  121498. /**
  121499. * Callback called to apply the custom optimization.
  121500. */
  121501. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  121502. /**
  121503. * Callback called to get custom description
  121504. */
  121505. onGetDescription: () => string;
  121506. /**
  121507. * Gets a string describing the action executed by the current optimization
  121508. * @returns description string
  121509. */
  121510. getDescription(): string;
  121511. /**
  121512. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121513. * @param scene defines the current scene where to apply this optimization
  121514. * @param optimizer defines the current optimizer
  121515. * @returns true if everything that can be done was applied
  121516. */
  121517. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121518. }
  121519. /**
  121520. * Defines an optimization used to turn particles off
  121521. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121522. */
  121523. export class ParticlesOptimization extends SceneOptimization {
  121524. /**
  121525. * Gets a string describing the action executed by the current optimization
  121526. * @return description string
  121527. */
  121528. getDescription(): string;
  121529. /**
  121530. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121531. * @param scene defines the current scene where to apply this optimization
  121532. * @param optimizer defines the current optimizer
  121533. * @returns true if everything that can be done was applied
  121534. */
  121535. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121536. }
  121537. /**
  121538. * Defines an optimization used to turn render targets off
  121539. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121540. */
  121541. export class RenderTargetsOptimization extends SceneOptimization {
  121542. /**
  121543. * Gets a string describing the action executed by the current optimization
  121544. * @return description string
  121545. */
  121546. getDescription(): string;
  121547. /**
  121548. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121549. * @param scene defines the current scene where to apply this optimization
  121550. * @param optimizer defines the current optimizer
  121551. * @returns true if everything that can be done was applied
  121552. */
  121553. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  121554. }
  121555. /**
  121556. * Defines an optimization used to merge meshes with compatible materials
  121557. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121558. */
  121559. export class MergeMeshesOptimization extends SceneOptimization {
  121560. private static _UpdateSelectionTree;
  121561. /**
  121562. * Gets or sets a boolean which defines if optimization octree has to be updated
  121563. */
  121564. /**
  121565. * Gets or sets a boolean which defines if optimization octree has to be updated
  121566. */
  121567. static UpdateSelectionTree: boolean;
  121568. /**
  121569. * Gets a string describing the action executed by the current optimization
  121570. * @return description string
  121571. */
  121572. getDescription(): string;
  121573. private _canBeMerged;
  121574. /**
  121575. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  121576. * @param scene defines the current scene where to apply this optimization
  121577. * @param optimizer defines the current optimizer
  121578. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  121579. * @returns true if everything that can be done was applied
  121580. */
  121581. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  121582. }
  121583. /**
  121584. * Defines a list of options used by SceneOptimizer
  121585. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121586. */
  121587. export class SceneOptimizerOptions {
  121588. /**
  121589. * Defines the target frame rate to reach (60 by default)
  121590. */
  121591. targetFrameRate: number;
  121592. /**
  121593. * Defines the interval between two checkes (2000ms by default)
  121594. */
  121595. trackerDuration: number;
  121596. /**
  121597. * Gets the list of optimizations to apply
  121598. */
  121599. optimizations: SceneOptimization[];
  121600. /**
  121601. * Creates a new list of options used by SceneOptimizer
  121602. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  121603. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  121604. */
  121605. constructor(
  121606. /**
  121607. * Defines the target frame rate to reach (60 by default)
  121608. */
  121609. targetFrameRate?: number,
  121610. /**
  121611. * Defines the interval between two checkes (2000ms by default)
  121612. */
  121613. trackerDuration?: number);
  121614. /**
  121615. * Add a new optimization
  121616. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  121617. * @returns the current SceneOptimizerOptions
  121618. */
  121619. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  121620. /**
  121621. * Add a new custom optimization
  121622. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  121623. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  121624. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  121625. * @returns the current SceneOptimizerOptions
  121626. */
  121627. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  121628. /**
  121629. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  121630. * @param targetFrameRate defines the target frame rate (60 by default)
  121631. * @returns a SceneOptimizerOptions object
  121632. */
  121633. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  121634. /**
  121635. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  121636. * @param targetFrameRate defines the target frame rate (60 by default)
  121637. * @returns a SceneOptimizerOptions object
  121638. */
  121639. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  121640. /**
  121641. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  121642. * @param targetFrameRate defines the target frame rate (60 by default)
  121643. * @returns a SceneOptimizerOptions object
  121644. */
  121645. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  121646. }
  121647. /**
  121648. * Class used to run optimizations in order to reach a target frame rate
  121649. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  121650. */
  121651. export class SceneOptimizer implements IDisposable {
  121652. private _isRunning;
  121653. private _options;
  121654. private _scene;
  121655. private _currentPriorityLevel;
  121656. private _targetFrameRate;
  121657. private _trackerDuration;
  121658. private _currentFrameRate;
  121659. private _sceneDisposeObserver;
  121660. private _improvementMode;
  121661. /**
  121662. * Defines an observable called when the optimizer reaches the target frame rate
  121663. */
  121664. onSuccessObservable: Observable<SceneOptimizer>;
  121665. /**
  121666. * Defines an observable called when the optimizer enables an optimization
  121667. */
  121668. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  121669. /**
  121670. * Defines an observable called when the optimizer is not able to reach the target frame rate
  121671. */
  121672. onFailureObservable: Observable<SceneOptimizer>;
  121673. /**
  121674. * Gets a boolean indicating if the optimizer is in improvement mode
  121675. */
  121676. readonly isInImprovementMode: boolean;
  121677. /**
  121678. * Gets the current priority level (0 at start)
  121679. */
  121680. readonly currentPriorityLevel: number;
  121681. /**
  121682. * Gets the current frame rate checked by the SceneOptimizer
  121683. */
  121684. readonly currentFrameRate: number;
  121685. /**
  121686. * Gets or sets the current target frame rate (60 by default)
  121687. */
  121688. /**
  121689. * Gets or sets the current target frame rate (60 by default)
  121690. */
  121691. targetFrameRate: number;
  121692. /**
  121693. * Gets or sets the current interval between two checks (every 2000ms by default)
  121694. */
  121695. /**
  121696. * Gets or sets the current interval between two checks (every 2000ms by default)
  121697. */
  121698. trackerDuration: number;
  121699. /**
  121700. * Gets the list of active optimizations
  121701. */
  121702. readonly optimizations: SceneOptimization[];
  121703. /**
  121704. * Creates a new SceneOptimizer
  121705. * @param scene defines the scene to work on
  121706. * @param options defines the options to use with the SceneOptimizer
  121707. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  121708. * @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)
  121709. */
  121710. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  121711. /**
  121712. * Stops the current optimizer
  121713. */
  121714. stop(): void;
  121715. /**
  121716. * Reset the optimizer to initial step (current priority level = 0)
  121717. */
  121718. reset(): void;
  121719. /**
  121720. * Start the optimizer. By default it will try to reach a specific framerate
  121721. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  121722. */
  121723. start(): void;
  121724. private _checkCurrentState;
  121725. /**
  121726. * Release all resources
  121727. */
  121728. dispose(): void;
  121729. /**
  121730. * Helper function to create a SceneOptimizer with one single line of code
  121731. * @param scene defines the scene to work on
  121732. * @param options defines the options to use with the SceneOptimizer
  121733. * @param onSuccess defines a callback to call on success
  121734. * @param onFailure defines a callback to call on failure
  121735. * @returns the new SceneOptimizer object
  121736. */
  121737. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  121738. }
  121739. }
  121740. declare module BABYLON {
  121741. /**
  121742. * Class used to serialize a scene into a string
  121743. */
  121744. export class SceneSerializer {
  121745. /**
  121746. * Clear cache used by a previous serialization
  121747. */
  121748. static ClearCache(): void;
  121749. /**
  121750. * Serialize a scene into a JSON compatible object
  121751. * @param scene defines the scene to serialize
  121752. * @returns a JSON compatible object
  121753. */
  121754. static Serialize(scene: Scene): any;
  121755. /**
  121756. * Serialize a mesh into a JSON compatible object
  121757. * @param toSerialize defines the mesh to serialize
  121758. * @param withParents defines if parents must be serialized as well
  121759. * @param withChildren defines if children must be serialized as well
  121760. * @returns a JSON compatible object
  121761. */
  121762. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  121763. }
  121764. }
  121765. declare module BABYLON {
  121766. /**
  121767. * Class used to host texture specific utilities
  121768. */
  121769. export class TextureTools {
  121770. /**
  121771. * Uses the GPU to create a copy texture rescaled at a given size
  121772. * @param texture Texture to copy from
  121773. * @param width defines the desired width
  121774. * @param height defines the desired height
  121775. * @param useBilinearMode defines if bilinear mode has to be used
  121776. * @return the generated texture
  121777. */
  121778. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  121779. }
  121780. }
  121781. declare module BABYLON {
  121782. /**
  121783. * This represents the different options available for the video capture.
  121784. */
  121785. export interface VideoRecorderOptions {
  121786. /** Defines the mime type of the video. */
  121787. mimeType: string;
  121788. /** Defines the FPS the video should be recorded at. */
  121789. fps: number;
  121790. /** Defines the chunk size for the recording data. */
  121791. recordChunckSize: number;
  121792. /** The audio tracks to attach to the recording. */
  121793. audioTracks?: MediaStreamTrack[];
  121794. }
  121795. /**
  121796. * This can help with recording videos from BabylonJS.
  121797. * This is based on the available WebRTC functionalities of the browser.
  121798. *
  121799. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  121800. */
  121801. export class VideoRecorder {
  121802. private static readonly _defaultOptions;
  121803. /**
  121804. * Returns whether or not the VideoRecorder is available in your browser.
  121805. * @param engine Defines the Babylon Engine.
  121806. * @returns true if supported otherwise false.
  121807. */
  121808. static IsSupported(engine: Engine): boolean;
  121809. private readonly _options;
  121810. private _canvas;
  121811. private _mediaRecorder;
  121812. private _recordedChunks;
  121813. private _fileName;
  121814. private _resolve;
  121815. private _reject;
  121816. /**
  121817. * True when a recording is already in progress.
  121818. */
  121819. readonly isRecording: boolean;
  121820. /**
  121821. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  121822. * @param engine Defines the BabylonJS Engine you wish to record.
  121823. * @param options Defines options that can be used to customize the capture.
  121824. */
  121825. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  121826. /**
  121827. * Stops the current recording before the default capture timeout passed in the startRecording function.
  121828. */
  121829. stopRecording(): void;
  121830. /**
  121831. * Starts recording the canvas for a max duration specified in parameters.
  121832. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  121833. * If null no automatic download will start and you can rely on the promise to get the data back.
  121834. * @param maxDuration Defines the maximum recording time in seconds.
  121835. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  121836. * @return A promise callback at the end of the recording with the video data in Blob.
  121837. */
  121838. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  121839. /**
  121840. * Releases internal resources used during the recording.
  121841. */
  121842. dispose(): void;
  121843. private _handleDataAvailable;
  121844. private _handleError;
  121845. private _handleStop;
  121846. }
  121847. }
  121848. declare module BABYLON {
  121849. /**
  121850. * Class containing a set of static utilities functions for screenshots
  121851. */
  121852. export class ScreenshotTools {
  121853. /**
  121854. * Captures a screenshot of the current rendering
  121855. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  121856. * @param engine defines the rendering engine
  121857. * @param camera defines the source camera
  121858. * @param size This parameter can be set to a single number or to an object with the
  121859. * following (optional) properties: precision, width, height. If a single number is passed,
  121860. * it will be used for both width and height. If an object is passed, the screenshot size
  121861. * will be derived from the parameters. The precision property is a multiplier allowing
  121862. * rendering at a higher or lower resolution
  121863. * @param successCallback defines the callback receives a single parameter which contains the
  121864. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  121865. * src parameter of an <img> to display it
  121866. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  121867. * Check your browser for supported MIME types
  121868. */
  121869. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  121870. /**
  121871. * Generates an image screenshot from the specified camera.
  121872. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  121873. * @param engine The engine to use for rendering
  121874. * @param camera The camera to use for rendering
  121875. * @param size This parameter can be set to a single number or to an object with the
  121876. * following (optional) properties: precision, width, height. If a single number is passed,
  121877. * it will be used for both width and height. If an object is passed, the screenshot size
  121878. * will be derived from the parameters. The precision property is a multiplier allowing
  121879. * rendering at a higher or lower resolution
  121880. * @param successCallback The callback receives a single parameter which contains the
  121881. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  121882. * src parameter of an <img> to display it
  121883. * @param mimeType The MIME type of the screenshot image (default: image/png).
  121884. * Check your browser for supported MIME types
  121885. * @param samples Texture samples (default: 1)
  121886. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  121887. * @param fileName A name for for the downloaded file.
  121888. */
  121889. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  121890. }
  121891. }
  121892. declare module BABYLON {
  121893. /**
  121894. * A cursor which tracks a point on a path
  121895. */
  121896. export class PathCursor {
  121897. private path;
  121898. /**
  121899. * Stores path cursor callbacks for when an onchange event is triggered
  121900. */
  121901. private _onchange;
  121902. /**
  121903. * The value of the path cursor
  121904. */
  121905. value: number;
  121906. /**
  121907. * The animation array of the path cursor
  121908. */
  121909. animations: Animation[];
  121910. /**
  121911. * Initializes the path cursor
  121912. * @param path The path to track
  121913. */
  121914. constructor(path: Path2);
  121915. /**
  121916. * Gets the cursor point on the path
  121917. * @returns A point on the path cursor at the cursor location
  121918. */
  121919. getPoint(): Vector3;
  121920. /**
  121921. * Moves the cursor ahead by the step amount
  121922. * @param step The amount to move the cursor forward
  121923. * @returns This path cursor
  121924. */
  121925. moveAhead(step?: number): PathCursor;
  121926. /**
  121927. * Moves the cursor behind by the step amount
  121928. * @param step The amount to move the cursor back
  121929. * @returns This path cursor
  121930. */
  121931. moveBack(step?: number): PathCursor;
  121932. /**
  121933. * Moves the cursor by the step amount
  121934. * If the step amount is greater than one, an exception is thrown
  121935. * @param step The amount to move the cursor
  121936. * @returns This path cursor
  121937. */
  121938. move(step: number): PathCursor;
  121939. /**
  121940. * Ensures that the value is limited between zero and one
  121941. * @returns This path cursor
  121942. */
  121943. private ensureLimits;
  121944. /**
  121945. * Runs onchange callbacks on change (used by the animation engine)
  121946. * @returns This path cursor
  121947. */
  121948. private raiseOnChange;
  121949. /**
  121950. * Executes a function on change
  121951. * @param f A path cursor onchange callback
  121952. * @returns This path cursor
  121953. */
  121954. onchange(f: (cursor: PathCursor) => void): PathCursor;
  121955. }
  121956. }
  121957. declare module BABYLON {
  121958. /** @hidden */
  121959. export var blurPixelShader: {
  121960. name: string;
  121961. shader: string;
  121962. };
  121963. }
  121964. declare module BABYLON {
  121965. /** @hidden */
  121966. export var pointCloudVertexDeclaration: {
  121967. name: string;
  121968. shader: string;
  121969. };
  121970. }
  121971. // Mixins
  121972. interface Window {
  121973. mozIndexedDB: IDBFactory;
  121974. webkitIndexedDB: IDBFactory;
  121975. msIndexedDB: IDBFactory;
  121976. webkitURL: typeof URL;
  121977. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  121978. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  121979. WebGLRenderingContext: WebGLRenderingContext;
  121980. MSGesture: MSGesture;
  121981. CANNON: any;
  121982. AudioContext: AudioContext;
  121983. webkitAudioContext: AudioContext;
  121984. PointerEvent: any;
  121985. Math: Math;
  121986. Uint8Array: Uint8ArrayConstructor;
  121987. Float32Array: Float32ArrayConstructor;
  121988. mozURL: typeof URL;
  121989. msURL: typeof URL;
  121990. VRFrameData: any; // WebVR, from specs 1.1
  121991. DracoDecoderModule: any;
  121992. setImmediate(handler: (...args: any[]) => void): number;
  121993. }
  121994. interface HTMLCanvasElement {
  121995. requestPointerLock(): void;
  121996. msRequestPointerLock?(): void;
  121997. mozRequestPointerLock?(): void;
  121998. webkitRequestPointerLock?(): void;
  121999. /** Track wether a record is in progress */
  122000. isRecording: boolean;
  122001. /** Capture Stream method defined by some browsers */
  122002. captureStream(fps?: number): MediaStream;
  122003. }
  122004. interface CanvasRenderingContext2D {
  122005. msImageSmoothingEnabled: boolean;
  122006. }
  122007. interface MouseEvent {
  122008. mozMovementX: number;
  122009. mozMovementY: number;
  122010. webkitMovementX: number;
  122011. webkitMovementY: number;
  122012. msMovementX: number;
  122013. msMovementY: number;
  122014. }
  122015. interface Navigator {
  122016. mozGetVRDevices: (any: any) => any;
  122017. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  122018. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  122019. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  122020. webkitGetGamepads(): Gamepad[];
  122021. msGetGamepads(): Gamepad[];
  122022. webkitGamepads(): Gamepad[];
  122023. }
  122024. interface HTMLVideoElement {
  122025. mozSrcObject: any;
  122026. }
  122027. interface Math {
  122028. fround(x: number): number;
  122029. imul(a: number, b: number): number;
  122030. }
  122031. interface WebGLRenderingContext {
  122032. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  122033. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  122034. vertexAttribDivisor(index: number, divisor: number): void;
  122035. createVertexArray(): any;
  122036. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  122037. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  122038. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  122039. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  122040. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  122041. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  122042. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  122043. // Queries
  122044. createQuery(): WebGLQuery;
  122045. deleteQuery(query: WebGLQuery): void;
  122046. beginQuery(target: number, query: WebGLQuery): void;
  122047. endQuery(target: number): void;
  122048. getQueryParameter(query: WebGLQuery, pname: number): any;
  122049. getQuery(target: number, pname: number): any;
  122050. MAX_SAMPLES: number;
  122051. RGBA8: number;
  122052. READ_FRAMEBUFFER: number;
  122053. DRAW_FRAMEBUFFER: number;
  122054. UNIFORM_BUFFER: number;
  122055. HALF_FLOAT_OES: number;
  122056. RGBA16F: number;
  122057. RGBA32F: number;
  122058. R32F: number;
  122059. RG32F: number;
  122060. RGB32F: number;
  122061. R16F: number;
  122062. RG16F: number;
  122063. RGB16F: number;
  122064. RED: number;
  122065. RG: number;
  122066. R8: number;
  122067. RG8: number;
  122068. UNSIGNED_INT_24_8: number;
  122069. DEPTH24_STENCIL8: number;
  122070. /* Multiple Render Targets */
  122071. drawBuffers(buffers: number[]): void;
  122072. readBuffer(src: number): void;
  122073. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  122074. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  122075. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  122076. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  122077. // Occlusion Query
  122078. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  122079. ANY_SAMPLES_PASSED: number;
  122080. QUERY_RESULT_AVAILABLE: number;
  122081. QUERY_RESULT: number;
  122082. }
  122083. interface WebGLProgram {
  122084. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  122085. }
  122086. interface EXT_disjoint_timer_query {
  122087. QUERY_COUNTER_BITS_EXT: number;
  122088. TIME_ELAPSED_EXT: number;
  122089. TIMESTAMP_EXT: number;
  122090. GPU_DISJOINT_EXT: number;
  122091. QUERY_RESULT_EXT: number;
  122092. QUERY_RESULT_AVAILABLE_EXT: number;
  122093. queryCounterEXT(query: WebGLQuery, target: number): void;
  122094. createQueryEXT(): WebGLQuery;
  122095. beginQueryEXT(target: number, query: WebGLQuery): void;
  122096. endQueryEXT(target: number): void;
  122097. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  122098. deleteQueryEXT(query: WebGLQuery): void;
  122099. }
  122100. interface WebGLUniformLocation {
  122101. _currentState: any;
  122102. }
  122103. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  122104. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  122105. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  122106. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  122107. interface WebGLRenderingContext {
  122108. readonly RASTERIZER_DISCARD: number;
  122109. readonly DEPTH_COMPONENT24: number;
  122110. readonly TEXTURE_3D: number;
  122111. readonly TEXTURE_2D_ARRAY: number;
  122112. readonly TEXTURE_COMPARE_FUNC: number;
  122113. readonly TEXTURE_COMPARE_MODE: number;
  122114. readonly COMPARE_REF_TO_TEXTURE: number;
  122115. readonly TEXTURE_WRAP_R: number;
  122116. readonly HALF_FLOAT: number;
  122117. readonly RGB8: number;
  122118. readonly RED_INTEGER: number;
  122119. readonly RG_INTEGER: number;
  122120. readonly RGB_INTEGER: number;
  122121. readonly RGBA_INTEGER: number;
  122122. readonly R8_SNORM: number;
  122123. readonly RG8_SNORM: number;
  122124. readonly RGB8_SNORM: number;
  122125. readonly RGBA8_SNORM: number;
  122126. readonly R8I: number;
  122127. readonly RG8I: number;
  122128. readonly RGB8I: number;
  122129. readonly RGBA8I: number;
  122130. readonly R8UI: number;
  122131. readonly RG8UI: number;
  122132. readonly RGB8UI: number;
  122133. readonly RGBA8UI: number;
  122134. readonly R16I: number;
  122135. readonly RG16I: number;
  122136. readonly RGB16I: number;
  122137. readonly RGBA16I: number;
  122138. readonly R16UI: number;
  122139. readonly RG16UI: number;
  122140. readonly RGB16UI: number;
  122141. readonly RGBA16UI: number;
  122142. readonly R32I: number;
  122143. readonly RG32I: number;
  122144. readonly RGB32I: number;
  122145. readonly RGBA32I: number;
  122146. readonly R32UI: number;
  122147. readonly RG32UI: number;
  122148. readonly RGB32UI: number;
  122149. readonly RGBA32UI: number;
  122150. readonly RGB10_A2UI: number;
  122151. readonly R11F_G11F_B10F: number;
  122152. readonly RGB9_E5: number;
  122153. readonly RGB10_A2: number;
  122154. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  122155. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  122156. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  122157. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  122158. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  122159. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  122160. 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;
  122161. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  122162. readonly TRANSFORM_FEEDBACK: number;
  122163. readonly INTERLEAVED_ATTRIBS: number;
  122164. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  122165. createTransformFeedback(): WebGLTransformFeedback;
  122166. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  122167. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  122168. beginTransformFeedback(primitiveMode: number): void;
  122169. endTransformFeedback(): void;
  122170. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  122171. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  122172. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  122173. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  122174. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  122175. }
  122176. interface ImageBitmap {
  122177. readonly width: number;
  122178. readonly height: number;
  122179. close(): void;
  122180. }
  122181. interface WebGLQuery extends WebGLObject {
  122182. }
  122183. declare var WebGLQuery: {
  122184. prototype: WebGLQuery;
  122185. new(): WebGLQuery;
  122186. };
  122187. interface WebGLSampler extends WebGLObject {
  122188. }
  122189. declare var WebGLSampler: {
  122190. prototype: WebGLSampler;
  122191. new(): WebGLSampler;
  122192. };
  122193. interface WebGLSync extends WebGLObject {
  122194. }
  122195. declare var WebGLSync: {
  122196. prototype: WebGLSync;
  122197. new(): WebGLSync;
  122198. };
  122199. interface WebGLTransformFeedback extends WebGLObject {
  122200. }
  122201. declare var WebGLTransformFeedback: {
  122202. prototype: WebGLTransformFeedback;
  122203. new(): WebGLTransformFeedback;
  122204. };
  122205. interface WebGLVertexArrayObject extends WebGLObject {
  122206. }
  122207. declare var WebGLVertexArrayObject: {
  122208. prototype: WebGLVertexArrayObject;
  122209. new(): WebGLVertexArrayObject;
  122210. };
  122211. // Type definitions for WebVR API
  122212. // Project: https://w3c.github.io/webvr/
  122213. // Definitions by: six a <https://github.com/lostfictions>
  122214. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  122215. interface VRDisplay extends EventTarget {
  122216. /**
  122217. * Dictionary of capabilities describing the VRDisplay.
  122218. */
  122219. readonly capabilities: VRDisplayCapabilities;
  122220. /**
  122221. * z-depth defining the far plane of the eye view frustum
  122222. * enables mapping of values in the render target depth
  122223. * attachment to scene coordinates. Initially set to 10000.0.
  122224. */
  122225. depthFar: number;
  122226. /**
  122227. * z-depth defining the near plane of the eye view frustum
  122228. * enables mapping of values in the render target depth
  122229. * attachment to scene coordinates. Initially set to 0.01.
  122230. */
  122231. depthNear: number;
  122232. /**
  122233. * An identifier for this distinct VRDisplay. Used as an
  122234. * association point in the Gamepad API.
  122235. */
  122236. readonly displayId: number;
  122237. /**
  122238. * A display name, a user-readable name identifying it.
  122239. */
  122240. readonly displayName: string;
  122241. readonly isConnected: boolean;
  122242. readonly isPresenting: boolean;
  122243. /**
  122244. * If this VRDisplay supports room-scale experiences, the optional
  122245. * stage attribute contains details on the room-scale parameters.
  122246. */
  122247. readonly stageParameters: VRStageParameters | null;
  122248. /**
  122249. * Passing the value returned by `requestAnimationFrame` to
  122250. * `cancelAnimationFrame` will unregister the callback.
  122251. * @param handle Define the hanle of the request to cancel
  122252. */
  122253. cancelAnimationFrame(handle: number): void;
  122254. /**
  122255. * Stops presenting to the VRDisplay.
  122256. * @returns a promise to know when it stopped
  122257. */
  122258. exitPresent(): Promise<void>;
  122259. /**
  122260. * Return the current VREyeParameters for the given eye.
  122261. * @param whichEye Define the eye we want the parameter for
  122262. * @returns the eye parameters
  122263. */
  122264. getEyeParameters(whichEye: string): VREyeParameters;
  122265. /**
  122266. * Populates the passed VRFrameData with the information required to render
  122267. * the current frame.
  122268. * @param frameData Define the data structure to populate
  122269. * @returns true if ok otherwise false
  122270. */
  122271. getFrameData(frameData: VRFrameData): boolean;
  122272. /**
  122273. * Get the layers currently being presented.
  122274. * @returns the list of VR layers
  122275. */
  122276. getLayers(): VRLayer[];
  122277. /**
  122278. * Return a VRPose containing the future predicted pose of the VRDisplay
  122279. * when the current frame will be presented. The value returned will not
  122280. * change until JavaScript has returned control to the browser.
  122281. *
  122282. * The VRPose will contain the position, orientation, velocity,
  122283. * and acceleration of each of these properties.
  122284. * @returns the pose object
  122285. */
  122286. getPose(): VRPose;
  122287. /**
  122288. * Return the current instantaneous pose of the VRDisplay, with no
  122289. * prediction applied.
  122290. * @returns the current instantaneous pose
  122291. */
  122292. getImmediatePose(): VRPose;
  122293. /**
  122294. * The callback passed to `requestAnimationFrame` will be called
  122295. * any time a new frame should be rendered. When the VRDisplay is
  122296. * presenting the callback will be called at the native refresh
  122297. * rate of the HMD. When not presenting this function acts
  122298. * identically to how window.requestAnimationFrame acts. Content should
  122299. * make no assumptions of frame rate or vsync behavior as the HMD runs
  122300. * asynchronously from other displays and at differing refresh rates.
  122301. * @param callback Define the eaction to run next frame
  122302. * @returns the request handle it
  122303. */
  122304. requestAnimationFrame(callback: FrameRequestCallback): number;
  122305. /**
  122306. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  122307. * Repeat calls while already presenting will update the VRLayers being displayed.
  122308. * @param layers Define the list of layer to present
  122309. * @returns a promise to know when the request has been fulfilled
  122310. */
  122311. requestPresent(layers: VRLayer[]): Promise<void>;
  122312. /**
  122313. * Reset the pose for this display, treating its current position and
  122314. * orientation as the "origin/zero" values. VRPose.position,
  122315. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  122316. * updated when calling resetPose(). This should be called in only
  122317. * sitting-space experiences.
  122318. */
  122319. resetPose(): void;
  122320. /**
  122321. * The VRLayer provided to the VRDisplay will be captured and presented
  122322. * in the HMD. Calling this function has the same effect on the source
  122323. * canvas as any other operation that uses its source image, and canvases
  122324. * created without preserveDrawingBuffer set to true will be cleared.
  122325. * @param pose Define the pose to submit
  122326. */
  122327. submitFrame(pose?: VRPose): void;
  122328. }
  122329. declare var VRDisplay: {
  122330. prototype: VRDisplay;
  122331. new(): VRDisplay;
  122332. };
  122333. interface VRLayer {
  122334. leftBounds?: number[] | Float32Array | null;
  122335. rightBounds?: number[] | Float32Array | null;
  122336. source?: HTMLCanvasElement | null;
  122337. }
  122338. interface VRDisplayCapabilities {
  122339. readonly canPresent: boolean;
  122340. readonly hasExternalDisplay: boolean;
  122341. readonly hasOrientation: boolean;
  122342. readonly hasPosition: boolean;
  122343. readonly maxLayers: number;
  122344. }
  122345. interface VREyeParameters {
  122346. /** @deprecated */
  122347. readonly fieldOfView: VRFieldOfView;
  122348. readonly offset: Float32Array;
  122349. readonly renderHeight: number;
  122350. readonly renderWidth: number;
  122351. }
  122352. interface VRFieldOfView {
  122353. readonly downDegrees: number;
  122354. readonly leftDegrees: number;
  122355. readonly rightDegrees: number;
  122356. readonly upDegrees: number;
  122357. }
  122358. interface VRFrameData {
  122359. readonly leftProjectionMatrix: Float32Array;
  122360. readonly leftViewMatrix: Float32Array;
  122361. readonly pose: VRPose;
  122362. readonly rightProjectionMatrix: Float32Array;
  122363. readonly rightViewMatrix: Float32Array;
  122364. readonly timestamp: number;
  122365. }
  122366. interface VRPose {
  122367. readonly angularAcceleration: Float32Array | null;
  122368. readonly angularVelocity: Float32Array | null;
  122369. readonly linearAcceleration: Float32Array | null;
  122370. readonly linearVelocity: Float32Array | null;
  122371. readonly orientation: Float32Array | null;
  122372. readonly position: Float32Array | null;
  122373. readonly timestamp: number;
  122374. }
  122375. interface VRStageParameters {
  122376. sittingToStandingTransform?: Float32Array;
  122377. sizeX?: number;
  122378. sizeY?: number;
  122379. }
  122380. interface Navigator {
  122381. getVRDisplays(): Promise<VRDisplay[]>;
  122382. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  122383. }
  122384. interface Window {
  122385. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  122386. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  122387. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  122388. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  122389. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  122390. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  122391. }
  122392. interface Gamepad {
  122393. readonly displayId: number;
  122394. }
  122395. interface XRDevice {
  122396. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  122397. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  122398. }
  122399. interface XRSession {
  122400. getInputSources(): Array<any>;
  122401. baseLayer: XRWebGLLayer;
  122402. requestFrameOfReference(type: string): Promise<void>;
  122403. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  122404. end(): Promise<void>;
  122405. requestAnimationFrame: Function;
  122406. addEventListener: Function;
  122407. }
  122408. interface XRSessionCreationOptions {
  122409. outputContext?: WebGLRenderingContext | null;
  122410. immersive?: boolean;
  122411. environmentIntegration?: boolean;
  122412. }
  122413. interface XRLayer {
  122414. getViewport: Function;
  122415. framebufferWidth: number;
  122416. framebufferHeight: number;
  122417. }
  122418. interface XRView {
  122419. projectionMatrix: Float32Array;
  122420. }
  122421. interface XRFrame {
  122422. getDevicePose: Function;
  122423. getInputPose: Function;
  122424. views: Array<XRView>;
  122425. baseLayer: XRLayer;
  122426. }
  122427. interface XRFrameOfReference {
  122428. }
  122429. interface XRWebGLLayer extends XRLayer {
  122430. framebuffer: WebGLFramebuffer;
  122431. }
  122432. declare var XRWebGLLayer: {
  122433. prototype: XRWebGLLayer;
  122434. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  122435. };